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

📄 miscovl.c

📁 frasr200的win 版本源码(18.21),使用make文件,使用的vc版本较低,在我的环境下编译有问题! 很不错的分形程序代码!
💻 C
📖 第 1 页 / 共 5 页
字号:
{
   int i,j;
   if ((i = vidtbl[*((int *)p1)].keynum) == 0) i = 9999;
   if ((j = vidtbl[*((int *)p2)].keynum) == 0) j = 9999;
   if (i < j || (i == j && *((int *)p1) < *((int *)p2)))
      return(-1);
   return(1);
}

static void update_fractint_cfg()
{
#ifndef XFRACT
   char cfgname[100],outname[100],buf[121],kname[5];
   FILE *cfgfile,*outfile;
   int far *cfglinenums;
   int i,j,linenum,nextlinenum,nextmode;
   struct videoinfo vident;

   findpath("fractint.cfg",cfgname);

   if (access(cfgname,6)) {
      sprintf(buf,s_cantwrite,cfgname);
      stopmsg(0,buf);
      return;
      }
   strcpy(outname,cfgname);
   i = strlen(outname);
   while (--i >= 0 && outname[i] != SLASHC)
   outname[i] = 0;
   strcat(outname,"fractint.tmp");
   if ((outfile = fopen(outname,"w")) == NULL) {
      sprintf(buf,s_cantcreate,outname);
      stopmsg(0,buf);
      return;
      }
   cfgfile = fopen(cfgname,"r");

   cfglinenums = (int far *)(&vidtbl[MAXVIDEOMODES]);
   linenum = nextmode = 0;
   nextlinenum = cfglinenums[0];
   while (fgets(buf,120,cfgfile)) {
      ++linenum;
      if (linenum == nextlinenum) { /* replace this line */
	 far_memcpy((char far *)&vident,(char far *)&vidtbl[nextmode],
		    sizeof(videoentry));
	 vidmode_keyname(vident.keynum,kname);
	 strcpy(buf,vident.name);
	 i = strlen(buf);
	 while (i && buf[i-1] == ' ') /* strip trailing spaces to compress */
	    --i;
	 j = i + 5;
	 while (j < 32) {		/* tab to column 33 */
	    buf[i++] = '\t';
	    j += 8;
	    }
	 buf[i] = 0;
	 fprintf(outfile,"%-4s,%s,%4x,%4x,%4x,%4x,%4d,%4d,%4d,%3d,%s\n",
		kname,
		buf,
		vident.videomodeax,
		vident.videomodebx,
		vident.videomodecx,
		vident.videomodedx,
		vident.dotmode,
		vident.xdots,
		vident.ydots,
		vident.colors,
		vident.comment);
	 if (++nextmode >= vidtbllen)
	    nextlinenum = 32767;
	 else
	    nextlinenum = cfglinenums[nextmode];
	 }
      else
	 fputs(buf,outfile);
      }

   fclose(cfgfile);
   fclose(outfile);
   unlink(cfgname);	    /* success assumed on these lines	    */
   rename(outname,cfgname); /* since we checked earlier with access */
#endif
}

extern unsigned char olddacbox[256][3];
extern int gif87a_flag;

/* make_mig() takes a collection of individual GIF images (all
   presumably the same resolution and all presumably generated
   by Fractint and its "divide and conquer" algorithm) and builds
   a single multiple-image GIF out of them.  This routine is
   invoked by the "batch=stitchmode/x/y" option, and is called
   with the 'x' and 'y' parameters
*/

