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

📄 mainfrac.c

📁 frasr200的win 版本源码(18.21),使用make文件,使用的vc版本较低,在我的环境下编译有问题! 很不错的分形程序代码!
💻 C
📖 第 1 页 / 共 2 页
字号:
    /* compute the (new) screen co-ordinates */
    /* correct a possibly munged-up zoom-box outside the image range */
    if (ytop    >= ydots) ytop    = ydots-1;
    if (ybottom >= ydots) ybottom = ydots-1;
    if (xleft   >= xdots) xleft   = xdots-1;
    if (xright  >= xdots) xright  = xdots-1;
    if (xleft == xright || ytop == ybottom) {
        }
    if (xleft > xright)
        { i = xleft; xleft = xright; xright = i;}
    if (ytop > ybottom)
        { i = ybottom; ybottom = ytop; ytop = i;}
    temp1 = xxmin;
    temp2 = xxmax - xxmin;
    xxmin = temp1 + (temp2 * xleft )/(xdots-1);
    xxmax = temp1 + (temp2 * xright)/(xdots-1);
    temp1 = yymin;
    temp2 = yymax - yymin;
    yymin = temp1 + (temp2 * (ydots - 1 - ybottom)/(ydots-1));
    yymax = temp1 + (temp2 * (ydots - 1 - ytop   )/(ydots-1));
    xx3rd = xxmin;
    yy3rd = yymin;
    xleft   = 0;
    xright  = xdots-1;
    ytop    = 0;
    ybottom = ydots-1;

/*
    delxx = (xxmax - xxmin) / (xdots-1);
    delyy = (yymax - yymin) / (ydots-1);
    delxx2 = delyy2 = 0.0;
    ddelmin = fabs(delxx);
    if (fabs(delyy) < ddelmin)
        ddelmin = fabs(delyy);
*/

    dxsize = xdots - 1;  dysize = ydots - 1;

    if (calc_status != 2 && !overlay3d)
        if (!clear_screen(1)) {
            stopmsg(0,"Can't free and re-allocate the image");
            return(0);
            }

    if (savedac || colorpreloaded) {
        memcpy(dacbox,olddacbox,256*3); /* restore the DAC */
        spindac(0,1);
        colorpreloaded = 0;
        }

    dxsize = xdots - 1;  dysize = ydots - 1;
    sxdots = xdots;  sydots = ydots;
    finalaspectratio = ((float)ydots)/xdots;

    calcfracinit();

    bitshiftless1 = bitshift - 1;

    if (time_to_load)
        goto wait_loop;

      if(showfile == 0) {		/* loading an image */
	 if (display3d) 		/* set up 3D decoding */
	    outln = call_line3d;
	 else if(filetype >= 1) 	/* old .tga format input file */
	    outln = outlin16;
	 else if(comparegif)		/* debug 50 */
	    outln = cmp_line;
	 else if(pot16bit) {		/* .pot format input file */
	    pot_startdisk();
	    outln = pot_line;
	    }
	 else				/* regular gif/fra input file */
	    outln = out_line;
	 if(filetype == 0)
	    i = funny_glasses_call(gifview);
	 else
	    i = funny_glasses_call(tgaview);
	 if(i == 0)
	    buzzer(0);
	 else {
	    calc_status = -1;
	    }
	 }

      if(showfile == 0) {		/* image has been loaded */
	 showfile = 1;
	 if (initbatch == 1 && calc_status == 2)
	    initbatch = -1; /* flag to finish calc before save */
	 if (calc_status == 2) goto try_to_resume;
	 }
      else {				/* draw an image */

try_to_resume:

	 diskisactive = 1;		/* flag for disk-video routines */
	 if (initsavetime != 0		/* autosave and resumable? */
	   && (fractalspecific[fractype].flags&NORESUME) == 0) {
	    savebase = readticker(); /* calc's start time */
	    saveticks = (long)initsavetime * 1092; /* bios ticks/minute */
	    if ((saveticks & 65535) == 0)
	       ++saveticks; /* make low word nonzero */
	    }
         kbdcount = 30;                 /* ensure that we check the keyboard */
	 if ((i = calcfract()) == 0)	/* draw the fractal using "C" */
	    buzzer(0); /* finished!! */
         saveticks = 0; 		/* turn off autosave timer */
         diskisactive = 0;		/* flag for disk-video routines */
	 }

    overlay3d = 0;      /* turn off overlay3d */
    display3d = 0;      /* turn off display3d */

    zwidth = 0;

    if (!keypressed()) {
        flush_screen();
        buzzer(3);
        win_title_text(0);
        getakey();
        }

wait_loop:

    win_title_text(0);