make_mig(unsigned int xmult, unsigned int ymult)
{
unsigned int xstep, ystep;
unsigned int xres, yres;
unsigned int allxres, allyres, xtot, ytot;
unsigned int xloc, yloc;
unsigned int x, y;
unsigned char ichar;
unsigned int allitbl, itbl;
unsigned int i, j, k;
char gifin[15], gifout[15];
int errorflag, inputerrorflag;
unsigned char *temp;
FILE *out, *in;
char msgbuf[81];

errorflag = 0;				/* no errors so far */

strcpy(gifout,"fractmig.gif");

temp= &olddacbox[0][0];			/* a safe place for our temp data */

gif87a_flag = 1;			/* for now, force this */

/* process each input image, one at a time */
for (ystep = 0; ystep < ymult; ystep++) {
    for (xstep = 0; xstep < xmult; xstep++) {

if (xstep == 0 && ystep == 0) {		/* first time through? */
    static char far msg1[] = "Cannot create output file %s!\n";
    static char far msg2[] = " \n Generating multi-image GIF file %s using";
    static char far msg3[] = " %d X and %d Y components\n\n";
    _fstrcpy(msgbuf, msg2);
    printf(msgbuf, gifout);
    _fstrcpy(msgbuf, msg3);
    printf(msgbuf, xmult, ymult);
    /* attempt to create the output file */
    if ((out = fopen(gifout,"wb")) == NULL) {
        _fstrcpy(msgbuf, msg1);
        printf(msgbuf, gifout);
        exit(1);
        }
    }

        sprintf(gifin, "frmig_%c%c.gif", PAR_KEY(xstep), PAR_KEY(ystep));

        if ((in = fopen(gifin,"rb")) == NULL) {
            static char far msg1[] = "Can't open file %s!\n";
            _fstrcpy(msgbuf, msg1);
            printf(msgbuf, gifin);
            exit(1);
            }

        inputerrorflag = 0;

        /* (read, but only copy this if it's the first time through) */
        if (fread(temp,13,1,in) != 1)	/* read the header and LDS */
            inputerrorflag = 1;
        memcpy(&xres, &temp[6], 2);	/* X-resolution */
        memcpy(&yres, &temp[8], 2);	/* Y-resolution */

        if (xstep == 0 && ystep == 0) {	/* first time through? */
            allxres = xres;		/* save the "master" resolution */
            allyres = yres;
            xtot = xres * xmult;	/* adjust the image size */
            ytot = yres * ymult;
            memcpy(&temp[6], &xtot, 2);
            memcpy(&temp[8], &ytot, 2);
            if (gif87a_flag) {
                temp[3] = '8';
                temp[4] = '7';
                temp[5] = 'a';
                }
            if (fwrite(temp,13,1,out) != 1)	/* write out the header */
                errorflag = 1;
            }				/* end of first-time-through */


        ichar = temp[10] & 0x07;	/* find the color table size */
        itbl = 1 << (++ichar);
        ichar = temp[10] & 0x80;	/* is there a global color table? */
        if (xstep == 0 && ystep == 0)	/* first time through? */
            allitbl = itbl;		/* save the color table size */
        if (ichar != 0) {		/* yup */
            /* (read, but only copy this if it's the first time through) */
            if(fread(temp,3*itbl,1,in) != 1)	/* read the global color table */
                inputerrorflag = 2;
            if (xstep == 0 && ystep == 0)	/* first time through? */
                if (fwrite(temp,3*itbl,1,out) != 1)	/* write out the GCT */
                    errorflag = 2;
            }

        if (xres != allxres || yres != allyres || itbl != allitbl) {
            /* Oops - our pieces don't match */
            static char far msg1[] = "File %s doesn't have the same resolution as its predecessors!\n";
            _fstrcpy(msgbuf, msg1);
            printf(msgbuf, gifin);
            exit(1);
            }

        for (;;) {			/* process each information block */
        if (fread(temp,1,1,in) != 1)	/* read the block identifier */
            inputerrorflag = 3;

        if (temp[0] == 0x2c) {		/* image descriptor block */
            if (fread(&temp[1],9,1,in) != 1)	/* read the Image Descriptor */
                inputerrorflag = 4;
            memcpy(&xloc, &temp[1], 2);	/* X-location */
            memcpy(&yloc, &temp[3], 2);	/* Y-location */
            xloc += (xstep * xres);	/* adjust the locations */
            yloc += (ystep * yres);
            memcpy(&temp[1], &xloc, 2);
            memcpy(&temp[3], &yloc, 2);
            if (fwrite(temp,10,1,out) != 1)	/* write out the Image Descriptor */
                errorflag = 4;

            ichar = temp[9] & 0x80;	/* is there a local color table? */
            if (ichar != 0) {		/* yup */
                if (fread(temp,3*itbl,1,in) != 1)	/* read the local color table */
                    inputerrorflag = 5;
                if (fwrite(temp,3*itbl,1,out) != 1)	/* write out the LCT */
                    errorflag = 5;
                }

            if (fread(temp,1,1,in) != 1)	/* LZH table size */
                inputerrorflag = 6;
            if (fwrite(temp,1,1,out) != 1)
                errorflag = 6;
            while (1) {
                if (errorflag != 0 || inputerrorflag != 0)	/* oops - did something go wrong? */
                    break;
                if (fread(temp,1,1,in) != 1)	/* block size */
                    inputerrorflag = 7;
                if (fwrite(temp,1,1,out) != 1)
                    errorflag = 7;
                if ((i = temp[0]) == 0)
                    break;
                if (fread(temp,i,1,in) != 1)	/* LZH data block */
                    inputerrorflag = 8;
                if (fwrite(temp,i,1,out) != 1)
                    errorflag = 8;
                }
            }

        if (temp[0] == 0x21) {		/* extension block */
            /* (read, but only copy this if it's the last time through) */
            if (fread(&temp[2],1,1,in) != 1)	/* read the block type */
                inputerrorflag = 9;
            if ((!gif87a_flag) && xstep == xmult-1 && ystep == ymult-1)
                if (fwrite(temp,2,1,out) != 1)
                    errorflag = 9;
            while (1) {
                if (errorflag != 0 || inputerrorflag != 0)	/* oops - did something go wrong? */
                    break;
                if (fread(temp,1,1,in) != 1)	/* block size */
                    inputerrorflag = 10;
                if ((!gif87a_flag) && xstep == xmult-1 && ystep == ymult-1)
                    if (fwrite(temp,1,1,out) != 1)
                        errorflag = 10;
                if ((i = temp[0]) == 0)
                    break;
                if (fread(temp,i,1,in) != 1)	/* data block */
                    inputerrorflag = 11;
                if ((!gif87a_flag) && xstep == xmult-1 && ystep == ymult-1)
                    if (fwrite(temp,i,1,out) != 1)
                        errorflag = 11;
                }
            }

        if (temp[0] == 0x3b) {		/* end-of-stream indicator */
            break;			/* done with this file */
            }

        if (errorflag != 0 || inputerrorflag != 0)	/* oops - did something go wrong? */
            break;

        }
        fclose(in);			/* done with an input GIF */

        if (errorflag != 0 || inputerrorflag != 0)	/* oops - did something go wrong? */
            break;
        }

    if (errorflag != 0 || inputerrorflag != 0)	/* oops - did something go wrong? */
        break;
    }

temp[0] = 0x3b;			/* end-of-stream indicator */
if (fwrite(temp,1,1,out) != 1)
    errorflag = 12;
fclose(out);			/* done with the output GIF */

if (inputerrorflag != 0) {	/* uh-oh - something failed */
    static char far msg1[] = "\007 Process failed = early EOF on input file %s\n";
    _fstrcpy(msgbuf, msg1);
    printf(msgbuf, gifin);
/* following line was for debugging
    printf("inputerrorflag = %d\n", inputerrorflag);
*/
    }

if (errorflag != 0) {		/* uh-oh - something failed */
    static char far msg1[] = "\007 Process failed = out of disk space?\n";
    _fstrcpy(msgbuf, msg1);
    printf(msgbuf);
/* following line was for debugging
    printf("errorflag = %d\n", errorflag);
*/
    }

/* now delete each input image, one at a time */
if (errorflag == 0 && inputerrorflag == 0)
  for (ystep = 0; ystep < ymult; ystep++) {
    for (xstep = 0; xstep < xmult; xstep++) {
        sprintf(gifin, "frmig_%c%c.gif", PAR_KEY(xstep), PAR_KEY(ystep));
        remove(gifin);
        }
    }

/* tell the world we're done */
if (errorflag == 0 && inputerrorflag == 0) {
    static char far msg1[] = "File %s has been created (and its component files deleted)\n";
    _fstrcpy(msgbuf, msg1);
    printf(msgbuf, gifout);
    }
}