for (;;) {
    if (time_to_act) {
         /* we bailed out of the main loop to take some secondary action */
         time_to_act = 0;
         SecondaryWndProc();
         if (! keypressed())
         	time_to_resume = 1;
         }
    if (time_to_quit) {
         end_help();
         return(0);
         }
    if (time_to_starfield) {
         time_to_starfield = 0;
         win_title_text(4);
         starfield();
         win_title_text(0);
         flush_screen();
         }
    if (time_to_load) {
        strcpy(readname, FileName);
        showfile = 1;
        time_to_load = 0;
        time_to_restart = 0;
        overlay3d = win_overlay3d;
        display3d = win_display3d;
        if (win_load() >= 0) {
            showfile = 0;
            rowcount = 0;
            ytop    = 0;		/* reset the zoom-box */
            ybottom = ydots-1;
            xleft   = 0;
            xright  = xdots-1;
            maxiter = maxit;
            time_to_load = 0;
            time_to_restart = 1;
            if (calc_status == 2) {
                calc_status = -99;      /* special klooge for restart */
                }
            }
        win_overlay3d = 0;
        win_display3d = 0;
        }
    if (time_to_save) {
        strcpy(readname, FileName);
        if (readname[0] != 0)
            win_save();
        time_to_save = 0;
        if (calc_status == 2) {
            calc_status = -99;
            time_to_restart = 1;
            }
        }
    if (time_to_print) {
	PrintFile();
        time_to_print = 0;
        }
    if (time_to_cycle) {
       win_cycle();
       }
    if (time_to_reinit == 2) {
       win_cmdfiles();
       maxiter = maxit;
       }
    if (time_to_reinit)
         goto reinit;
    if(time_to_restart)
         goto restart;
    if(time_to_resume)
        if (calc_status == 2) {
            calc_status = -99;
            time_to_restart = 1;
            goto restart;
            }
    getakey();
    }

}

/* displays differences between current image file and new image */
/* Bert - suggest add this to video.asm */
int cmp_line(unsigned char *pixels, int linelen)
{
   static errcount;
   static FILE *fp = NULL;
   extern int rowcount;
   int row,col;
   int oldcolor;
   char *timestring;
   time_t ltime;
   if(fp == NULL)
      fp = fopen("cmperr",(initbatch)?"a":"w");
   if((row = rowcount++) == 0)
      errcount = 0;
   if(pot16bit) { /* 16 bit info, ignore odd numbered rows */
      if((row & 1) != 0) return(0);
      row >>= 1;
      }
   for(col=0;col<linelen;col++) {
      oldcolor=getcolor(col,row);
      if(oldcolor==pixels[col])
	 putcolor(col,row,0);
      else {
	 if(oldcolor==0)
	    putcolor(col,row,1);
	 ++errcount;
	 if(initbatch == 0)
	    fprintf(fp,"#%5d col %3d row %3d old %3d new %3d\n",
	       errcount,col,row,oldcolor,pixels[col]);
	 }
      }
   if(row+1 == ydots && initbatch) {
      time(&ltime);
      timestring = ctime(&ltime);
      timestring[24] = 0; /*clobber newline in time string */
      fprintf(fp,"%s compare to %s has %5d errs\n",timestring,readname,errcount);
      }
   return(0);
}

int pot_line(unsigned char *pixels, int linelen)
{
   extern int rowcount;
   int row,col,saverowcount;
   if (rowcount == 0)
      pot_startdisk();
   saverowcount = rowcount;
   row = (rowcount >>= 1);
   if ((saverowcount & 1) != 0) /* odd line */
      row += ydots;
   else 			/* even line */
      if (dotmode != 11) /* display the line too */
	 out_line(pixels,linelen);
   for (col = 0; col < xdots; ++col)
      writedisk(col+sxoffs,row+syoffs,*(pixels+col));
   rowcount = saverowcount + 1;
   return(0);
}

static int call_line3d(unsigned char *pixels, int linelen)
{
   /* this routine exists because line3d might be in an overlay */
   return(line3d(pixels,linelen));
}

void win_cmdfiles()   /* convert lpCmdLine into argc, argv */
{
int i, k;
int argc;
char *argv[10];
unsigned char arg[501];   /* max 10 args, 450 chars total */

arg[0] = 0;
for (i = 0; i < 10; i++)
   argv[i] = &arg[0];
argc = 1;
strcpy(&arg[1],"winfract.exe");
argv[argc-1] = &arg[1];

for (i = 0; i < 460 && win_lpCmdLine[i] != 0; i++)
   arg[20+i] = win_lpCmdLine[i];
arg[20+i] = 0;
arg[21+i] = 0;

for (k = 20; arg[k] != 0; k++) {
    while(arg[k] <= ' ' && arg[k] != 0) k++;
    if (arg[k] == 0) break;
    if (argc >= 10) break;
    argc++;
    argv[argc-1] = &arg[k];
    while(arg[k] > ' ')k++;
    arg[k] = 0;
    }

cmdfiles(argc,argv);

}

⌨️ 快捷键说明

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