/* This routine copies the current screen to by flipping x-axis, y-axis,
   or both. Refuses to work if calculation in progress or if fractal
   non-resumable. Clears zoombox if any. Resets corners so resulting fractal
   is still valid. */
void flip_image(int key)
{
   int i, j, ix, iy, ixhalf, iyhalf, tempdot;

   ENTER_OVLY(OVLY_MISCOVL);
   /* fractal must be rotate-able and be finished */
   if ((curfractalspecific->flags&NOROTATE) > 0 
       || calc_status == 1   
       || calc_status == 2)  
      return;
   clear_zoombox(); /* clear, don't copy, the zoombox */
   ixhalf = xdots / 2;  
   iyhalf = ydots / 2;
   switch(key)
   {
   case 24:            /* control-X - reverse X-axis */
      for (i = 0; i < ixhalf; i++) 
      {
         if(keypressed())
            break;
         for (j = 0; j < ydots; j++) 
         {
            tempdot=getcolor(i,j);
            putcolor(i, j, getcolor(xdots-1-i,j));
            putcolor(xdots-1-i, j, tempdot);
         }
      }
      sxmin = xxmax + xxmin - xx3rd;
      symax = yymax + yymin - yy3rd;
      sxmax = xx3rd;
      symin = yy3rd;
      sx3rd = xxmax;
      sy3rd = yymin;
      reset_zoom_corners();
      calc_status = 0;
      break;
   case 25:            /* control-Y - reverse Y-aXis */
      for (j = 0; j < iyhalf; j++)
      {
         if(keypressed())
            break;
         for (i = 0; i < xdots; i++) 
         {
            tempdot=getcolor(i,j);
            putcolor(i, j, getcolor(i,ydots-1-j));
            putcolor(i,ydots-1-j, tempdot);
         }
      }
      sxmin = xx3rd;
      symax = yy3rd;
      sxmax = xxmax + xxmin - xx3rd;
      symin = yymax + yymin - yy3rd;
      sx3rd = xxmin;
      sy3rd = yymax;
      calc_status = 0;
      break;
   case 26:            /* control-Z - reverse X and Y aXis */
      for (i = 0; i < ixhalf; i++) 
      {
         if(keypressed())
            break;
         for (j = 0; j < ydots; j++) 
         {
            tempdot=getcolor(i,j);
            putcolor(i, j, getcolor(xdots-1-i,ydots-1-j));
            putcolor(xdots-1-i, ydots-1-j, tempdot);
         }
      }
      sxmin = xxmax;
      symax = yymin;
      sxmax = xxmin;
      symin = yymax;
      sx3rd = xxmax + xxmin - xx3rd;
      sy3rd = yymax + yymin - yy3rd;
      break;
   }
   reset_zoom_corners();
   calc_status = 0;
   EXIT_OVLY;
}

⌨️ 快捷键说明

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