diff options
| -rw-r--r-- | src/post/goom/Makefile.am | 35 | ||||
| -rw-r--r-- | src/post/goom/drawmethods.h | 41 | ||||
| -rw-r--r-- | src/post/goom/filters.c | 1075 | ||||
| -rw-r--r-- | src/post/goom/filters.h | 52 | ||||
| -rw-r--r-- | src/post/goom/goom_config.h | 14 | ||||
| -rw-r--r-- | src/post/goom/goom_core.c | 1377 | ||||
| -rw-r--r-- | src/post/goom/goom_core.h | 21 | ||||
| -rw-r--r-- | src/post/goom/goom_tools.h | 6 | ||||
| -rw-r--r-- | src/post/goom/graphic.c | 26 | ||||
| -rw-r--r-- | src/post/goom/graphic.h | 8 | ||||
| -rw-r--r-- | src/post/goom/ifs.c | 414 | ||||
| -rw-r--r-- | src/post/goom/ifs.h | 27 | ||||
| -rw-r--r-- | src/post/goom/ifs_display.c | 466 | ||||
| -rw-r--r-- | src/post/goom/lines.c | 784 | ||||
| -rw-r--r-- | src/post/goom/lines.h | 86 | ||||
| -rw-r--r-- | src/post/goom/ppc_zoom_ultimate.s | 149 | ||||
| -rw-r--r-- | src/post/goom/xine_goom.c | 97 | ||||
| -rw-r--r-- | src/post/goom/zoom_filter_mmx.c | 119 | 
18 files changed, 2775 insertions, 2022 deletions
| diff --git a/src/post/goom/Makefile.am b/src/post/goom/Makefile.am index 99a11335c..2e9ae1c0f 100644 --- a/src/post/goom/Makefile.am +++ b/src/post/goom/Makefile.am @@ -2,23 +2,42 @@  ## Process this file with automake to produce Makefile.in  ## -AM_CFLAGS = @ANSI_FLAGS@  DEBUG_CFLAGS = @DEBUG_CFLAGS@ @ANSI_FLAGS@  LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic +# FIXME +# -fomit-frame-pointer segfaults here +CFLAGS = -DHAVE_CONFIG_H -I. -I. -I../../.. -I../../.. -I../../../include -I../../../include -I../../../src -I../../../src/xine-engine -I../../../src/xine-engine -I../../../src/xine-utils -Wall -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DXINE_COMPILE -O3 -pipe -falign-functions=4 -falign-loops=4 -falign-jumps=4 -mpreferred-stack-boundary=2 -fexpensive-optimizations -fschedule-insns2 -fno-strict-aliasing -ffast-math -funroll-loops -finline-functions -mcpu=pentiumpro +  libdir = $(XINE_PLUGINDIR)/post  lib_LTLIBRARIES = xineplug_post_goom.la -xineplug_post_goom_la_SOURCES = \ +if !PPC_ARCH +  xineplug_post_goom_la_SOURCES = \ +        xine_goom.c \ +        goom_core.c goom_core.h \ +        goom_tools.h goom_config.h \ +        filters.c filters.h\ +        lines.c lines.h \ +        ifs_display.c ifs.c ifs.h \ +        graphic.c graphic.h \ +        drawmethods.h \ +        zoom_filter_mmx.c + +else +  xineplug_post_goom_la_SOURCES = \          xine_goom.c \ -	goom_core.c goom_core.h \ -	goom_tools.h goom_config.h \ -	filters.c filters.h \ -	lines.c lines.h \ -	ifs_display.c ifs.c ifs.h \ -	graphic.c graphic.h +        goom_core.c goom_core.h \ +        goom_tools.h goom_config.h \ +        filters.c filters.h \ +        lines.c lines.h \ +        ifs_display.c ifs.c ifs.h \ +        graphic.c graphic.h \ +        drawmethods.h \ +        ppc_zoom_ultimate.s +endif  xineplug_post_goom_la_LIBADD = $(XINE_LIB)  xineplug_post_goom_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@ diff --git a/src/post/goom/drawmethods.h b/src/post/goom/drawmethods.h new file mode 100644 index 000000000..4ad83b047 --- /dev/null +++ b/src/post/goom/drawmethods.h @@ -0,0 +1,41 @@ +#ifndef _DRAWMETHODS_H +#define _DRAWMETHODS_H + +#include "goom_config.h" + +#define DRAWMETHOD_NORMAL(adr,col) {*(adr) = (col);} + +/* #ifdef MMX */ +#if 0 +#define DRAWMETHOD_PLUS(_out,_backbuf,_col) \ +{\ +__asm__		("movd %%eax,%%mm0\n movd %%edx,%%mm1\n paddusb %%mm1,%%mm0\n movd %%mm0,%%eax"\ +:"=eax"(_out):"eax"(_backbuf),"edx"(_col));\ +} +#else +#define DRAWMETHOD_PLUS(_out,_backbuf,_col) \ +{\ +      int tra=0,i=0;\ +      unsigned char *bra = (unsigned char*)&(_backbuf);\ +      unsigned char *dra = (unsigned char*)&(_out);\ +      unsigned char *cra = (unsigned char*)&(_col);\ +      for (;i<4;i++) {\ +				tra = *cra;\ +				tra += *bra;\ +				if (tra>255) tra=255;\ +				*dra = tra;\ +				++dra;++cra;++bra;\ +			}\ +} +#endif + +#define DRAWMETHOD_OR(adr,col) {*(adr)|=(col);} + +/* #ifdef MMX */ +#if 0 +#define DRAWMETHOD_DONE() {__asm__ __volatile__ ("emms");} +#else +#define DRAWMETHOD_DONE() {} +#endif + +#endif diff --git a/src/post/goom/filters.c b/src/post/goom/filters.c index e33da4e8c..f18b6cbba 100644 --- a/src/post/goom/filters.c +++ b/src/post/goom/filters.c @@ -31,116 +31,141 @@  extern volatile guint32 resolx;  extern volatile guint32 c_resoly; +extern volatile int     use_asm; -guint32 mmx_zoom_size; -  #ifdef MMX -void zoom_filter_mmx (int prevX, int prevY, -		      unsigned int *expix1, unsigned int *expix2, -		      int *brutS, int *brutD, int buffratio, -		      int precalCoef[16][16]); - +/*int mmx_zoom () ;*/ +void    zoom_filter_mmx (int prevX, int prevY, +												 unsigned int *expix1, unsigned int *expix2, +												 int *brutS, int *brutD, int buffratio, +												 int precalCoef[16][16]);  #endif /* MMX */ + +guint32 mmx_zoom_size; + +#ifdef USE_ASM +  #ifdef POWERPC -extern unsigned int useAltivec; -extern void ppc_zoom(unsigned int * frompixmap, unsigned int * topixmap, -		     unsigned int sizex, unsigned int sizey, -		     unsigned int * brutS, unsigned int * brutD, unsigned int buffratio,int precalCoef[16][16]); -extern void ppc_zoom_altivec(void); +/* extern unsigned int useAltivec; */ +extern void ppc_zoom (unsigned int *frompixmap, unsigned int *topixmap, +											unsigned int sizex, unsigned int sizey, +											unsigned int *brutS, unsigned int *brutD, + +											unsigned int buffratio); +/* extern void ppc_zoom_altivec (void); */ + +/*extern void ppc_zoom(void);*/  unsigned int ppcsize4;  #endif /* PowerPC */ +#endif /* ASM */ + -signed int *brutS = 0, *freebrutS = 0; /*  source */ -signed int *brutD = 0, *freebrutD = 0; /*  dest */ -signed int *brutT = 0, *freebrutT = 0; /*  temp (en cours de génération) */ +/* A VIRER */ +unsigned int *coeffs = 0, *freecoeffs = 0;	/* ne sont plus utilisé */ -guint32 *expix1 = 0; /*  pointeur exporte vers p1 */ -guint32 *expix2 = 0; /*  pointeur exporte vers p2 */ +signed int *brutS = 0, *freebrutS = 0;	/* source */ +signed int *brutD = 0, *freebrutD = 0;	/* dest */ +signed int *brutT = 0, *freebrutT = 0;	/* temp (en cours de génération) */ + +guint32 *expix1 = 0;						/* pointeur exporte vers p1 */ +guint32 *expix2 = 0;						/* pointeur exporte vers p2 */  guint32 zoom_width; -int prevX=0,prevY=0; +int     prevX = 0, prevY = 0; -static int sintable [0xffff] ; +static int sintable[0xffff];  static int vitesse = 127; -static char theMode = AMULETTE_MODE ; +static char theMode = AMULETTE_MODE;  static int waveEffect = 0;  static int hypercosEffect = 0;  static int vPlaneEffect = 0;  static int hPlaneEffect = 0;  static char noisify = 2; -static int middleX , middleY ; -/* static unsigned char sqrtperte = 16 ; */ +static int middleX, middleY; + +/*static unsigned char sqrtperte = 16 ; */  /** modif by jeko : fixedpoint : buffration = (16:16) (donc 0<=buffration<=2^16) */ -/* static int buffratio = 0; */ -int buffratio = 0; +/*static int buffratio = 0; */ +int     buffratio = 0; +  #define BUFFPOINTNB 16  #define BUFFPOINTMASK 0xffff  #define BUFFINCR 0xff  #define sqrtperte 16 -/*  faire : a % sqrtperte <=> a & pertemask */ +/* faire : a % sqrtperte <=> a & pertemask */  #define PERTEMASK 0xf -/*  faire : a / sqrtperte <=> a >> PERTEDEC */ +/* faire : a / sqrtperte <=> a >> PERTEDEC */  #define PERTEDEC 4 -static int * firedec = 0 ; +static int *firedec = 0; -/*  retourne x>>s , en testant le signe de x */ +/* retourne x>>s , en testant le signe de x */  int ShiftRight (int x, const unsigned char s)  { -    if (x<0) -	return -(-x >> s) ; -    else -	return x >> s ; +	if (x < 0) +		return -(-x >> s); +	else +		return x >> s;  }  /** modif d'optim by Jeko : precalcul des 4 coefs résultant des 2 pos */ -int precalCoef[16][16]; +int     precalCoef[16][16]; -void generatePrecalCoef () { -    static int firstime = 1; -    if (firstime) { -	int coefh,coefv; -	firstime = 0; - -	/* 		precalCoef = (int**) malloc (17*sizeof (int*)); */ - -	for (coefh=0;coefh<16;coefh++) { -	    /* 			precalCoef [coefh] = (int *) malloc (17*sizeof (int)); */ - -	    for (coefv=0;coefv<16;coefv++) { -		int i; -		int diffcoeffh; -		int diffcoeffv; - -		diffcoeffh = sqrtperte - coefh; -		diffcoeffv = sqrtperte - coefv; - -		/* 			coeffs[myPos] = ((px >> PERTEDEC) + prevX * (py >> PERTEDEC)) << 2; */ -		if (!(coefh || coefv)) i = 255 ; -		else { -		    int i1,i2,i3,i4; -		    i1 = diffcoeffh * diffcoeffv; -		    i2 = coefh * diffcoeffv; -		    i3 = diffcoeffh * coefv; -		    i4 = coefh * coefv; -		    if (i1) i1--; -		    if (i2) i2--; -		    if (i3) i3--; -		    if (i4) i4--; - -		    i = (i1)|(i2<<8)|(i3<<16)|(i4<<24); +void generatePrecalCoef () +{ +	static int firstime = 1; + +	if (firstime) { +		int     coefh, coefv; + +		firstime = 0; + +/*              precalCoef = (int**) malloc (17*sizeof (int*)); */ + +		for (coefh = 0; coefh < 16; coefh++) { +/*                      precalCoef [coefh] = (int *) malloc (17*sizeof (int)); */ + +			for (coefv = 0; coefv < 16; coefv++) { +				int     i; +				int     diffcoeffh; +				int     diffcoeffv; + +				diffcoeffh = sqrtperte - coefh; +				diffcoeffv = sqrtperte - coefv; + +				/* coeffs[myPos] = ((px >> PERTEDEC) + prevX * (py >> PERTEDEC)) << */ +				/* 2; */ +				if (!(coefh || coefv)) +					i = 255; +				else { +					int     i1, i2, i3, i4; + +					i1 = diffcoeffh * diffcoeffv; +					i2 = coefh * diffcoeffv; +					i3 = diffcoeffh * coefv; +					i4 = coefh * coefv; +					if (i1) +						i1--; +					if (i2) +						i2--; +					if (i3) +						i3--; +					if (i4) +						i4--; + +					i = (i1) | (i2 << 8) | (i3 << 16) | (i4 << 24); +				} +				precalCoef[coefh][coefv] = i; +			}  		} -		precalCoef [coefh][coefv] = i; -	    }  	} -    }  }  /* @@ -150,495 +175,518 @@ void generatePrecalCoef () {   */  void calculatePXandPY (int x, int y, int *px, int *py)  { -    if (theMode == WATER_MODE) -    { -        static int wave = 0 ; -        static int wavesp = 0 ; -        int yy ; - -        yy = y + RAND () % 4 - RAND () % 4 + wave / 10 ; -        if (yy < 0) yy = 0 ; -        if (yy >= c_resoly) yy = c_resoly - 1 ; - -        *px = (x<<4) + firedec [yy] + (wave / 10) ; -        *py = (y<<4) + 132 - ((vitesse < 132) ? vitesse : 131) ; - -        wavesp += RAND () % 3 - RAND () % 3 ; -        if (wave < -10) wavesp += 2 ; -        if (wave > 10) wavesp -= 2 ; -        wave += (wavesp / 10) + RAND () % 3 - RAND () % 3 ; -        if (wavesp > 100) wavesp = (wavesp * 9) / 10  ; -    } -    else -    { -        int dist=0 ,vx9,vy9; -        register int vx,vy ; -		int ppx,ppy; -        int fvitesse = vitesse << 4 ; -		 -        if (noisify) -		  { -            x += RAND() % noisify - RAND() % noisify ; -            y += RAND() % noisify - RAND() % noisify ; -		  } +	if (theMode == WATER_MODE) { +		static int wave = 0; +		static int wavesp = 0; +		int     yy; + +		yy = y + RAND () % 4 - RAND () % 4 + wave / 10; +		if (yy < 0) +			yy = 0; +		if (yy >= c_resoly) +			yy = c_resoly - 1; + +		*px = (x << 4) + firedec[yy] + (wave / 10); +		*py = (y << 4) + 132 - ((vitesse < 132) ? vitesse : 131); + +		wavesp += RAND () % 3 - RAND () % 3; +		if (wave < -10) +			wavesp += 2; +		if (wave > 10) +			wavesp -= 2; +		wave += (wavesp / 10) + RAND () % 3 - RAND () % 3; +		if (wavesp > 100) +			wavesp = (wavesp * 9) / 10; +	} +	else { +		int     dist = 0, vx9, vy9; +		register int vx, vy; +		int     ppx, ppy; +		int     fvitesse = vitesse << 4; + +		if (noisify) { +			x += RAND () % noisify - RAND () % noisify; +			y += RAND () % noisify - RAND () % noisify; +		}  		vx = (x - middleX) << 9;  		vy = (y - middleY) << 9; -		 -        if (hPlaneEffect) vx += hPlaneEffect * (y - middleY); -		/*         else vx = (x - middleX) << 9 ; */ -		 -        if (vPlaneEffect) vy += vPlaneEffect * (x - middleX); -		/*         else vy = (y - middleY) << 9 ; */ -		 + +		if (hPlaneEffect) +			vx += hPlaneEffect * (y - middleY); +		/* else vx = (x - middleX) << 9 ; */ + +		if (vPlaneEffect) +			vy += vPlaneEffect * (x - middleX); +		/* else vy = (y - middleY) << 9 ; */ +  		if (waveEffect) { -		  fvitesse *= 1024 + ShiftRight ( -			sintable [(unsigned short)(0xffff*dist*EFFECT_DISTORS)],6); -		  fvitesse /= 1024 ; +			fvitesse *= +				1024 + +				ShiftRight (sintable +										[(unsigned short) (0xffff * dist * EFFECT_DISTORS)], 6); +			fvitesse /= 1024;  		}  		if (hypercosEffect) { -		  vx += ShiftRight(sintable [(-vy+dist)&0xffff],1); -		  vy += ShiftRight(sintable [(vx+dist)&0xffff],1); +			vx += ShiftRight (sintable[(-vy + dist) & 0xffff], 1); +			vy += ShiftRight (sintable[(vx + dist) & 0xffff], 1);  		} -		 -		vx9 = ShiftRight(vx,9); -		vy9 = ShiftRight(vy,9); -		dist = vx9*vx9+vy9*vy9; -		 -        switch (theMode) -		  { -		  case WAVE_MODE: -			fvitesse *= 1024 + ShiftRight ( -			  sintable [(unsigned short)(0xffff*dist*EFFECT_DISTORS)],6); -			fvitesse /= 1024 ; -			break ; -		  case CRYSTAL_BALL_MODE: + +		vx9 = ShiftRight (vx, 9); +		vy9 = ShiftRight (vy, 9); +		dist = vx9 * vx9 + vy9 * vy9; + +		switch (theMode) { +		case WAVE_MODE: +			fvitesse *= +				1024 + +				ShiftRight (sintable +										[(unsigned short) (0xffff * dist * EFFECT_DISTORS)], 6); +			fvitesse /= 1024; +			break; +		case CRYSTAL_BALL_MODE:  			fvitesse += (dist * EFFECT_DISTORS >> 10);  			break; -		  case AMULETTE_MODE: +		case AMULETTE_MODE:  			fvitesse -= (dist * EFFECT_DISTORS >> 4);  			break; -		  case SCRUNCH_MODE: +		case SCRUNCH_MODE:  			fvitesse -= (dist * EFFECT_DISTORS >> 9);  			break; -		  case HYPERCOS1_MODE: -			vx = vx + ShiftRight(sintable [(-vy+dist)&0xffff],1); -			vy = vy + ShiftRight(sintable [(vx+dist)&0xffff],1); +		case HYPERCOS1_MODE: +			vx = vx + ShiftRight (sintable[(-vy + dist) & 0xffff], 1); +			vy = vy + ShiftRight (sintable[(vx + dist) & 0xffff], 1);  			break; -		  case HYPERCOS2_MODE: -			vx = vx + ShiftRight(sintable [(-ShiftRight(vy,1)+dist)&0xffff],0); -			vy = vy + ShiftRight(sintable [(ShiftRight(vx,1)+dist)&0xffff],0); -			fvitesse = 128<<4; +		case HYPERCOS2_MODE: +			vx = +				vx + ShiftRight (sintable[(-ShiftRight (vy, 1) + dist) & 0xffff], 0); +			vy = +				vy + ShiftRight (sintable[(ShiftRight (vx, 1) + dist) & 0xffff], 0); +			fvitesse = 128 << 4;  			break; -		  } +		}  		if (fvitesse < -3024) -		  fvitesse = -3024; -		 -        if (vx<0) /*  pb avec decalage sur nb negatif */ -		  ppx = - (-(vx * fvitesse) >> 16); -		/* 16 = 9 + 7 (7 = nb chiffre virgule de vitesse -		 * (v = 128 => immobile) -		 * 9 = nb chiffre virgule de vx) */ -        else -		  ppx = ((vx * fvitesse) >> 16) ; -		 -        if (vy<0) -		  ppy = - (-(vy * fvitesse) >> 16) ; -        else -		  ppy = ((vy * fvitesse) >> 16) ; - -		*px=(middleX << 4)+ppx; -		*py=(middleY << 4)+ppy; -    } +			fvitesse = -3024; + +		if (vx < 0)									/* pb avec decalage sur nb negatif  */ +			ppx = -(-(vx * fvitesse) >> 16); +		/* 16 = 9 + 7 (7 = nb chiffre virgule de vitesse * (v = 128 => immobile) */ +		/* * * * * * 9 = nb chiffre virgule de vx) */ +		else +			ppx = ((vx * fvitesse) >> 16); + +		if (vy < 0) +			ppy = -(-(vy * fvitesse) >> 16); +		else +			ppy = ((vy * fvitesse) >> 16); + +		*px = (middleX << 4) + ppx; +		*py = (middleY << 4) + ppy; +	}  } -/* #define _DEBUG */ +/*#define _DEBUG */ -void setPixelRGB(Uint *buffer, Uint x, Uint y, Color c) +void setPixelRGB (Uint * buffer, Uint x, Uint y, Color c)  { -    /* 		buffer[ y*WIDTH + x ] = (c.r<<16)|(c.v<<8)|c.b */ +	/* buffer[ y*WIDTH + x ] = (c.r<<16)|(c.v<<8)|c.b */  #ifdef _DEBUG_PIXEL -    if ( x+y*resolx >= resolx * resoly) -	  { -		fprintf (stderr,"setPixel ERROR : hors du tableau... %i, %i\n", x,y) ; +	if (x + y * resolx >= resolx * resoly) { +		fprintf (stderr, "setPixel ERROR : hors du tableau... %i, %i\n", x, y);  		/* exit (1) ; */ -	  } +	}  #endif -	 -/* #ifdef USE_DGA */ -/*     buffer[ y*resolx + x ] = (c.b<<16)|(c.v<<8)|c.r ; */ -/* #else */ -/* #ifdef COLOR_BGRA */ -    buffer[ y*resolx + x ] = (c.b<<(BLEU*8))|(c.v<<(VERT*8))|(c.r<<(ROUGE*8)) ; -/* #else */ -/*     buffer[ y*resolx + x ] = (c.r<<16)|(c.v<<8)|c.b ; */ -/* #endif */ -/* #endif */ + +/*#ifdef USE_DGA */ +/*    buffer[ y*resolx + x ] = (c.b<<16)|(c.v<<8)|c.r ; */ +/*#else */ +/*#ifdef COLOR_BGRA */ +	buffer[y * resolx + x] = +		(c.b << (BLEU * 8)) | (c.v << (VERT * 8)) | (c.r << (ROUGE * 8)); +/*#else */ +/*    buffer[ y*resolx + x ] = (c.r<<16)|(c.v<<8)|c.b ; */ +/*#endif */ +/*#endif */  } -void setPixelRGB_ (Uint *buffer, Uint x, Color c) +void setPixelRGB_ (Uint * buffer, Uint x, Color c)  {  #ifdef _DEBUG -  if ( x >= resolx*c_resoly ) -    { -	  printf ("setPixel ERROR : hors du tableau... %i\n", x) ; -	  /* 	exit (1) ; */ -    } +	if (x >= resolx * c_resoly) { +		printf ("setPixel ERROR : hors du tableau... %i\n", x); +		/* exit (1) ; */ +	}  #endif -   -/* #ifdef USE_DGA */ -/*     buffer[ x ] = (c.b<<16)|(c.v<<8)|c.r ; */ -/* #else */ -/* #ifdef COLOR_BGRA */ -/*     buffer[ x ] = (c.b<<24)|(c.v<<16)|(c.r<<8) ; */ -/* #else */ -    buffer[ x ] = (c.r<<(ROUGE*8))|(c.v<<(VERT*8))|c.b<<(BLEU*8) ; -/* #endif */ -/* #endif */ + +/*#ifdef USE_DGA */ +/*    buffer[ x ] = (c.b<<16)|(c.v<<8)|c.r ; */ +/*#else */ +/*#ifdef COLOR_BGRA */ +/*    buffer[ x ] = (c.b<<24)|(c.v<<16)|(c.r<<8) ; */ +/*#else */ +	buffer[x] = (c.r << (ROUGE * 8)) | (c.v << (VERT * 8)) | c.b << (BLEU * 8); +/*#endif */ +/*#endif */  } -void getPixelRGB (Uint *buffer, Uint x, Uint y, Color *c) +void getPixelRGB (Uint * buffer, Uint x, Uint y, Color * c)  { -/*     register unsigned char *tmp8; */ -  unsigned int i; +/*    register unsigned char *tmp8; */ +	unsigned int i; +  #ifdef _DEBUG -    if (x + y * resolx >= resolx * c_resoly) -    { -	  printf ("getPixel ERROR : hors du tableau... %i, %i\n", x,y) ; -	  /* 	exit (1) ; */ -    } +	if (x + y * resolx >= resolx * c_resoly) { +		printf ("getPixel ERROR : hors du tableau... %i, %i\n", x, y); +		/* exit (1) ; */ +	}  #endif -	 -    /* -	#ifdef __BIG_ENDIAN__ -	    c->b = *(unsigned char *)(tmp8 = (unsigned char*)(buffer + (x + y*resolx))); -	    c->r = *(unsigned char *)(++tmp8); -	    c->v = *(unsigned char *)(++tmp8); -	    c->b = *(unsigned char *)(++tmp8); -	 -	#else -    */ -    /* ATTENTION AU PETIT INDIEN  */ -	i = *(buffer + (x + y*resolx)); -	c->b = (i>>(BLEU*8)) & 0xff; -	c->v = (i>>(VERT*8)) & 0xff; -	c->r = (i>>(ROUGE*8)) & 0xff; -    /* 	*c = (Color) buffer[x+y*WIDTH] ; */ -/* #endif */ + +	/* #ifdef __BIG_ENDIAN__ */ +	/* c->b = *(unsigned char *)(tmp8 = (unsigned char*)(buffer + (x + */ +	/* y*resolx))); */ +	/* c->r = *(unsigned char *)(++tmp8); */ +	/* c->v = *(unsigned char *)(++tmp8); */ +	/* c->b = *(unsigned char *)(++tmp8); */ + +	/* #else */ +	/* ATTENTION AU PETIT INDIEN  */ +	i = *(buffer + (x + y * resolx)); +	c->b = (i >> (BLEU * 8)) & 0xff; +	c->v = (i >> (VERT * 8)) & 0xff; +	c->r = (i >> (ROUGE * 8)) & 0xff; +	/* *c = (Color) buffer[x+y*WIDTH] ; */ +/*#endif */  } -void getPixelRGB_ (Uint *buffer, Uint x, Color *c) +void getPixelRGB_ (Uint * buffer, Uint x, Color * c)  { -    register unsigned char *tmp8; +	register unsigned char *tmp8;  #ifdef _DEBUG -    if ( x >= resolx * c_resoly ) -	  { -		printf ("getPixel ERROR : hors du tableau... %i\n", x) ; -		/* 	exit (1) ; */ -	  } +	if (x >= resolx * c_resoly) { +		printf ("getPixel ERROR : hors du tableau... %i\n", x); +		/* exit (1) ; */ +	}  #endif  #ifdef __BIG_ENDIAN__ -    c->b = *(unsigned char *)(tmp8 = (unsigned char*)(buffer + x)); -    c->r = *(unsigned char *)(++tmp8); -    c->v = *(unsigned char *)(++tmp8); -    c->b = *(unsigned char *)(++tmp8); +	c->b = *(unsigned char *) (tmp8 = (unsigned char *) (buffer + x)); +	c->r = *(unsigned char *) (++tmp8); +	c->v = *(unsigned char *) (++tmp8); +	c->b = *(unsigned char *) (++tmp8);  #else -    /* ATTENTION AU PETIT INDIEN  */ -    c->b = *(unsigned char *)(tmp8 = (unsigned char*)(buffer + x)); -    c->v = *(unsigned char *)(++tmp8); -    c->r = *(unsigned char *)(++tmp8); -    /* 	*c = (Color) buffer[x+y*WIDTH] ; */ +	/* ATTENTION AU PETIT INDIEN  */ +	c->b = *(unsigned char *) (tmp8 = (unsigned char *) (buffer + x)); +	c->v = *(unsigned char *) (++tmp8); +	c->r = *(unsigned char *) (++tmp8); +	/* *c = (Color) buffer[x+y*WIDTH] ; */  #endif  } -void c_zoom () { -  int myPos,myPos2; -  Color couleur; - -  unsigned int ax = (prevX-1)<<PERTEDEC, ay = (prevY-1)<<PERTEDEC; -   -  int bufsize = prevX * prevY * 2; -  int bufwidth = prevX; -   -  for (myPos=0; myPos<bufsize; myPos+=2) -	{ -	  Color col1,col2,col3,col4; -	  int c1,c2,c3,c4, px,py; -	  int pos; -	  int coeffs; -	   -	  int brutSmypos = brutS[myPos]; -	  myPos2 = myPos + 1; -	   -	  px = brutSmypos + (((brutD[myPos] - brutSmypos)*buffratio) >> BUFFPOINTNB); -	  brutSmypos = brutS[myPos2]; -	  py = brutSmypos + (((brutD[myPos2] - brutSmypos)*buffratio) >> BUFFPOINTNB); -	   -	  if ((py>=ay) || (px>=ax)) { -		pos = coeffs = 0; -	  } -	  else { -		pos = ((px >> PERTEDEC) + prevX * (py >> PERTEDEC)); -		/*  coef en modulo 15 */ -		coeffs = precalCoef [px & PERTEMASK][py & PERTEMASK]; -	  } -	   -	  getPixelRGB_(expix1,pos,&col1); -	  getPixelRGB_(expix1,pos+1,&col2); -	  getPixelRGB_(expix1,pos+bufwidth,&col3); -	  getPixelRGB_(expix1,pos+bufwidth+1,&col4); -	   -	  c1 = coeffs; -	  c2 = (c1 & 0x0000ff00) >> 8; -	  c3 = (c1 & 0x00ff0000) >> 16; -	  c4 = (c1 & 0xff000000) >> 24; -	  c1 = c1 & 0xff; -	   -	  couleur.r = col1.r * c1 -		+ col2.r * c2 -		+ col3.r * c3 -		+ col4.r * c4; -	  if (couleur.r>5) couleur.r -= 5; -	  couleur.r >>= 8 ; -	   -	  couleur.v = col1.v * c1 -		+ col2.v * c2 -		+ col3.v * c3 -		+ col4.v * c4; -	  if (couleur.v>5) couleur.v -= 5; -	  couleur.v >>= 8 ; -	   -	  couleur.b = col1.b * c1 -		+ col2.b * c2 -		+ col3.b * c3 -		+ col4.b * c4; -	  if (couleur.b>5) couleur.b -= 5; -	  couleur.b >>= 8 ; -			   -	  setPixelRGB_(expix2,myPos>>1,couleur); -	} -} +void +c_zoom () +{ +	int     myPos, myPos2; +	Color   couleur; +	unsigned int coefv, coefh; -#ifdef USE_ASM -static int use_asm = 1; -void setAsmUse (int useIt) { -	use_asm = useIt; -} -int getAsmUse () { -	return use_asm; +	unsigned int ax = (prevX - 1) << PERTEDEC, ay = (prevY - 1) << PERTEDEC; + +	int     bufsize = prevX * prevY * 2; +	int     bufwidth = prevX; + +	for (myPos = 0; myPos < bufsize; myPos += 2) { +		Color   col1, col2, col3, col4; +		int     c1, c2, c3, c4, px, py; +		int     pos; +		int     coeffs; + +		int     brutSmypos = brutS[myPos]; + +		myPos2 = myPos + 1; + +		px = +			brutSmypos + (((brutD[myPos] - brutSmypos) * buffratio) >> BUFFPOINTNB); +		brutSmypos = brutS[myPos2]; +		py = +			brutSmypos + +			(((brutD[myPos2] - brutSmypos) * buffratio) >> BUFFPOINTNB); + +		if ((py >= ay) || (px >= ax)) { +			pos = coeffs = 0; +		} +		else { +			pos = ((px >> PERTEDEC) + prevX * (py >> PERTEDEC)); +			/* coef en modulo 15 */ +			coeffs = precalCoef[px & PERTEMASK][py & PERTEMASK]; +		} + +		getPixelRGB_ (expix1, pos, &col1); +		getPixelRGB_ (expix1, pos + 1, &col2); +		getPixelRGB_ (expix1, pos + bufwidth, &col3); +		getPixelRGB_ (expix1, pos + bufwidth + 1, &col4); + +		c1 = coeffs; +		c2 = (c1 & 0x0000ff00) >> 8; +		c3 = (c1 & 0x00ff0000) >> 16; +		c4 = (c1 & 0xff000000) >> 24; +		c1 = c1 & 0xff; + +		couleur.r = col1.r * c1 + col2.r * c2 + col3.r * c3 + col4.r * c4; +		if (couleur.r > 5) +			couleur.r -= 5; +		couleur.r >>= 8; + +		couleur.v = col1.v * c1 + col2.v * c2 + col3.v * c3 + col4.v * c4; +		if (couleur.v > 5) +			couleur.v -= 5; +		couleur.v >>= 8; + +		couleur.b = col1.b * c1 + col2.b * c2 + col3.b * c3 + col4.b * c4; +		if (couleur.b > 5) +			couleur.b -= 5; +		couleur.b >>= 8; + +		setPixelRGB_ (expix2, myPos >> 1, couleur); +	}  } -#endif  /*===============================================================*/ -void zoomFilterFastRGB (Uint *pix1, -						Uint *pix2, -						ZoomFilterData *zf, -						Uint resx, Uint resy, -						int switchIncr, float switchMult) +void +zoomFilterFastRGB (Uint * pix1, +									 Uint * pix2, +									 ZoomFilterData * zf, +									 Uint resx, Uint resy, int switchIncr, float switchMult)  { -  register Uint x, y; -   -  static char reverse = 0 ; /* vitesse inversé..(zoom out) */ -  static unsigned char pertedec = 8 ; -  static char firstTime = 1; -   -  expix1 = pix1 ; -  expix2 = pix2 ; -   -  /** changement de taille **/ -  if ((prevX != resx) || (prevY != resy)) -    { -	  prevX = resx; -	  prevY = resy; -	   -	  if (brutS) free (freebrutS) ; -	  brutS = 0; -	  if (brutD) free (freebrutD) ; -	  brutD = 0; -	  if (brutT) free (freebrutT) ; -	  brutT = 0; -	   -	  middleX = resx / 2 ; -	  middleY = resy - 1; -	  firstTime = 1 ; -	  if (firedec) free (firedec); -	  firedec=0; -    } -   -  /** changement de config **/ -  if (zf) -	{ -	  reverse = zf->reverse ; -	  vitesse = zf->vitesse ; -	  if (reverse) -		vitesse = 256 - vitesse ; -	  pertedec = zf->pertedec ; -	  middleX = zf->middleX ; -	  middleY = zf->middleY ; -	  theMode = zf->mode ; -	  hPlaneEffect = zf->hPlaneEffect; -	  vPlaneEffect = zf->vPlaneEffect; -	  waveEffect = zf->waveEffect; -	  hypercosEffect = zf->hypercosEffect; -	  noisify = zf->noisify; +	register Uint x, y; +	unsigned int *temp = brutD; + +	static char reverse = 0;			/* vitesse inversé..(zoom out) */ +	static unsigned char pertedec = 8; +	static char firstTime = 1; + +	expix1 = pix1; +	expix2 = pix2; + +	/** changement de taille **/ +	if ((prevX != resx) || (prevY != resy)) { +		prevX = resx; +		prevY = resy; + +		if (brutS) +			free (freebrutS); +		brutS = 0; +		if (brutD) +			free (freebrutD); +		brutD = 0; +		if (brutT) +			free (freebrutT); +		brutT = 0; + +		middleX = resx / 2; +		middleY = resy - 1; +		firstTime = 1; +		if (firedec) +			free (firedec); +		firedec = 0;  	} -   -  /** generation d'un effet **/ -  if (firstTime || zf) -	{ -	   -	  /*  generation d'une table de sinus */ -	  if (firstTime) -		{ -		  unsigned short us ; -		  int yofs; -						 -		  firstTime = 0; -		  generatePrecalCoef (); -		   -		  freebrutS = (unsigned int *) malloc (resx*resy*2*sizeof(unsigned int)+128); -		  brutS = (guint32 *)((1+((unsigned int)(freebrutS))/128)*128); -		   -		  freebrutD = (unsigned int *) malloc (resx*resy*2*sizeof(unsigned int)+128); -		  brutD = (guint32 *)((1+((unsigned int)(freebrutD))/128)*128); - -		  freebrutT = (unsigned int *) malloc (resx*resy*2*sizeof(unsigned int)+128); -		  brutT = (guint32 *)((1+((unsigned int)(freebrutT))/128)*128); -		   -		  /** modif here by jeko : plus de multiplications **/ -		  { -			int yperte = 0; -			for (y=0, yofs=0; y<resy; y++,yofs+=resx) -			  { -				int xofs = yofs << 1; -				int xperte = 0; -				for (x = 0; x<resx; x++) -				  { -					brutS[xofs++] = xperte; -					brutS[xofs++] = yperte; -					xperte += sqrtperte; -				  } -				yperte += sqrtperte; -			  } -			buffratio = 0; -		  } -		   -		  for (us=0; us<0xffff; us++) + +	/** changement de config **/ +	if (zf) { +		reverse = zf->reverse; +		vitesse = zf->vitesse; +		if (reverse) +			vitesse = 256 - vitesse; +		pertedec = zf->pertedec; +		middleX = zf->middleX; +		middleY = zf->middleY; +		theMode = zf->mode; +		hPlaneEffect = zf->hPlaneEffect; +		vPlaneEffect = zf->vPlaneEffect; +		waveEffect = zf->waveEffect; +		hypercosEffect = zf->hypercosEffect; +		noisify = zf->noisify; +	} + +	/** generation d'un effet **/ +	if (firstTime || zf) { + +		/* generation d'une table de sinus */ +		if (firstTime) { +			unsigned short us; +			int     yofs; + +			firstTime = 0; +			generatePrecalCoef (); + +			freebrutS = +				(unsigned int *) malloc (resx * resy * 2 * sizeof (unsigned int) + + +																 128); +			brutS = (guint32 *) ((1 + ((unsigned int) (freebrutS)) / 128) * 128); + +			freebrutD = +				(unsigned int *) malloc (resx * resy * 2 * sizeof (unsigned int) + + +																 128); +			brutD = (guint32 *) ((1 + ((unsigned int) (freebrutD)) / 128) * 128); + +			freebrutT = +				(unsigned int *) malloc (resx * resy * 2 * sizeof (unsigned int) + + +																 128); +			brutT = (guint32 *) ((1 + ((unsigned int) (freebrutT)) / 128) * 128); + +			/** modif here by jeko : plus de multiplications **/  			{ -			  sintable [us] = (int)(1024.0f * sin (us*2*3.31415f/0xffff)) ; +				int     yperte = 0; + +				for (y = 0, yofs = 0; y < resy; y++, yofs += resx) { +					int     xofs = yofs << 1; +					int     xperte = 0; + +					for (x = 0; x < resx; x++) { +						brutS[xofs++] = xperte; +						brutS[xofs++] = yperte; +						xperte += sqrtperte; +					} +					yperte += sqrtperte; +				} +				buffratio = 0; +			} + +			for (us = 0; us < 0xffff; us++) { +				sintable[us] = +					(int) (1024 * +								 sin ((double) us * 360 / +											(sizeof (sintable) / sizeof (sintable[0]) - +											 1) * 3.141592 / 180) + .5); +				/* sintable [us] = (int)(1024.0f * sin (us*2*3.31415f/0xffff)) ; */ +			} + +			{ +				int     loopv; +				firedec = (int *) malloc (prevY * sizeof (int)); + +				for (loopv = prevY; loopv != 0;) { +					static int decc = 0; +					static int spdc = 0; +					static int accel = 0; + +					loopv--; +					firedec[loopv] = decc; +					decc += spdc / 10; +					spdc = spdc + RAND () % 3 - RAND () % 3; + +					if (decc > 4) +						spdc -= 1; +					if (decc < -4) +						spdc += 1; + +					if (spdc > 30) +						spdc = spdc - RAND () % 3 + accel / 10; +					if (spdc < -30) +						spdc = spdc + RAND () % 3 + accel / 10; + +					if (decc > 8 && spdc > 1) +						spdc -= RAND () % 3 - 2; + +					if (decc < -8 && spdc < -1) +						spdc += RAND () % 3 + 2; + +					if (decc > 8 || decc < -8) +						decc = decc * 8 / 9; + +					accel += RAND () % 2 - RAND () % 2; +					if (accel > 20) +						accel -= 2; +					if (accel < -20) +						accel += 2; +				}  			} -		   -		  { -			int loopv ; -			firedec = (int *) malloc (prevY * sizeof(int)) ; -			for (loopv = prevY ; loopv != 0 ;) -			  { -				static int decc = 0 ; -				static int spdc = 0 ; -				static int accel = 0 ; -				loopv -- ; -				firedec [loopv] = decc ; -				decc += spdc / 10 ; -				spdc = spdc + RAND () % 3 - RAND () % 3 ; -				 -				if (decc > 4) -				  spdc -= 1 ; -				if (decc < -4) -				  spdc += 1 ; -				 -				if (spdc > 30) -				  spdc = spdc - RAND () % 3 + accel / 10 ; -				if (spdc < -30) -				  spdc = spdc + RAND () % 3 + accel / 10 ; -				 -				if (decc > 8 && spdc > 1 ) -				  spdc -= RAND () % 3 - 2 ; -				 -				if (decc < -8 && spdc < -1 ) -				  spdc += RAND () % 3 + 2 ; -				 -				if (decc > 8 || decc < -8) -				  decc = decc * 8 / 9 ; -				 -				accel += RAND () % 2 - RAND () % 2 ; -				if (accel > 20) -				  accel -= 2 ; -				if (accel < -20) -				  accel += 2 ; -			  } -		  } -		} -	   -	  /*  generation du buffer de trans */ -	  { -		 -		/* sauvegarde de l'etat actuel dans la nouvelle source */ -		y=prevX*prevY*2; -		for (x=0;x<y;x+=2) { -		  int brutSmypos = brutS[x]; -		  int x2 = x + 1; - -		  brutS[x] = brutSmypos + (((brutD[x] - brutSmypos)*buffratio) >> BUFFPOINTNB); -		  brutSmypos = brutS[x2]; -		  brutS[x2] = brutSmypos + (((brutD[x2] - brutSmypos)*buffratio) >> BUFFPOINTNB);  		} -    -		/* creation de la nouvelle destination */ -		for (y = 0 ; y < prevY ; y++) -		  { -			for (x = 0; x < prevX ; x++) -			  { -				int px,py; -								/* unsigned char coefv,coefh; */ -				 -				calculatePXandPY (x,y,&px, &py) ; - -				if ((px == x << 4) && (py == y << 4)) { -				  if (x > middleX) -					py += 2; -				  else -					py -= 2; -				  if (y > middleY) -					px += 2 ; -				  else -					px -= 2; + +/*        buffratio = 0; */ + +		/* generation du buffer de trans */ +		{ +			int     yprevx = 0; +			unsigned int ax = (prevX - 1) << PERTEDEC, ay = (prevY - 1) << PERTEDEC; + +			/* sauvegarde de l'etat actuel dans la nouvelle source */ +			y = prevX * prevY * 2; +			for (x = 0; x < y; x += 2) { +				int     brutSmypos = brutS[x]; +				int     x2 = x + 1; + +				brutS[x] = +					brutSmypos + (((brutD[x] - brutSmypos) * buffratio) >> BUFFPOINTNB); +				brutSmypos = brutS[x2]; +				brutS[x2] = +					brutSmypos + +					(((brutD[x2] - brutSmypos) * buffratio) >> BUFFPOINTNB); +			} + +			/* creation de la nouvelle destination */ +			for (y = 0; y < prevY; y++) { +				for (x = 0; x < prevX; x++) { +					int     px, py; + +					/* unsigned char coefv,coefh; */ + +					calculatePXandPY (x, y, &px, &py); + +/*				if (py>ay<<16) +				  py = iRAND (32); +				if (px>ax<<16) +				  px = iRAND (32); +*/ + +					if ((px == x << 4) && (py == y << 4)) { +						if (x > middleX) +							py += 2; +						else +							py -= 2; +						if (y > middleY) +							px += 2; +						else +							px -= 2; +					} + +					brutD[(y * prevX + x) << 1] = px; +					brutD[((y * prevX + x) << 1) + 1] = py;  				} -				 -				brutD[(y*prevX+x)<<1] = px; -				brutD[((y*prevX+x)<<1)+1] = py; -			  } -		  } - -		buffratio = 0; -	  } +			} + +			buffratio = 0; +		}  	} -   -  if (switchIncr != 0) -	{ -	  buffratio += switchIncr; -	  if (buffratio > BUFFPOINTMASK) -		buffratio = BUFFPOINTMASK; + +	if (switchIncr != 0) { +		buffratio += switchIncr; +		if (buffratio > BUFFPOINTMASK) +			buffratio = BUFFPOINTMASK;  	} -   -  if (switchMult != 1.0f) { -	buffratio = (int)((float)BUFFPOINTMASK * (1.0f - switchMult) + (float)buffratio * switchMult); -  } - -  zoom_width = prevX ; -  mmx_zoom_size = prevX * prevY ; -   + +	if (switchMult != 1.0f) { +		buffratio = +			(int) ((float) BUFFPOINTMASK * (1.0f - switchMult) + +						 (float) buffratio * switchMult); +	} + +	zoom_width = prevX; +	mmx_zoom_size = prevX * prevY; +  #ifdef USE_ASM  #ifdef MMX -/*   mmx_zoom () ; */ +/*  mmx_zoom () ; */  	if (use_asm) {  		zoom_filter_mmx (prevX, prevY, expix1, expix2, brutS, brutD, buffratio, precalCoef);  	} @@ -646,38 +694,31 @@ void zoomFilterFastRGB (Uint *pix1,  		c_zoom (prevX, prevY);  	}  #endif -   +  #ifdef POWERPC -  zoom_width = prevX; -  if (useAltivec) -	{ -/* 	  ppcsize4 = ((unsigned int)(prevX*prevY))/4; */ -/* 	  ppc_zoom_altivec(); */ -	  ppc_zoom(expix1,expix2,prevX,prevY, brutS, brutD, buffratio, precalCoef);  /* FIXME Altivec disabled since dynamic zooms */ +	if (use_asm) { +		ppc_zoom (expix1, expix2, prevX, prevY, brutS, brutD, buffratio);  	} -  else -	{ -	  ppc_zoom(expix1,expix2,prevX,prevY, brutS, brutD, buffratio, precalCoef); +	else { +		c_zoom (prevX, prevY);  	}  #endif  #else -  c_zoom (prevX, prevY); +	c_zoom (prevX, prevY);  #endif  } - -void pointFilter(Uint *pix1, Color c, -		 float t1, float t2, float t3, float t4, -		 Uint cycle) +void pointFilter (Uint * pix1, Color c, +						 float t1, float t2, float t3, float t4, Uint cycle)  { -    Uint x = (Uint)((int)middleX + (int)(t1*cos((float)cycle/t3))); -    Uint y = (Uint)((int)middleY + (int)(t2*sin((float)cycle/t4))); -    if ((x>1) && (y>1) && (x<resolx-2) && (y<c_resoly-2)) -    { -	setPixelRGB(pix1, x+1, y, c); -	setPixelRGB(pix1, x, y+1, c); -	setPixelRGB(pix1, x+1, y+1, WHITE); -	setPixelRGB(pix1, x+2, y+1, c); -	setPixelRGB(pix1, x+1, y+2, c); -    } +	Uint    x = (Uint) ((int) middleX + (int) (t1 * cos ((float) cycle / t3))); +	Uint    y = (Uint) ((int) middleY + (int) (t2 * sin ((float) cycle / t4))); + +	if ((x > 1) && (y > 1) && (x < resolx - 2) && (y < c_resoly - 2)) { +		setPixelRGB (pix1, x + 1, y, c); +		setPixelRGB (pix1, x, y + 1, c); +		setPixelRGB (pix1, x + 1, y + 1, WHITE); +		setPixelRGB (pix1, x + 2, y + 1, c); +		setPixelRGB (pix1, x + 1, y + 2, c); +	}  } diff --git a/src/post/goom/filters.h b/src/post/goom/filters.h index 94e9a91aa..e306e6032 100644 --- a/src/post/goom/filters.h +++ b/src/post/goom/filters.h @@ -8,23 +8,24 @@  typedef struct  { -  int vitesse ; /* 128 = vitesse nule... -				 * 256 = en arriere hyper vite.. -				 * 0 = en avant hype vite. */ -  unsigned char pertedec ; -  unsigned char sqrtperte ; -  int middleX,middleY ; /* milieu de l'effet */ -  char reverse ; /* inverse la vitesse */ -  char mode ; /* type d'effet ŕ appliquer (cf les #define) */ -  /** @since June 2001 */ -  int hPlaneEffect ; /* deviation horitontale */ -  int vPlaneEffect ; /* deviation verticale */ -  /** @since April 2002 */ -  int waveEffect; /* applique une "surcouche" de wave effect */ -  int hypercosEffect; /* applique une "surcouche de hypercos effect */ +	int     vitesse;							/* 128 = vitesse nule... * * 256 = en arriere  +																 * hyper vite.. * * 0 = en avant hype vite. */ +	unsigned char pertedec; +	unsigned char sqrtperte; +	int     middleX, middleY;			/* milieu de l'effet */ +	char    reverse;							/* inverse la vitesse */ +	char    mode;									/* type d'effet ŕ appliquer (cf les #define)  +																 * * * * * */ /** @since June 2001 */ +	int     hPlaneEffect;					/* deviation horitontale */ +	int     vPlaneEffect;					/* deviation verticale */ +	/** @since April 2002 */ +	int     waveEffect;						/* applique une "surcouche" de wave effect */ +	int     hypercosEffect;				/* applique une "surcouche de hypercos effect  +																 */ -  char noisify ; /* ajoute un bruit a la transformation */ -} ZoomFilterData ; +	char    noisify;							/* ajoute un bruit a la transformation */ +} +ZoomFilterData;  #define NORMAL_MODE 0 @@ -36,9 +37,8 @@ typedef struct  #define HYPERCOS1_MODE 6  #define HYPERCOS2_MODE 7 -void pointFilter(guint32 *pix1, Color c, -				 float t1, float t2, float t3, float t4, -				 guint32 cycle); +void    pointFilter (guint32 * pix1, Color c, +										 float t1, float t2, float t3, float t4, guint32 cycle);  /* filtre de zoom :   * le contenu de pix1 est copie dans pix2. @@ -46,11 +46,12 @@ void pointFilter(guint32 *pix1, Color c,   * resx,resy : taille des buffers.   */ -void zoomFilterFastRGB (guint32 *pix1, -						guint32 *pix2, -						ZoomFilterData *zf, -						guint32 resx, guint32 resy, -						int switchIncr, float switchMult); +void    zoomFilterFastRGB (guint32 * pix1, +													 guint32 * pix2, +													 ZoomFilterData * zf, +													 guint32 resx, guint32 resy, + +													 int switchIncr, float switchMult);  /* filtre sin : @@ -73,8 +74,5 @@ void sinFilter(Uint *pix1,Uint *pix2,  #define SIN_MUL 1  #define SIN_ADD 2 -/* #ifdef USE_ASM */ -/* void setAsmUse (int useIt); */ -/* #endif */  #endif diff --git a/src/post/goom/goom_config.h b/src/post/goom/goom_config.h index 948bf8eb0..5d2a1a91f 100644 --- a/src/post/goom/goom_config.h +++ b/src/post/goom/goom_config.h @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +  #include <inttypes.h>  /* #define VERSION "1.9dev5" */ @@ -25,8 +29,14 @@  /* #define STANDALONE */  /*  for pc users with mmx processors. */ -/* #define MMX */ -/* #define POWERPC */ +#ifdef ARCH_X86 +#define MMX +#endif + +#ifdef ARCH_PPC +#define POWERPC +#endif +  /* #define VERBOSE */  #ifndef guint32 diff --git a/src/post/goom/goom_core.c b/src/post/goom/goom_core.c index 81e1ea6f3..9e1fd33ce 100644 --- a/src/post/goom/goom_core.c +++ b/src/post/goom/goom_core.c @@ -6,7 +6,7 @@  #include "lines.h"  #include "ifs.h" -/* #define VERBOSE */ +/*#define VERBOSE */  #ifdef VERBOSE  #include <stdio.h> @@ -16,528 +16,569 @@  #define TIME_BTW_CHG 300 +int use_asm = 0; +  /**-----------------------------------------------------**   **  SHARED DATA                                        **   **-----------------------------------------------------**/ -static guint32 *pixel ; -static guint32 *back ; -static guint32 *p1,*p2,*tmp; +static guint32 *pixel; +static guint32 *back; +static guint32 *p1, *p2, *tmp;  static guint32 cycle; -guint32 resolx, resoly, buffsize, -  c_black_height=0, /* hauteur des bande noires en bas et en haut */ -  c_offset=0, c_resoly=0; /* avec prise en compte de ca */ +guint32 resolx, resoly, buffsize, c_black_height = 0,	/* hauteur des bande * +																											 * * noires en bas et * +																											 * * en * haut */ +        c_offset = 0, c_resoly = 0;	/* avec prise en compte de ca */ -/*  effet de ligne.. */ +/* effet de ligne.. */  static GMLine *gmline1 = NULL;  static GMLine *gmline2 = NULL; -void choose_a_goom_line (float *param1, float *param2, int *couleur, -						 int *mode); +void    choose_a_goom_line (float *param1, float *param2, int *couleur, +														int *mode); + +/* la police */ +int  ***font_chars; +int    *font_width; +int    *font_height; + +void    goom_draw_text (guint32 * buf, +												int x, int y, +												const char *str, float chspace, int center); + +void update_message (char *message); + -void goom_init (guint32 resx, guint32 resy, int cinemascope) +void +goom_init (guint32 resx, guint32 resy, int cinemascope)  {  #ifdef VERBOSE -  printf ("GOOM: init (%d, %d);\n", resx,resy); +	printf ("GOOM: init (%d, %d);\n", resx, resy);  #endif  	if (cinemascope) -	  c_black_height = resy/5; +		c_black_height = resy / 5;  	else -	  c_black_height = 0; +		c_black_height = 0; -    resolx = resx; -    resoly = resy; -    buffsize = resx * resy; +	resolx = resx; +	resoly = resy; +	buffsize = resx * resy;  	c_offset = c_black_height * resx;  	c_resoly = resy - c_black_height * 2; -    pixel = (guint32 *) malloc (buffsize * sizeof(guint32) + 128); -    back = (guint32 *) malloc (buffsize * sizeof(guint32) + 128); -    RAND_INIT ((guint32)pixel) ; -    cycle = 0 ; - -    p1 = (guint32 *)((1+((unsigned int)(pixel))/128)*128); -    p2 = (guint32 *)((1+((unsigned int)(back))/128)*128); - -    init_ifs (resx,c_resoly); -	gmline1 = goom_lines_init (resx,c_resoly, -							  GML_HLINE, c_resoly, GML_BLACK, -							  GML_CIRCLE, 0.4f*(float)c_resoly, GML_VERT); -	gmline2 = goom_lines_init (resx,c_resoly, -							  GML_HLINE, 0, GML_BLACK, -							  GML_CIRCLE, 0.2f*(float)c_resoly, GML_RED); +	pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128); +	back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128); +	RAND_INIT ((guint32) pixel); +	cycle = 0; + +	p1 = (guint32 *) ((1 + ((unsigned int) (pixel)) / 128) * 128); +	p2 = (guint32 *) ((1 + ((unsigned int) (back)) / 128) * 128); + +	init_ifs (resx, c_resoly); +	gmline1 = goom_lines_init (resx, c_resoly, +														 GML_HLINE, c_resoly, GML_BLACK, +														 GML_CIRCLE, 0.4f * (float) c_resoly, GML_VERT); +	gmline2 = goom_lines_init (resx, c_resoly, +														 GML_HLINE, 0, GML_BLACK, +														 GML_CIRCLE, 0.2f * (float) c_resoly, GML_RED); + +	font_height = NULL; +	font_width = NULL; +	font_chars = NULL;  } -void goom_set_resolution (guint32 resx, guint32 resy, int cinemascope) +void +goom_set_resolution (guint32 resx, guint32 resy, int cinemascope)  { -    free (pixel); -    free (back); +	free (pixel); +	free (back);  	if (cinemascope) -	  c_black_height = resy/8; +		c_black_height = resy / 8;  	else -	  c_black_height = 0; +		c_black_height = 0;  	c_offset = c_black_height * resx;  	c_resoly = resy - c_black_height * 2; -    resolx = resx; -    resoly = resy; -    buffsize = resx * resy; +	resolx = resx; +	resoly = resy; +	buffsize = resx * resy; -    pixel = (guint32 *) malloc (buffsize * sizeof(guint32) + 128); -    bzero(pixel,buffsize * sizeof(guint32) + 128); -    back = (guint32 *) malloc (buffsize * sizeof(guint32) + 128); -    bzero(back,buffsize * sizeof(guint32) + 128); -    p1 = (guint32 *)((1+((unsigned int)(pixel))/128)*128); -    p2 = (guint32 *)((1+((unsigned int)(back))/128)*128); +	pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128); +	bzero (pixel, buffsize * sizeof (guint32) + 128); +	back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128); +	bzero (back, buffsize * sizeof (guint32) + 128); +	p1 = (guint32 *) ((1 + ((unsigned int) (pixel)) / 128) * 128); +	p2 = (guint32 *) ((1 + ((unsigned int) (back)) / 128) * 128); -    init_ifs (resx,c_resoly); -	goom_lines_set_res (gmline1,resx,c_resoly); -	goom_lines_set_res (gmline2,resx,c_resoly); +	init_ifs (resx, c_resoly); +	goom_lines_set_res (gmline1, resx, c_resoly); +	goom_lines_set_res (gmline2, resx, c_resoly);  } -guint32 * goom_update (gint16 data [2][512],int forceMode) +guint32 * +goom_update (gint16 data[2][512], +						 int forceMode, +						 float fps, +						 char *songTitle, +						 char *message)  { -    static int	lockvar = 0 ;  /* pour empecher de nouveaux changements */ -    static int 	goomvar = 0 ;  /* boucle des gooms */ -    static int 	totalgoom = 0 ;  /* nombre de gooms par seconds */ -    static int 	agoom = 0 ;  /* un goom a eu lieu..	 */ -    static int 	loopvar = 0 ;  /* mouvement des points */ -    static int 	speedvar = 0 ;  /* vitesse des particules */ - -    /*  duree de la transition entre afficher les lignes ou pas */ +	static int lockvar = 0;				/* pour empecher de nouveaux changements */ +	static int goomvar = 0;				/* boucle des gooms */ +	static int totalgoom = 0;			/* nombre de gooms par seconds */ +	static int agoom = 0;					/* un goom a eu lieu..    */    +	static int abiggoom = 0;					/* un big goom a eu lieu..       */ +	static int loopvar = 0;				/* mouvement des points */ +	static int speedvar = 0;			/* vitesse des particules */ + +	/* duree de la transition entre afficher les lignes ou pas */  #define DRAWLINES 70 -    static int	lineMode = DRAWLINES ; /*  l'effet lineaire a dessiner */ -	static int  nombreCDDC = 0; /*  nombre de Cycle Depuis Dernier Changement */ -    guint32 * return_val; -    guint32 pointWidth; -    guint32 pointHeight; -    int 	incvar ;  /* volume du son */ -    int 	accelvar ; /*  acceleration des particules */ -    int 	i ; -    float 	largfactor ; /*  elargissement de l'intervalle d'évolution des points */ - -	static int ifs_incr = 1;  /* dessiner l'ifs (0 = non: > = increment) */ -	static int decay_ifs = 0;  /* disparition de l'ifs */ -	static int recay_ifs = 0;  /* dédisparition de l'ifs */ +	static int lineMode = DRAWLINES;	/* l'effet lineaire a dessiner */ +	static int nombreCDDC = 0;		/* nombre de Cycle Depuis Dernier Changement */ +	guint32 *return_val; +	guint32 pointWidth; +	guint32 pointHeight; +	int     incvar;								/* volume du son */ +	static int accelvar=0;							/* acceleration des particules */ +	int     i; +	float   largfactor;						/* elargissement de l'intervalle d'évolution */ + +	/* des points */ + +	static int ifs_incr = 1;			/* dessiner l'ifs (0 = non: > = increment) */ +	static int decay_ifs = 0;			/* disparition de l'ifs */ +	static int recay_ifs = 0;			/* dédisparition de l'ifs */  #define SWITCHMULT (19.0f/20.0f)  #define SWITCHINCR 0xff  	static float switchMult = 1.0f;  	static int switchIncr = SWITCHINCR; -	/*static int lastgoom = 0;*/ - -    static char	goomlimit = 2 ; /*  sensibilité du goom */ -    static 	ZoomFilterData zfd = -    { -	127,	8,	16, -	1,	1,	0,	NORMAL_MODE, -	0,	0,	0, 0, 0}; - -    ZoomFilterData *pzfd; - -    /* test if the config has changed, update it if so */ -    pointWidth = (resolx * 2) / 5; -    pointHeight = ((c_resoly) * 2) / 5; - -    /* ! etude du signal ... */ -    incvar = 0 ; -    for (i=0;i<512;i++) -    { -        if (incvar < data[0][i]) incvar = data[0][i] ; -    } - -    accelvar = incvar / 5000 ; -    if (speedvar>5) -    { -        accelvar-- ; -        if (speedvar>20) accelvar -- ; -        if (speedvar>40) speedvar = 40 ; -    } -    accelvar -- ; -    speedvar += accelvar ; -	 -    if (speedvar<0) speedvar=0; -    if (speedvar>40) speedvar = 40 ; +	static int lastgoom = 0; + +	static char goomlimit = 2;		/* sensibilité du goom */ +	static ZoomFilterData zfd = { +		127, 8, 16, +		1, 1, 0, NORMAL_MODE, +		0, 0, 0, 0, 0 +	}; + +	ZoomFilterData *pzfd; + +	/* test if the config has changed, update it if so */ +	pointWidth = (resolx * 2) / 5; +	pointHeight = ((c_resoly) * 2) / 5; + +	/* ! etude du signal ... */ +	incvar = 0; +	for (i = 0; i < 512; i++) { +		if (incvar < data[0][i]) +			incvar = data[0][i]; +	} + +	i = accelvar; +	accelvar = incvar / 1000; + +	if (speedvar > 5) { +		accelvar--; +		if (speedvar > 20) +			accelvar--; +		if (speedvar > 40) +			speedvar = 40; +	} +	accelvar--; + +	i = accelvar - i; +	if (i<0) i=-i; + +	speedvar += i/2; +	speedvar = speedvar * 15/16; + +	if (speedvar < 0) +		speedvar = 0; +	if (speedvar > 40) +		speedvar = 40; + -	  	/* ! calcul du deplacement des petits points ... */ -	 -	largfactor = ((float)speedvar / 40.0f + (float)incvar / 50000.0f) / 1.5f ; -	if (largfactor>1.5f) largfactor = 1.5f ; -	if ((ifs_incr==1) && (iRAND(200)==0) && (decay_ifs<-300) && (agoom)) { -	  decay_ifs = 200; +	largfactor = ((float) speedvar / 40.0f + (float) incvar / 50000.0f) / 1.5f; +	if (largfactor > 1.5f) +		largfactor = 1.5f; + +	if ((ifs_incr == 1) && (iRAND (300) == 0) && (decay_ifs < -300) && (agoom)) { +		decay_ifs = 200;  	} -	decay_ifs --; +	decay_ifs--;  	if (decay_ifs > 0) -	  ifs_incr += 2; +		ifs_incr += 2;  	if (decay_ifs == 0) -	  ifs_incr = 0; +		ifs_incr = 0; -	if ((ifs_incr==0) && (iRAND(200)==0) && (agoom) && (decay_ifs < -100)) { -	  recay_ifs = 5; -	  ifs_incr = 11; +	if ((ifs_incr == 0) && (iRAND (300) == 0) && (agoom) && (decay_ifs < -100)) { +		recay_ifs = 5; +		ifs_incr = 11;  	}  	if (recay_ifs) { -	  ifs_incr -= 2; -	  recay_ifs --; -	  if (recay_ifs == 0) -		ifs_incr = 1; +		ifs_incr -= 2; +		recay_ifs--; +		if (recay_ifs == 0) +			ifs_incr = 1;  	}  	if (ifs_incr > 0) -	  ifs_update (p1+c_offset, p2+c_offset, resolx, c_resoly, ifs_incr); +		ifs_update (p1 + c_offset, p2 + c_offset, resolx, c_resoly, ifs_incr); -/* 	(p1+c_offset)[resolx/2 + c_resoly/2 * resolx] = 0; */ +/*      (p1+c_offset)[resolx/2 + c_resoly/2 * resolx] = 0; */  	if (ifs_incr != 1) { -	  for (i = 1 ; i*15 <= speedvar + 15; i ++) { -		loopvar += speedvar + 1 ; -		 -		pointFilter(p1+c_offset, -					YELLOW, -					((pointWidth - 6.0f) * largfactor + 5.0f), -					((pointHeight - 6.0f) * largfactor + 5.0f), -					i * 152.0f, 128.0f, -					loopvar + i*2032); -		pointFilter(p1+c_offset, ORANGE, -					((pointWidth / 2) * largfactor) / i + 10.0f * i, -					((pointHeight / 2) * largfactor) / i + 10.0f * i, -					96.0f, i * 80.0f, loopvar / i); -		pointFilter(p1+c_offset, VIOLET, -					((pointHeight / 3 + 5.0f) * largfactor) / i + 10.0f * i, -					((pointHeight / 3 + 5.0f) * largfactor) / i + 10.0f * i, -					i + 122.0f, 134.0f, loopvar / i); -		pointFilter(p1+c_offset, BLACK, -					((pointHeight / 3) * largfactor + 20.0f), -					((pointHeight / 3) * largfactor + 20.0f), -					58.0f, i * 66.0f, loopvar / i); -		pointFilter(p1+c_offset, WHITE, -					(pointHeight * largfactor + 10.0f * i) / i, -					(pointHeight * largfactor + 10.0f * i) / i, -					66.0f, 74.0f, loopvar + i * 500); -	  } +		for (i = 1; i * 15 <= speedvar + 15; i++) { +			loopvar += speedvar*2 + 1; + +			pointFilter (p1 + c_offset, +									 YELLOW, +									 ((pointWidth - 6.0f) * largfactor + 5.0f), +									 ((pointHeight - 6.0f) * largfactor + 5.0f), +									 i * 152.0f, 128.0f, loopvar + i * 2032); +			pointFilter (p1 + c_offset, ORANGE, +									 ((pointWidth / 2) * largfactor) / i + 10.0f * i, +									 ((pointHeight / 2) * largfactor) / i + 10.0f * i, +									 96.0f, i * 80.0f, loopvar / i); +			pointFilter (p1 + c_offset, VIOLET, +									 ((pointHeight / 3 + 5.0f) * largfactor) / i + 10.0f * i, +									 ((pointHeight / 3 + 5.0f) * largfactor) / i + 10.0f * i, +									 i + 122.0f, 134.0f, loopvar / i); +			pointFilter (p1 + c_offset, BLACK, +									 ((pointHeight / 3) * largfactor + 20.0f), +									 ((pointHeight / 3) * largfactor + 20.0f), +									 58.0f, i * 66.0f, loopvar / i); +			pointFilter (p1 + c_offset, WHITE, +									 (pointHeight * largfactor + 10.0f * i) / i, +									 (pointHeight * largfactor + 10.0f * i) / i, +									 66.0f, 74.0f, loopvar + i * 500); +		}  	} -    /*  par défaut pas de changement de zoom */ -	pzfd = NULL ; +	/* par défaut pas de changement de zoom */ +	pzfd = NULL; -	/* +	/*   	 * Test forceMode  	 */  #ifdef VERBOSE  	if (forceMode != 0) { -		printf ("forcemode = %d\n",forceMode); +		printf ("forcemode = %d\n", forceMode);  	}  #endif -	 -    /* -     * diminuer de 1 le temps de lockage -     * note pour ceux qui n'ont pas suivis : le lockvar permet d'empecher un -     * changement d'etat du plugins juste apres un autre changement d'etat. oki ? -     */ -    if (--lockvar < 0) lockvar = 0 ; - -    /*  temps du goom */ -    if (--agoom < 0) agoom = 0 ; -     -    /*  on verifie qu'il ne se pas un truc interressant avec le son. */ -    if ((accelvar>goomlimit) || (accelvar<-goomlimit) || (forceMode>0) -		|| (nombreCDDC > TIME_BTW_CHG)) { - -/* 	  if (nombreCDDC > 300) { */ -/* 	  } */ - -	  /*  UN GOOM !!! YAHOO ! */ -	  totalgoom ++ ; -	  agoom = 20 ; /*  mais pdt 20 cycles, il n'y en aura plus. */ -	  /* 	  lineMode = (lineMode + 1)%40; // Tous les 10 gooms on change de mode lineaire */ -	   -/* 	  		if (iRAND(12) == 0) */ -/* 	  		  zfd.vitesse=STOP_SPEED-1; */ -/* 	  		if (iRAND(13) == 0) */ -/* 	  		  zfd.vitesse=STOP_SPEED+1; */ -	   -/* 	   changement eventuel de mode */ - -	  switch (iRAND(28)) -		{ + + +	/* diminuer de 1 le temps de lockage */ +	/* note pour ceux qui n'ont pas suivis : le lockvar permet d'empecher un */ +	/* changement d'etat du plugins juste apres un autre changement d'etat. oki  */ +	/*  */ +	/*  */ +	/*  */ +	/* ? */ +	if (--lockvar < 0) +		lockvar = 0; + +	/* temps du goom */ +	if (--agoom < 0) +		agoom = 0; + +	/* temps du goom */ +	if (--abiggoom < 0) +		abiggoom = 0; + +	if ((!abiggoom) && (speedvar > 4) && (goomlimit > 4) && +			((accelvar > goomlimit*9/8+7)||(accelvar < -goomlimit*9/8-7))) { +		int size,i; +		static int couleur = +			 (0xc0<<(ROUGE*8)) +			|(0xc0<<(VERT*8)) +			|(0xf0<<(BLEU*8)) +			|(0xf0<<(ALPHA*8)); +		abiggoom = 100; +		size = resolx*c_resoly; +		for (i=0;i<size;i++) +			(p1+c_offset)[i] = (~(p1+c_offset)[i]) | couleur; +	} + +	/* on verifie qu'il ne se pas un truc interressant avec le son. */ +	if ((accelvar > goomlimit) || (accelvar < -goomlimit) || (forceMode > 0) +			|| (nombreCDDC > TIME_BTW_CHG)) { + +/*        if (nombreCDDC > 300) { */ +/*        } */ + +		/* UN GOOM !!! YAHOO ! */ +		totalgoom++; +		agoom = 20;									/* mais pdt 20 cycles, il n'y en aura plus. */ +		/* lineMode = (lineMode + 1)%40; */ /* Tous les 10 gooms on change de mode */ +		/* lineaire */ + +		/* if (iRAND(12) == 0) */ +		/* zfd.vitesse=STOP_SPEED-1; */ +		/* if (iRAND(13) == 0) */ +		/* zfd.vitesse=STOP_SPEED+1; */ + +		/* changement eventuel de mode */ +		switch (iRAND (28)) {  		case 0:  		case 10: -		  zfd.hypercosEffect=iRAND(2); +			zfd.hypercosEffect = iRAND (2);  		case 13:  		case 20:  		case 21: -		  zfd.mode=WAVE_MODE; -		  zfd.reverse=0; -		  zfd.waveEffect= (iRAND(3)==0); -		  if (iRAND(2)) -			  zfd.vitesse = (zfd.vitesse + 127) >> 1; -		  break; -        case 1: +			zfd.mode = WAVE_MODE; +			zfd.reverse = 0; +			zfd.waveEffect = (iRAND (3) == 0); +			if (iRAND (2)) +				zfd.vitesse = (zfd.vitesse + 127) >> 1; +			break; +		case 1:  		case 11: -		  zfd.mode=CRYSTAL_BALL_MODE; -		  zfd.waveEffect=0; -		  zfd.hypercosEffect=0; -		  break; -        case 2: +			zfd.mode = CRYSTAL_BALL_MODE; +			zfd.waveEffect = 0; +			zfd.hypercosEffect = 0; +			break; +		case 2:  		case 12: -		  zfd.mode=AMULETTE_MODE; -		  zfd.waveEffect=(iRAND(3)==0); -		  zfd.hypercosEffect=(iRAND(3)==0); -		  break; -        case 3: -		  zfd.mode = WATER_MODE ; -		  zfd.waveEffect=0; -		  zfd.hypercosEffect=0; -		  break; -        case 4: +			zfd.mode = AMULETTE_MODE; +			zfd.waveEffect = (iRAND (3) == 0); +			zfd.hypercosEffect = (iRAND (3) == 0); +			break; +		case 3: +			zfd.mode = WATER_MODE; +			zfd.waveEffect = 0; +			zfd.hypercosEffect = 0; +			break; +		case 4:  		case 14: -		  zfd.mode=SCRUNCH_MODE; -		  zfd.waveEffect=0; -		  zfd.hypercosEffect=0; -		  break; +			zfd.mode = SCRUNCH_MODE; +			zfd.waveEffect = 0; +			zfd.hypercosEffect = 0; +			break;  		case 5:  		case 15: -		  zfd.mode=HYPERCOS1_MODE; -		  zfd.waveEffect=0; -		  zfd.hypercosEffect=(iRAND(3)==0); -		  break; +			zfd.mode = HYPERCOS1_MODE; +			zfd.waveEffect = 0; +			zfd.hypercosEffect = (iRAND (3) == 0); +			break;  		case 6:  		case 16: -		  zfd.mode=HYPERCOS2_MODE; -		  zfd.waveEffect=0; -		  zfd.hypercosEffect=0; -		  break; -        case 7: +			zfd.mode = HYPERCOS2_MODE; +			zfd.waveEffect = 0; +			zfd.hypercosEffect = 0; +			break; +		case 7:  		case 17: -		  zfd.mode=CRYSTAL_BALL_MODE; -		  zfd.waveEffect=(iRAND(4)==0); -		  zfd.hypercosEffect=iRAND(2); -		  break; +			zfd.mode = CRYSTAL_BALL_MODE; +			zfd.waveEffect = (iRAND (4) == 0); +			zfd.hypercosEffect = iRAND (2); +			break;  		case 8:  		case 18:  		case 19: -		  zfd.mode=SCRUNCH_MODE; -		  zfd.waveEffect=1; -		  zfd.hypercosEffect=1; -		  break; -        default: -		  zfd.mode=NORMAL_MODE; -		  zfd.waveEffect=0; -		  zfd.hypercosEffect=0; -        } -    } - -    /*  tout ceci ne sera fait qu'en cas de non-blocage */ -    if (lockvar == 0) -    { -      /* -       *   reperage de goom (acceleration forte de l'acceleration du volume) -       *  -> coup de boost de la vitesse si besoin.. -       */ -        if ( (accelvar>goomlimit) || (accelvar<-goomlimit) ) -        { -            goomvar ++ ; -            /* if (goomvar % 1 == 0) */ -            { -			  guint32 vtmp ; -                guint32 newvit ; -			  lockvar = 50; -                newvit = STOP_SPEED - speedvar / 2 ; -                /*  retablir le zoom avant.. */ -                if ((zfd.reverse) && -                        (!(cycle%13)) && -                        (rand ()%5==0)) -                { -                    zfd.reverse = 0 ; -                    zfd.vitesse = STOP_SPEED - 2 ; -                    lockvar = 75 ; -                } -                if (iRAND (10) == 0) -                { -                    zfd.reverse = 1; -                    lockvar = 100; -                } - -        if (iRAND(10) == 0) -          zfd.vitesse=STOP_SPEED-1; -        if (iRAND(12) == 0) -		          zfd.vitesse=STOP_SPEED+1; - -		/*  changement de milieu.. */ -                switch (iRAND(25)) -                { +			zfd.mode = SCRUNCH_MODE; +			zfd.waveEffect = 1; +			zfd.hypercosEffect = 1; +			break; +		default: +			zfd.mode = NORMAL_MODE; +			zfd.waveEffect = 0; +			zfd.hypercosEffect = 0; +		} +	} + +	/* tout ceci ne sera fait qu'en cas de non-blocage */ +	if (lockvar == 0) { +		/* reperage de goom (acceleration forte de l'acceleration du volume) */ +		/* -> coup de boost de la vitesse si besoin.. */ +		if ((accelvar > goomlimit) || (accelvar < -goomlimit)) { +			goomvar++; +			/* if (goomvar % 1 == 0) */ +			{ +				guint32 vtmp; +				guint32 newvit; + +				lockvar = 50; +				newvit = STOP_SPEED - speedvar / 2; +				/* retablir le zoom avant.. */ +				if ((zfd.reverse) && (!(cycle % 13)) && (rand () % 5 == 0)) { +					zfd.reverse = 0; +					zfd.vitesse = STOP_SPEED - 2; +					lockvar = 75; +				} +				if (iRAND (10) == 0) { +					zfd.reverse = 1; +					lockvar = 100; +				} + +				if (iRAND (10) == 0) +					zfd.vitesse = STOP_SPEED - 1; +				if (iRAND (12) == 0) +					zfd.vitesse = STOP_SPEED + 1; + +				/* changement de milieu.. */ +				switch (iRAND (25)) {  				case 0:  				case 3:  				case 6: -				  zfd.middleY = c_resoly - 1 ; -				  zfd.middleX = resolx / 2 ; -				  break ; +					zfd.middleY = c_resoly - 1; +					zfd.middleX = resolx / 2; +					break;  				case 1:  				case 4: -				  zfd.middleX = resolx - 1 ; -				  break ; +					zfd.middleX = resolx - 1; +					break;  				case 2:  				case 5: -				  zfd.middleX = 1 ; -				  break ; +					zfd.middleX = 1; +					break;  				default: -				  zfd.middleY = c_resoly / 2 ; -				  zfd.middleX = resolx / 2 ; -                } -				 -                if (zfd.mode == WATER_MODE) -                { -                    zfd.middleX = resolx / 2; -                    zfd.middleY = c_resoly / 2; -                } - -                switch (vtmp = (iRAND (15))) -                { -                    case 0: -                        zfd.vPlaneEffect = iRAND(3) - iRAND(3); -                        zfd.hPlaneEffect = iRAND(3) - iRAND(3); -                        break; -                    case 3: -                        zfd.vPlaneEffect = 0 ; -                        zfd.hPlaneEffect = iRAND(8) - iRAND(8); -                        break; -                    case 4: -                    case 5: -                    case 6: -                    case 7: -                        zfd.vPlaneEffect = iRAND(5) - iRAND (5); -                        zfd.hPlaneEffect = - zfd.vPlaneEffect; -                        break; -                    case 8: -                        zfd.hPlaneEffect = 5 + iRAND (8); -                        zfd.vPlaneEffect = - zfd.hPlaneEffect ; -                        break; -                    case 9: -                        zfd.vPlaneEffect = 5 + iRAND (8); -                        zfd.hPlaneEffect = - zfd.hPlaneEffect ; -                        break; -                    case 13: -                        zfd.hPlaneEffect = 0; -                        zfd.vPlaneEffect = iRAND(10) - iRAND(10); -                        break; -                    case 14: -                        zfd.hPlaneEffect = iRAND(10) - iRAND(10); -                        zfd.vPlaneEffect = iRAND(10) - iRAND(10); -                        break; -                    default: -                        if (vtmp < 10) -                        { -                            zfd.vPlaneEffect = 0; -                            zfd.hPlaneEffect = 0; -                        } -                    } - -                if (iRAND (5) != 0) zfd.noisify = 0 ; -                else -                { -                    zfd.noisify = iRAND (3) + 2 ; -                    lockvar *= 2; -                } -			 -                if (zfd.mode == AMULETTE_MODE) -                { -                    zfd.vPlaneEffect = 0; -                    zfd.hPlaneEffect = 0; -                    zfd.noisify = 0; -                } - -                if ((zfd.middleX == 1) || (zfd.middleX == resolx - 1)) -                { -                    zfd.vPlaneEffect = 0 ; -                    zfd.hPlaneEffect = iRAND (2) ? 0 : zfd.hPlaneEffect; -                } - -                if (newvit < zfd.vitesse) /*  on accelere */ -                { -                    pzfd = &zfd; -                    if ( ( (newvit < STOP_SPEED - 7) && -                                (zfd.vitesse < STOP_SPEED - 6) && -                                (cycle % 3 == 0)) || -                                (iRAND (40) == 0)) -                    { -                        zfd.vitesse = STOP_SPEED - iRAND(2) + iRAND(2) ; -                        zfd.reverse = ! zfd.reverse ; -                    } -                    else -                    { -                        zfd.vitesse = (newvit + zfd.vitesse * 4) / 5 ; -                    } -                    lockvar += 50 ; -                } -            } +					zfd.middleY = c_resoly / 2; +					zfd.middleX = resolx / 2; +				} + +				if (zfd.mode == WATER_MODE) { +					zfd.middleX = resolx / 2; +					zfd.middleY = c_resoly / 2; +				} + +				switch (vtmp = (iRAND (15))) { +				case 0: +					zfd.vPlaneEffect = iRAND (3) - iRAND (3); +					zfd.hPlaneEffect = iRAND (3) - iRAND (3); +					break; +				case 3: +					zfd.vPlaneEffect = 0; +					zfd.hPlaneEffect = iRAND (8) - iRAND (8); +					break; +				case 4: +				case 5: +				case 6: +				case 7: +					zfd.vPlaneEffect = iRAND (5) - iRAND (5); +					zfd.hPlaneEffect = -zfd.vPlaneEffect; +					break; +				case 8: +					zfd.hPlaneEffect = 5 + iRAND (8); +					zfd.vPlaneEffect = -zfd.hPlaneEffect; +					break; +				case 9: +					zfd.vPlaneEffect = 5 + iRAND (8); +					zfd.hPlaneEffect = -zfd.hPlaneEffect; +					break; +				case 13: +					zfd.hPlaneEffect = 0; +					zfd.vPlaneEffect = iRAND (10) - iRAND (10); +					break; +				case 14: +					zfd.hPlaneEffect = iRAND (10) - iRAND (10); +					zfd.vPlaneEffect = iRAND (10) - iRAND (10); +					break; +				default: +					if (vtmp < 10) { +						zfd.vPlaneEffect = 0; +						zfd.hPlaneEffect = 0; +					} +				} + +				if (iRAND (5) != 0) +					zfd.noisify = 0; +				else { +					zfd.noisify = iRAND (3) + 2; +					lockvar *= 2; +				} + +				if (zfd.mode == AMULETTE_MODE) { +					zfd.vPlaneEffect = 0; +					zfd.hPlaneEffect = 0; +					zfd.noisify = 0; +				} + +				if ((zfd.middleX == 1) || (zfd.middleX == resolx - 1)) { +					zfd.vPlaneEffect = 0; +					zfd.hPlaneEffect = iRAND (2) ? 0 : zfd.hPlaneEffect; +				} + +				if (newvit < zfd.vitesse)	/* on accelere */ +				{ +					pzfd = &zfd; +					if (((newvit < STOP_SPEED - 7) && +							 (zfd.vitesse < STOP_SPEED - 6) && +							 (cycle % 3 == 0)) || (iRAND (40) == 0)) { +						zfd.vitesse = STOP_SPEED - iRAND (2) + iRAND (2); +						zfd.reverse = !zfd.reverse; +					} +					else { +						zfd.vitesse = (newvit + zfd.vitesse * 4) / 5; +					} +					lockvar += 50; +				} +			}  			if (lockvar > 150) { -			  switchIncr = SWITCHINCR; -			  switchMult = 1.0f; +				switchIncr = SWITCHINCR; +				switchMult = 1.0f;  			} -        } -	  /*  mode mega-lent */ -	  if (iRAND(700) == 0) -		{ -		  /*  -			 printf ("coup du sort...\n") ; -		  */ -		  pzfd = &zfd ; -		  zfd.vitesse = STOP_SPEED - 1 ; -		  zfd.pertedec = 8 ; -		  zfd.sqrtperte = 16 ; -		  goomvar = 1 ; -		  lockvar += 50 ; -		  switchIncr = SWITCHINCR; -		  switchMult = 1.0f; +		} +		/* mode mega-lent */ +		if (iRAND (700) == 0) { +			/*  +			 * printf ("coup du sort...\n") ; +			 */ +			pzfd = &zfd; +			zfd.vitesse = STOP_SPEED - 1; +			zfd.pertedec = 8; +			zfd.sqrtperte = 16; +			goomvar = 1; +			lockvar += 50; +			switchIncr = SWITCHINCR; +			switchMult = 1.0f;  		}  	} -	 -  /*  gros frein si la musique est calme */ -  if ((speedvar < 1) && (zfd.vitesse < STOP_SPEED - 4) && (cycle % 16 == 0)) -	{ -	  /* -		printf ("++slow part... %i\n", zfd.vitesse) ; -	  */ -	  pzfd = &zfd ; -	  zfd.vitesse += 3 ; -	  zfd.pertedec = 8 ; -	  zfd.sqrtperte = 16 ; -	  goomvar = 0 ; -	  /* -		printf ("--slow part... %i\n", zfd.vitesse) ; -	  */ + +	/* gros frein si la musique est calme */ +	if ((speedvar < 1) && (zfd.vitesse < STOP_SPEED - 4) && (cycle % 16 == 0)) { +		/*  +		 * printf ("++slow part... %i\n", zfd.vitesse) ; +		 */ +		pzfd = &zfd; +		zfd.vitesse += 3; +		zfd.pertedec = 8; +		zfd.sqrtperte = 16; +		goomvar = 0; +		/*  +		 * printf ("--slow part... %i\n", zfd.vitesse) ; +		 */  	} -	 -  /*  baisser regulierement la vitesse... */ -  if ( (cycle % 73 == 0) && (zfd.vitesse < STOP_SPEED - 5)) -	{ -	  /* -		printf ("slow down...\n") ; -	  */ -	  pzfd = &zfd ; -	  zfd.vitesse ++ ; + +	/* baisser regulierement la vitesse... */ +	if ((cycle % 73 == 0) && (zfd.vitesse < STOP_SPEED - 5)) { +		/*  +		 * printf ("slow down...\n") ; +		 */ +		pzfd = &zfd; +		zfd.vitesse++;  	} -	 -  /*  arreter de decrémenter au bout d'un certain temps */ -  if ((cycle % 101 == 0) && (zfd.pertedec == 7)) -	{ -	  pzfd = &zfd ; -	  zfd.pertedec=8 ; -	  zfd.sqrtperte=16 ; + +	/* arreter de decrémenter au bout d'un certain temps */ +	if ((cycle % 101 == 0) && (zfd.pertedec == 7)) { +		pzfd = &zfd; +		zfd.pertedec = 8; +		zfd.sqrtperte = 16;  	} -	 +  	if ((forceMode > 0) && (forceMode <= NB_FX)) { -		pzfd=&zfd; +		pzfd = &zfd;  		pzfd->mode = forceMode - 1;  	} @@ -546,176 +587,380 @@ guint32 * goom_update (gint16 data [2][512],int forceMode)  	}  	if (pzfd != NULL) { -	  static int exvit = 128; -	  int dif; -	  nombreCDDC = 0; - -	  switchIncr = SWITCHINCR; - -	  dif = zfd.vitesse - exvit; -	  if (dif < 0) dif=-dif; - -	  if (dif > 2) { -		switchIncr *= (dif + 2) / 2; -	  } -	  exvit = zfd.vitesse; -	  switchMult = 1.0f; -	   -	  if (((accelvar > goomlimit) && (totalgoom < 2))||(forceMode>0)) { -		switchIncr = 0; -		switchMult = SWITCHMULT; -	  } +		static int exvit = 128; +		int     dif; + +		nombreCDDC = 0; + +		switchIncr = SWITCHINCR; + +		dif = zfd.vitesse - exvit; +		if (dif < 0) +			dif = -dif; + +		if (dif > 2) { +			switchIncr *= (dif + 2) / 2; +		} +		exvit = zfd.vitesse; +		switchMult = 1.0f; + +		if (((accelvar > goomlimit) && (totalgoom < 2)) || (forceMode > 0)) { +			switchIncr = 0; +			switchMult = SWITCHMULT; +		}  	} -  else { -	if (nombreCDDC > TIME_BTW_CHG) { -	  pzfd = &zfd; -	  nombreCDDC = 0; +	else { +		if (nombreCDDC > TIME_BTW_CHG) { +			pzfd = &zfd; +			nombreCDDC = 0; +		} +		else +			nombreCDDC++;  	} -	else -	  nombreCDDC ++; -  }  #ifdef VERBOSE -  if (pzfd) -	{ -	  printf ("GOOM: pzfd->mode = %d\n", pzfd->mode); +	if (pzfd) { +		printf ("GOOM: pzfd->mode = %d\n", pzfd->mode);  	}  #endif +	/* Zoom here ! */ +	zoomFilterFastRGB (p1 + c_offset, p2 + c_offset, pzfd, resolx, c_resoly, +										 switchIncr, switchMult); +	{ +		static char title[1024]; +		static int displayTitle = 0; +		char    text[255]; + +		if (fps > 0) { +			int i; +			if (speedvar>0) { +				for (i=0;i<speedvar;i++) +					text[i]='*'; +				text[i]=0; +				goom_draw_text (p1 + c_offset, +												10, 50, text, +												1.0f, 0); +			} +			if (accelvar>0) { +				for (i=0;i<accelvar;i++) { +					if (i==goomlimit) +						text[i]='o'; +					else +						text[i]='*'; +				} +				text[i]=0; +				goom_draw_text (p1 + c_offset, +												10, 62, text, +												1.0f, 0); +			} +			if (agoom==20) +				goom_draw_text (p1 + c_offset,10, 80, "GOOM",1.0f, 0); +			else if (agoom) +				goom_draw_text (p1 + c_offset,10, 80, "goom",1.0f, 0); +			if (abiggoom==200) +				goom_draw_text (p1 + c_offset,10, 100, "BGOOM",1.0f, 0); +			else if (abiggoom) +				goom_draw_text (p1 + c_offset,10, 100, "bgoom",1.0f, 0); +		} -    /*  si on est dans un goom : afficher les lignes... */ -	 -	if (lineMode != DRAWLINES) { -	  lineMode --; -	  if (lineMode == -1) -		lineMode = 0; +		update_message (message); + +		if (fps > 0) { +			sprintf (text, "%3.f fps", fps); +			goom_draw_text (p1 + c_offset, +											24, 24, text, 1, 1); +		} + +		if (songTitle != NULL) { +			sprintf (title, songTitle);	/* la flemme d'inclure string.h :) */ +			displayTitle = 200; +		} + +		if (displayTitle) { +			goom_draw_text (p1 + c_offset, +											resolx / 2, c_resoly / 2 + 7, title, +											((float) (200 - displayTitle) / 10.0f), 1); +			displayTitle--; +			if (displayTitle < 4) +				goom_draw_text (p2 + c_offset, +												resolx / 2, c_resoly / 2 + 7, title, +												((float) (200 - displayTitle) / 10.0f), 1); +		}  	} -	if ((agoom > 0) && (totalgoom>2) && (cycle % 120 == 0) && (iRAND(3)==0)) { -	  if (lineMode == 0) -		lineMode = DRAWLINES; -	  else if (lineMode == DRAWLINES) { -		float param1,param2; -		int couleur; -		int mode; -		 -		lineMode --; -		choose_a_goom_line (¶m1, ¶m2, &couleur, -							&mode); -		 -		goom_lines_switch_to (gmline1, mode, param1, GML_BLACK); -		goom_lines_switch_to (gmline2, mode, param2, GML_BLACK); -	  } +	/* si on est dans un goom : afficher les lignes... */ + +	if (lineMode != DRAWLINES) { +		lineMode--; +		if (lineMode == -1) +			lineMode = 0; +	} +	else if ((iRAND(60)==0)&&lineMode) +		lineMode--; + +	if ((agoom > 0) && (totalgoom > 2) && (cycle % 120 == 0) +			&& (iRAND (3) == 0)) { +		if (lineMode == 0) +			lineMode = DRAWLINES; +		else if (lineMode == DRAWLINES) { +			float   param1, param2; +			int     couleur; +			int     mode; + +			lineMode--; +			choose_a_goom_line (¶m1, ¶m2, &couleur, &mode); + +			goom_lines_switch_to (gmline1, mode, param1, couleur); +			goom_lines_switch_to (gmline2, mode, param2, 5 - couleur); +		}  	}  	if ((lineMode != 0) || (agoom > 15)) { -	  gmline2->power = gmline1->power; - -	  goom_lines_draw (gmline1,data[0],p1+c_offset); -	  goom_lines_draw (gmline2,data[1],p1+c_offset); -	   -	  if (((cycle % 101)==9) && (iRAND (3)==1) -		  && ((lineMode == 0) || (lineMode == DRAWLINES))) { -		float param1,param2; -		int couleur; -		int mode; - -		choose_a_goom_line (¶m1, ¶m2, &couleur, -							&mode); - -		goom_lines_switch_to (gmline1, mode, param1, couleur); -		goom_lines_switch_to (gmline2, mode, param2, 5-couleur); -	  } +		gmline2->power = gmline1->power; + +		goom_lines_draw (gmline1, data[0], p2 + c_offset); +		goom_lines_draw (gmline2, data[1], p2 + c_offset); + +		if (((cycle % 101) == 9) && (iRAND (3) == 1) +				&& ((lineMode == 0) || (lineMode == DRAWLINES))) { +			float   param1, param2; +			int     couleur; +			int     mode; + +			choose_a_goom_line (¶m1, ¶m2, &couleur, &mode); + +			goom_lines_switch_to (gmline1, mode, param1, couleur); +			goom_lines_switch_to (gmline2, mode, param2, 5 - couleur); +		}  	} -	/*    if (agoom > 15) goom_lines_draw -		  (gmline,data, -		  ( (zfd.middleX == resolx/2) -		  && (zfd.middleY == c_resoly/2) -		  && (zfd.mode != WATER_MODE) ) -		  ? (lineMode/10) : 0, -		  p2+c_offset,agoom-15); -	*/ -    /*  Zoom here ! */ -    zoomFilterFastRGB (p1+c_offset, p2+c_offset, pzfd, resolx, c_resoly, -		       switchIncr, switchMult) ; - - -    return_val = p2 ; -    tmp=p1; -    p1=p2; -    p2=tmp; - -    /*  affichage et swappage des buffers.. */ -    cycle++; -	 -    /*  tous les 100 cycles : vérifier si le taux de goom est correct */ -    /*  et le modifier sinon.. */ -    if (!(cycle%100)) -    { -        if (totalgoom>15) -        { -            /* 	printf ("less gooms\n") ; */ -            goomlimit ++ ; -        } -        else -        { -            if ((totalgoom==0) && (goomlimit>1)) -                goomlimit -- ; -        }         -        totalgoom = 0 ; -    } -    return return_val; + +	return_val = p1; +	tmp = p1; +	p1 = p2; +	p2 = tmp; + +	/* affichage et swappage des buffers.. */ +	cycle++; + +	/* toute les 2 secondes : vérifier si le taux de goom est correct */ +	/* et le modifier sinon.. */ +	if (!(cycle % 64)) { +		if (speedvar<1) +			goomlimit /= 2; +		if (totalgoom > 4) { +			goomlimit++; +		} +		if (totalgoom > 7) { +			goomlimit*=4/3; +			goomlimit+=2; +		} +		if ((totalgoom == 0) && (goomlimit > 1)) +			goomlimit--; +		if ((totalgoom == 1) && (goomlimit > 1)) +			goomlimit--; +		totalgoom = 0; +	} +	return return_val;  } -void goom_close () +void +goom_close ()  { -  if (pixel!=NULL) free (pixel) ; -  if (back!=NULL) free (back) ; -  	pixel = back = NULL; -  RAND_CLOSE(); -  release_ifs (); -  goom_lines_free (&gmline1); -  goom_lines_free (&gmline2); +	if (pixel != NULL) +		free (pixel); +	if (back != NULL) +		free (back); +	pixel = back = NULL; +	RAND_CLOSE (); +	release_ifs (); +	goom_lines_free (&gmline1); +	goom_lines_free (&gmline2);  } -void choose_a_goom_line (float *param1, float *param2, int *couleur, -						 int *mode) +void +choose_a_goom_line (float *param1, float *param2, int *couleur, int *mode)  { -  *mode = iRAND (3); -  switch (*mode) { -  case GML_CIRCLE: -	if (iRAND (3)==0) { -	  *param1 = *param2 = 0; -	} -	else if (iRAND(2)) { -	  *param1 = 0.40f * c_resoly; -	  *param2 = 0.20f * c_resoly; -	} -	else { -	  *param1 = *param2 = c_resoly * 0.25; +	*mode = iRAND (3); +	switch (*mode) { +	case GML_CIRCLE: +		if (iRAND (3) == 0) { +			*param1 = *param2 = 0; +		} +		else if (iRAND (2)) { +			*param1 = 0.40f * c_resoly; +			*param2 = 0.20f * c_resoly; +		} +		else { +			*param1 = *param2 = c_resoly * 0.25; +		} +		break; +	case GML_HLINE: +		if (iRAND (4)) { +			*param1 = c_resoly / 7; +			*param2 = 6.0f * c_resoly / 7.0f; +		} +		else { +			*param1 = *param2 = c_resoly / 2.0f; +		} +		break; +	case GML_VLINE: +		if (iRAND (3)) { +			*param1 = resolx / 7.0f; +			*param2 = 6.0f * resolx / 7.0f; +		} +		else { +			*param1 = *param2 = resolx / 2.0f; +		} +		break;  	} -	break; -  case GML_HLINE: -	if (iRAND (4)) { -	  *param1 = c_resoly / 7; -	  *param2 = 6.0f * c_resoly / 7.0f; + +	*couleur = iRAND (6); +} + +void +goom_draw_text (guint32 * buf, +								int x, int y, const char *str, float charspace, int center) +{ +	float   fx = (float) x; +	int     fin = 0; +	 +	if (font_chars == NULL) +		return ; + +	if (center) { +		unsigned char   *tmp = str; +		float   lg = -charspace; + +		while (*tmp != '\0') +			lg += font_width[*(tmp++)] + charspace; + +		fx -= lg / 2;  	} -	else { -	  *param1 = *param2 = c_resoly / 2.0f; + +	while (!fin) { +		unsigned char    c = *str; + +		x = (int) fx; + +		if (c == '\0') +			fin = 1; +		else { +			int     xx, yy; +			int     xmin = x; +			int     xmax = x + font_width[c]; +			int     ymin = y - font_height[c]; +			int     ymax = y; + +			yy = ymin; + +			if (xmin < 0) +				xmin = 0; + +			if (xmin >= resolx - 1) +				return; + +			if (xmax >= (int) resolx) +				xmax = resolx - 1; + +			if (yy < 0) +				yy = 0; + +			if (yy <= (int) resoly - 1) { +				if (ymax >= (int) resoly - 1) +					ymax = resoly - 1; + +				for (; yy < ymax; yy++) +					for (xx = xmin; xx < xmax; xx++) +						if (font_chars[c][yy - ymin][xx - x] & 0xff000000) +							buf[yy * resolx + xx] = font_chars[c][yy - ymin][xx - x]; +			} +			fx += font_width[c] + charspace; +		} +		str++;  	} -	break; -  case GML_VLINE: -	if (iRAND (3)) { -	  *param1 = resolx / 7.0f; -	  *param2 = 6.0f * resolx / 7.0f; +} + +void +goom_set_font (int ***chars, int *width, int *height) +{ +	font_chars = chars; +	font_width = width; +	font_height = height; +	/* tester les fonts.. */ +} + + +/* + * Met a jour l'affichage du message defilant + */ +void update_message (char *message) { + +	static int nbl; +	static char msg2 [0x800]; +	static int affiche = 0; +	static int longueur; +	int fin = 0; +	if (message) { +		int i=1,j=0; +		sprintf (msg2,message); +		for (j=0;msg2[j];j++) +			if (msg2[j]=='\n') +				i++; +		nbl = i; +		affiche = resoly + nbl * 25 + 105; +		longueur = strlen (msg2);  	} -	else { -	  *param1 = *param2 = resolx / 2.0f; +	if (affiche) { +		int i = 0; +		char *msg=malloc(longueur+1); +		char *ptr = msg; +		int pos; +		float ecart; +		message = msg; +		sprintf (msg,msg2); +		 +		while (!fin) { +			while (1) { +				if (*ptr == 0) { +					fin = 1; +					break; +				} +				if (*ptr == '\n') { +					*ptr = 0; +					break; +				} +				++ptr; +			} +			pos = affiche - (nbl-i)*25; +			pos += 6.0*(cos((double)pos/20.0)); +			pos -= 80; +			ecart = (3.0+1.0*sin((double)pos/20.0)); +			if ((fin) && (2 * pos < (int)resoly)) +				pos = (int)resoly / 2; +			pos += 7; + +			goom_draw_text(p1 + c_offset, +										 resolx/2, pos, +										 message, +										 ecart, +										 1); +			message = ++ptr; +			i++; +		} +		affiche --; +		free (msg);  	} -	break; -  } -   -  *couleur = iRAND (6);  } + +void goom_setAsmUse (int useIt) +{ +	use_asm = useIt; +} + +int goom_getAsmUse () +{ +	return use_asm; +}
\ No newline at end of file diff --git a/src/post/goom/goom_core.h b/src/post/goom/goom_core.h index c74adb5c0..5c5efd286 100644 --- a/src/post/goom/goom_core.h +++ b/src/post/goom/goom_core.h @@ -18,21 +18,26 @@  #define NB_FX 8 -void goom_init (guint32 resx, guint32 resy, int cinemascope); -void goom_set_resolution (guint32 resx, guint32 resy, int cinemascope); +void    goom_init (guint32 resx, guint32 resy, int cinemascope); +void    goom_set_resolution (guint32 resx, guint32 resy, int cinemascope);  /*   * forceMode == 0 : do nothing   * forceMode == -1 : lock the FX   * forceMode == 1..NB_FX : force a switch to FX n°forceMode + * + * songTitle = pointer to the title of the song... + *      - NULL if it is not the start of the song + *      - only have a value at the start of the song   */ -guint32 * goom_update (gint16 data [2][512], int forceMode); +guint32 *goom_update (gint16 data[2][512], int forceMode, float fps, +											char *songTitle, char *message); -void goom_close (); +void    goom_close (); -/* -  void goom_start (); -  void goom_stop (); -*/ +void    goom_set_font (int ***chars, int *width, int *height); + +void goom_setAsmUse (int useIt); +int goom_getAsmUse ();  #endif diff --git a/src/post/goom/goom_tools.h b/src/post/goom/goom_tools.h index ad646e60d..9ed16d6fc 100644 --- a/src/post/goom/goom_tools.h +++ b/src/post/goom/goom_tools.h @@ -4,8 +4,8 @@  #define NB_RAND 0x10000  /* in graphic.c */ -extern int * rand_tab ; -extern unsigned short rand_pos ; +extern int *rand_tab; +extern unsigned short rand_pos;  #define RAND_INIT(i) \  	srand (i) ;\ @@ -25,5 +25,5 @@ extern unsigned short rand_pos ;  /* #define iRAND(i) ((guint32)((float)i * RAND()/RAND_MAX)) */  #define iRAND(i) (RAND()%i) -	 +  #endif diff --git a/src/post/goom/graphic.c b/src/post/goom/graphic.c index 4223c67bd..10f3c7773 100644 --- a/src/post/goom/graphic.c +++ b/src/post/goom/graphic.c @@ -1,17 +1,17 @@  #include "graphic.h" -const Color BLACK = {0,0,0} ; -const Color WHITE = {0xff,0xff,0xff} ; -const Color RED = {0xff,0,0} ; -const Color GREEN = {0,0xff,0} ; -const Color BLUE = {0,0,0xff} ; -const Color YELLOW = {0xff, 0xff, 0x33} ; -const Color ORANGE = {0xff, 0xcc, 0x00} ; -const Color VIOLET = {0x55, 0x00, 0xff} ; +const Color BLACK = { 0, 0, 0 }; +const Color WHITE = { 0xff, 0xff, 0xff }; +const Color RED = { 0xff, 0, 0 }; +const Color GREEN = { 0, 0xff, 0 }; +const Color BLUE = { 0, 0, 0xff }; +const Color YELLOW = { 0xff, 0xff, 0x33 }; +const Color ORANGE = { 0xff, 0xcc, 0x00 }; +const Color VIOLET = { 0x55, 0x00, 0xff }; -unsigned int SIZE ; -unsigned int HEIGHT ; -unsigned int WIDTH ; +unsigned int SIZE; +unsigned int HEIGHT; +unsigned int WIDTH; -int * rand_tab = 0 ; -unsigned short int rand_pos = 0 ; +int    *rand_tab = 0; +unsigned short int rand_pos = 0; diff --git a/src/post/goom/graphic.h b/src/post/goom/graphic.h index 415dde73c..e66ba9e49 100644 --- a/src/post/goom/graphic.h +++ b/src/post/goom/graphic.h @@ -5,7 +5,7 @@ typedef unsigned int Uint;  typedef struct  { -  unsigned short r,v,b; +	unsigned short r, v, b;  }  Color; @@ -18,7 +18,7 @@ extern const Color YELLOW;  extern const Color ORANGE;  extern const Color VIOLET; -inline void setPixelRGB (Uint *buffer, Uint x, Uint y, Color c) ; -inline void getPixelRGB (Uint *buffer, Uint x, Uint y, Color *c) ; +inline void setPixelRGB (Uint * buffer, Uint x, Uint y, Color c); +inline void getPixelRGB (Uint * buffer, Uint x, Uint y, Color * c); -#endif /*GRAPHIC_H*/ +#endif /* GRAPHIC_H */ diff --git a/src/post/goom/ifs.c b/src/post/goom/ifs.c index 72330f4a3..c7e843d09 100644 --- a/src/post/goom/ifs.c +++ b/src/post/goom/ifs.c @@ -33,7 +33,7 @@ static const char sccsid[] = "@(#)ifs.c	5.00 2002/04/11 baffe";   *              that onto the screen, to reduce flicker.   */ -/* #ifdef STANDALONE */ +/*#ifdef STANDALONE */  #include <math.h>  #include <stdlib.h> @@ -55,28 +55,31 @@ static const char sccsid[] = "@(#)ifs.c	5.00 2002/04/11 baffe";  #define SMOOTH_COLORS -/* #include "xlockmore.h"		/\* in xscreensaver distribution *\/ */ -/* #else /\* STANDALONE *\/ */ -/* #include "xlock.h"		/\* in xlockmore distribution *\/ */ -/* #endif /\* STANDALONE *\/ */ +/*#include "xlockmore.h"   */              /* in xscreensaver distribution */ +/*#else  */ /* STANDALONE */ +/*#include "xlock.h"      */       /* in xlockmore distribution */ +/*#endif  */ /* STANDALONE */ -/* #ifdef MODE_ifs */ +/*#ifdef MODE_ifs */ -/* ModeSpecOpt ifs_opts = */ -/* {0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL}; */ +/*ModeSpecOpt ifs_opts = */ +/*{0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL}; */ -/* #ifdef USE_MODULES */ -/* ModStruct   ifs_description = */ -/* {"ifs", "init_ifs", "draw_ifs", "release_ifs", */ -/*  "init_ifs", "init_ifs", (char *) NULL, &ifs_opts, */ -/*  1000, 1, 1, 1, 64, 1.0, "", */ -/*  "Shows a modified iterated function system", 0, NULL}; */ +/*#ifdef USE_MODULES */ +/*ModStruct   ifs_description = */ +/*{"ifs", "init_ifs", "draw_ifs", "release_ifs", */ +/* "init_ifs", "init_ifs", (char *) NULL, &ifs_opts, */ +/* 1000, 1, 1, 1, 64, 1.0, "", */ +/* "Shows a modified iterated function system", 0, NULL}; */ -/* #endif */ +/*#endif */ -#define LRAND()                    ((long) (rand() & 0x7fffffff)) +#include "goom_tools.h" + +#define LRAND()                    ((long) (RAND() & 0x7fffffff))  #define NRAND(n)           ((int) (LRAND() % (n))) -#define MAXRAND                    (2147483648.0) /* unsigned 1<<31 as a float */ +#define MAXRAND                    (2147483648.0)	/* unsigned 1<<31 as a * * +																									 * * float */  /*****************************************************/ @@ -91,226 +94,238 @@ typedef int F_PT;  #define UNIT   ( 1<<FIX )  #define MAX_SIMI  6 -/* settings for a PC 120Mhz... */ +#define MAX_DEPTH_2  10 +#define MAX_DEPTH_3  6 +#define MAX_DEPTH_4  4 +#define MAX_DEPTH_5  2 + +/* PREVIOUS VALUE  +#define MAX_SIMI  6 + +* settings for a PC 120Mhz... *  #define MAX_DEPTH_2  10  #define MAX_DEPTH_3  6  #define MAX_DEPTH_4  4  #define MAX_DEPTH_5  3 +*/  #define DBL_To_F_PT(x)  (F_PT)( (DBL)(UNIT)*(x) )  typedef struct Similitude_Struct SIMI;  typedef struct Fractal_Struct FRACTAL; -struct Similitude_Struct { +struct Similitude_Struct +{ -	DBL         c_x, c_y; -	DBL         r, r2, A, A2; -	F_PT        Ct, St, Ct2, St2; -	F_PT        Cx, Cy; -	F_PT        R, R2; +	DBL     c_x, c_y; +	DBL     r, r2, A, A2; +	F_PT    Ct, St, Ct2, St2; +	F_PT    Cx, Cy; +	F_PT    R, R2;  }; -struct Fractal_Struct { - -	int         Nb_Simi; -	SIMI        Components[5 * MAX_SIMI]; -	int         Depth, Col; -	int         Count, Speed; -	int         Width, Height, Lx, Ly; -	DBL         r_mean, dr_mean, dr2_mean; -	int         Cur_Pt, Max_Pt; +struct Fractal_Struct +{ -	IFSPoint    *Buffer1, *Buffer2; -/* 	Pixmap      dbuf; */ -/* 	GC          dbuf_gc; */ +	int     Nb_Simi; +	SIMI    Components[5 * MAX_SIMI]; +	int     Depth, Col; +	int     Count, Speed; +	int     Width, Height, Lx, Ly; +	DBL     r_mean, dr_mean, dr2_mean; +	int     Cur_Pt, Max_Pt; + +	IFSPoint *Buffer1, *Buffer2; +/*      Pixmap      dbuf; */ +/*      GC          dbuf_gc; */  };  static FRACTAL *Root = (FRACTAL *) NULL, *Cur_F;  /* Used by the Trace recursive method */  IFSPoint *Buf; -static int  Cur_Pt; +static int Cur_Pt;  /*****************************************************/ -static      DBL -Gauss_Rand(DBL c, DBL A, DBL S) +static  DBL +Gauss_Rand (DBL c, DBL A, DBL S)  { -	DBL         y; +	DBL     y; -	y = (DBL) LRAND() / MAXRAND; -	y = A * (1.0 - exp(-y * y * S)) / (1.0 - exp(-S)); -	if (NRAND(2)) +	y = (DBL) LRAND () / MAXRAND; +	y = A * (1.0 - exp (-y * y * S)) / (1.0 - exp (-S)); +	if (NRAND (2))  		return (c + y);  	return (c - y);  } -static      DBL -Half_Gauss_Rand(DBL c, DBL A, DBL S) +static  DBL +Half_Gauss_Rand (DBL c, DBL A, DBL S)  { -	DBL         y; +	DBL     y; -	y = (DBL) LRAND() / MAXRAND; -	y = A * (1.0 - exp(-y * y * S)) / (1.0 - exp(-S)); +	y = (DBL) LRAND () / MAXRAND; +	y = A * (1.0 - exp (-y * y * S)) / (1.0 - exp (-S));  	return (c + y);  }  static void -Random_Simis(FRACTAL * F, SIMI * Cur, int i) +Random_Simis (FRACTAL * F, SIMI * Cur, int i)  {  	while (i--) { -		Cur->c_x = Gauss_Rand(0.0, .8, 4.0); -		Cur->c_y = Gauss_Rand(0.0, .8, 4.0); -		Cur->r = Gauss_Rand(F->r_mean, F->dr_mean, 3.0); -		Cur->r2 = Half_Gauss_Rand(0.0, F->dr2_mean, 2.0); -		Cur->A = Gauss_Rand(0.0, 360.0, 4.0) * (M_PI / 180.0); -		Cur->A2 = Gauss_Rand(0.0, 360.0, 4.0) * (M_PI / 180.0); +		Cur->c_x = Gauss_Rand (0.0, .8, 4.0); +		Cur->c_y = Gauss_Rand (0.0, .8, 4.0); +		Cur->r = Gauss_Rand (F->r_mean, F->dr_mean, 3.0); +		Cur->r2 = Half_Gauss_Rand (0.0, F->dr2_mean, 2.0); +		Cur->A = Gauss_Rand (0.0, 360.0, 4.0) * (M_PI / 180.0); +		Cur->A2 = Gauss_Rand (0.0, 360.0, 4.0) * (M_PI / 180.0);  		Cur++;  	}  }  static void -free_ifs_buffers(FRACTAL *Fractal) +free_ifs_buffers (FRACTAL * Fractal)  {  	if (Fractal->Buffer1 != NULL) { -		(void) free((void *) Fractal->Buffer1); +		(void) free ((void *) Fractal->Buffer1);  		Fractal->Buffer1 = (IFSPoint *) NULL;  	}  	if (Fractal->Buffer2 != NULL) { -		(void) free((void *) Fractal->Buffer2); +		(void) free ((void *) Fractal->Buffer2);  		Fractal->Buffer2 = (IFSPoint *) NULL;  	}  }  static void -free_ifs(FRACTAL *Fractal) +free_ifs (FRACTAL * Fractal)  { -	free_ifs_buffers(Fractal); +	free_ifs_buffers (Fractal);  }  /***************************************************************/  void -init_ifs(int width, int height) +init_ifs (int width, int height)  { -	int         i; -	FRACTAL    *Fractal; +	int     i; +	FRACTAL *Fractal; -/* 	printf ("initing ifs\n"); */ +/*      printf ("initing ifs\n"); */  	if (Root == NULL) { -	  Root = (FRACTAL *) malloc(sizeof(FRACTAL)); -	  if (Root == NULL) -		return; -	  Root->Buffer1 = (IFSPoint*)NULL; -	  Root->Buffer2 = (IFSPoint*)NULL; +		Root = (FRACTAL *) malloc (sizeof (FRACTAL)); +		if (Root == NULL) +			return; +		Root->Buffer1 = (IFSPoint *) NULL; +		Root->Buffer2 = (IFSPoint *) NULL;  	}  	Fractal = Root; -/* 	fprintf (stderr,"--ifs freeing ex-buffers\n"); */ -	free_ifs_buffers(Fractal); -/* 	fprintf (stderr,"--ifs ok\n"); */ +/*      fprintf (stderr,"--ifs freeing ex-buffers\n"); */ +	free_ifs_buffers (Fractal); +/*      fprintf (stderr,"--ifs ok\n"); */ -	i = (NRAND(4)) + 2;	/* Number of centers */ +	i = (NRAND (4)) + 2;					/* Number of centers */  	switch (i) { -		case 3: -			Fractal->Depth = MAX_DEPTH_3; -			Fractal->r_mean = .6; -			Fractal->dr_mean = .4; -			Fractal->dr2_mean = .3; -			break; - -		case 4: -			Fractal->Depth = MAX_DEPTH_4; -			Fractal->r_mean = .5; -			Fractal->dr_mean = .4; -			Fractal->dr2_mean = .3; -			break; - -		case 5: -			Fractal->Depth = MAX_DEPTH_5; -			Fractal->r_mean = .5; -			Fractal->dr_mean = .4; -			Fractal->dr2_mean = .3; -			break; - -		default: -		case 2: -			Fractal->Depth = MAX_DEPTH_2; -			Fractal->r_mean = .7; -			Fractal->dr_mean = .3; -			Fractal->dr2_mean = .4; -			break; +	case 3: +		Fractal->Depth = MAX_DEPTH_3; +		Fractal->r_mean = .6; +		Fractal->dr_mean = .4; +		Fractal->dr2_mean = .3; +		break; + +	case 4: +		Fractal->Depth = MAX_DEPTH_4; +		Fractal->r_mean = .5; +		Fractal->dr_mean = .4; +		Fractal->dr2_mean = .3; +		break; + +	case 5: +		Fractal->Depth = MAX_DEPTH_5; +		Fractal->r_mean = .5; +		Fractal->dr_mean = .4; +		Fractal->dr2_mean = .3; +		break; + +	default: +	case 2: +		Fractal->Depth = MAX_DEPTH_2; +		Fractal->r_mean = .7; +		Fractal->dr_mean = .3; +		Fractal->dr2_mean = .4; +		break;  	} -/* 	fprintf( stderr, "N=%d\n", i ); */ +/*      fprintf( stderr, "N=%d\n", i ); */  	Fractal->Nb_Simi = i;  	Fractal->Max_Pt = Fractal->Nb_Simi - 1;  	for (i = 0; i <= Fractal->Depth + 2; ++i)  		Fractal->Max_Pt *= Fractal->Nb_Simi; -	if ((Fractal->Buffer1 = (IFSPoint *) calloc(Fractal->Max_Pt, -												sizeof (IFSPoint))) == NULL) { -	  free_ifs(Fractal); -	  return; +	if ((Fractal->Buffer1 = (IFSPoint *) calloc (Fractal->Max_Pt, +																							 sizeof (IFSPoint))) == NULL) { +		free_ifs (Fractal); +		return;  	} -	if ((Fractal->Buffer2 = (IFSPoint *) calloc(Fractal->Max_Pt, -												sizeof (IFSPoint))) == NULL) { -	  free_ifs(Fractal); -	  return; +	if ((Fractal->Buffer2 = (IFSPoint *) calloc (Fractal->Max_Pt, +																							 sizeof (IFSPoint))) == NULL) { +		free_ifs (Fractal); +		return;  	} -	 -/* 	printf ("--ifs setting params\n"); */ + +/*      printf ("--ifs setting params\n"); */  	Fractal->Speed = 6; -	Fractal->Width = width; /* modif by JeKo */ -	Fractal->Height = height; /* modif by JeKo */ +	Fractal->Width = width;				/* modif by JeKo */ +	Fractal->Height = height;			/* modif by JeKo */  	Fractal->Cur_Pt = 0;  	Fractal->Count = 0;  	Fractal->Lx = (Fractal->Width - 1) / 2;  	Fractal->Ly = (Fractal->Height - 1) / 2; -	Fractal->Col = rand() % (width * height); /* modif by JeKo */ - -	Random_Simis(Fractal, Fractal->Components, 5 * MAX_SIMI); - -	/* -	  #ifndef NO_DBUF -	  if (Fractal->dbuf != None) -	  XFreePixmap(display, Fractal->dbuf); -	  Fractal->dbuf = XCreatePixmap(display, window, -	  Fractal->Width, Fractal->Height, 1); -	  /* Allocation checked * -	  if (Fractal->dbuf != None) { -	  XGCValues   gcv; -	   -	  gcv.foreground = 0; -	  gcv.background = 0; -	  gcv.graphics_exposures = False; -	  gcv.function = GXcopy; -	   -	  if (Fractal->dbuf_gc != None) -	  XFreeGC(display, Fractal->dbuf_gc); -	  if ((Fractal->dbuf_gc = XCreateGC(display, Fractal->dbuf, -	  GCForeground | GCBackground | GCGraphicsExposures | GCFunction, -	  &gcv)) == None) { -	  XFreePixmap(display, Fractal->dbuf); -	  Fractal->dbuf = None; -	  } else { -	  XFillRectangle(display, Fractal->dbuf, -	  Fractal->dbuf_gc, 0, 0, Fractal->Width, Fractal->Height); -	  XSetBackground(display, gc, MI_BLACK_PIXEL(mi)); -	  XSetFunction(display, gc, GXcopy); -	  } -	  } -	  #endif -	*/ -	/* 	MI_CLEARWINDOW(mi); */ +	Fractal->Col = rand () % (width * height);	/* modif by JeKo */ + +	Random_Simis (Fractal, Fractal->Components, 5 * MAX_SIMI); + +	/*  +	 * #ifndef NO_DBUF +	 * if (Fractal->dbuf != None) +	 * XFreePixmap(display, Fractal->dbuf); +	 * Fractal->dbuf = XCreatePixmap(display, window, +	 * Fractal->Width, Fractal->Height, 1); +	 */ +	/* Allocation checked */ +	/* if (Fractal->dbuf != None) { +	 * XGCValues   gcv; +	 *  +	 * gcv.foreground = 0; +	 * gcv.background = 0; +	 * gcv.graphics_exposures = False; +	 * gcv.function = GXcopy; +	 *  +	 * if (Fractal->dbuf_gc != None) +	 * XFreeGC(display, Fractal->dbuf_gc); +	 * if ((Fractal->dbuf_gc = XCreateGC(display, Fractal->dbuf, +	 * GCForeground | GCBackground | GCGraphicsExposures | GCFunction, +	 * &gcv)) == None) { +	 * XFreePixmap(display, Fractal->dbuf); +	 * Fractal->dbuf = None; +	 * } else { +	 * XFillRectangle(display, Fractal->dbuf, +	 * Fractal->dbuf_gc, 0, 0, Fractal->Width, Fractal->Height); +	 * XSetBackground(display, gc, MI_BLACK_PIXEL(mi)); +	 * XSetFunction(display, gc, GXcopy); +	 * } +	 * } +	 * #endif +	 */ +	/* MI_CLEARWINDOW(mi); */  	/* don't want any exposure events from XCopyPlane */ -	/* 	XSetGraphicsExposures(display, gc, False); */ -	 +	/* XSetGraphicsExposures(display, gc, False); */ +  } @@ -319,12 +334,12 @@ init_ifs(int width, int height)  /* Should be taken care of already... but just in case */  #if !defined( __GNUC__ ) && !defined(__cplusplus) && !defined(c_plusplus)  #undef inline -#define inline			/* */ +#define inline									/* */  #endif  static inline void -Transform(SIMI * Simi, F_PT xo, F_PT yo, F_PT * x, F_PT * y) +Transform (SIMI * Simi, F_PT xo, F_PT yo, F_PT * x, F_PT * y)  { -	F_PT        xx, yy; +	F_PT    xx, yy;  	xo = xo - Simi->Cx;  	xo = (xo * Simi->R) / UNIT; @@ -336,21 +351,25 @@ Transform(SIMI * Simi, F_PT xo, F_PT yo, F_PT * x, F_PT * y)  	yy = -yo - Simi->Cy;  	yy = (yy * Simi->R2) / UNIT; -	*x = ((xo * Simi->Ct - yo * Simi->St + xx * Simi->Ct2 - yy * Simi->St2) / UNIT) + Simi->Cx; -	*y = ((xo * Simi->St + yo * Simi->Ct + xx * Simi->St2 + yy * Simi->Ct2) / UNIT) + Simi->Cy; +	*x = +		((xo * Simi->Ct - yo * Simi->St + xx * Simi->Ct2 - yy * Simi->St2) / +		 UNIT) + Simi->Cx; +	*y = +		((xo * Simi->St + yo * Simi->Ct + xx * Simi->St2 + yy * Simi->Ct2) / +		 UNIT) + Simi->Cy;  }  /***************************************************************/  static void -Trace(FRACTAL * F, F_PT xo, F_PT yo) +Trace (FRACTAL * F, F_PT xo, F_PT yo)  { -	F_PT        x, y, i; -	SIMI       *Cur; +	F_PT    x, y, i; +	SIMI   *Cur;  	Cur = Cur_F->Components;  	for (i = Cur_F->Nb_Simi; i; --i, Cur++) { -		Transform(Cur, xo, yo, &x, &y); +		Transform (Cur, xo, yo, &x, &y);  		Buf->x = F->Lx + (x * F->Lx / (UNIT * 2));  		Buf->y = F->Ly - (y * F->Ly / (UNIT * 2)); @@ -360,31 +379,31 @@ Trace(FRACTAL * F, F_PT xo, F_PT yo)  		if (F->Depth && ((x - xo) >> 4) && ((y - yo) >> 4)) {  			F->Depth--; -			Trace(F, x, y); +			Trace (F, x, y);  			F->Depth++;  		}  	}  }  static void -Draw_Fractal(/*ModeInfo * mi*/) +Draw_Fractal ( /* ModeInfo * mi */ )  { -  FRACTAL    *F = Root; -  int         i, j; -  F_PT        x, y, xo, yo; -  SIMI       *Cur, *Simi; +	FRACTAL *F = Root; +	int     i, j; +	F_PT    x, y, xo, yo; +	SIMI   *Cur, *Simi;  	for (Cur = F->Components, i = F->Nb_Simi; i; --i, Cur++) { -		Cur->Cx = DBL_To_F_PT(Cur->c_x); -		Cur->Cy = DBL_To_F_PT(Cur->c_y); +		Cur->Cx = DBL_To_F_PT (Cur->c_x); +		Cur->Cy = DBL_To_F_PT (Cur->c_y); -		Cur->Ct = DBL_To_F_PT(cos(Cur->A)); -		Cur->St = DBL_To_F_PT(sin(Cur->A)); -		Cur->Ct2 = DBL_To_F_PT(cos(Cur->A2)); -		Cur->St2 = DBL_To_F_PT(sin(Cur->A2)); +		Cur->Ct = DBL_To_F_PT (cos (Cur->A)); +		Cur->St = DBL_To_F_PT (sin (Cur->A)); +		Cur->Ct2 = DBL_To_F_PT (cos (Cur->A2)); +		Cur->St2 = DBL_To_F_PT (sin (Cur->A2)); -		Cur->R = DBL_To_F_PT(Cur->r); -		Cur->R2 = DBL_To_F_PT(Cur->r2); +		Cur->R = DBL_To_F_PT (Cur->r); +		Cur->R2 = DBL_To_F_PT (Cur->r2);  	} @@ -397,8 +416,8 @@ Draw_Fractal(/*ModeInfo * mi*/)  		for (Simi = F->Components, j = F->Nb_Simi; j; --j, Simi++) {  			if (Simi == Cur)  				continue; -			Transform(Simi, xo, yo, &x, &y); -			Trace(F, x, y); +			Transform (Simi, xo, yo, &x, &y); +			Trace (F, x, y);  		}  	} @@ -409,8 +428,8 @@ Draw_Fractal(/*ModeInfo * mi*/)  		if (F->dbuf != None) {  			XSetForeground(display, F->dbuf_gc, 0);  */ -			/* XDrawPoints(display, F->dbuf, F->dbuf_gc, F->Buffer1, F->Cur_Pt, -  				CoordModeOrigin); */ +	/* XDrawPoints(display, F->dbuf, F->dbuf_gc, F->Buffer1, F->Cur_Pt, * * * *  +	 * CoordModeOrigin); */  /*			XFillRectangle(display, F->dbuf, F->dbuf_gc, 0, 0,  				       F->Width, F->Height);  		} else @@ -440,18 +459,18 @@ Draw_Fractal(/*ModeInfo * mi*/)  IFSPoint * -draw_ifs(/*ModeInfo * mi*/ int *nbpt) +draw_ifs ( /* ModeInfo * mi */ int *nbpt)  { -	int         i; -	DBL         u, uu, v, vv, u0, u1, u2, u3; -	SIMI       *S, *S1, *S2, *S3, *S4; -	FRACTAL    *F; +	int     i; +	DBL     u, uu, v, vv, u0, u1, u2, u3; +	SIMI   *S, *S1, *S2, *S3, *S4; +	FRACTAL *F;  	if (Root == NULL) -	  return NULL; -	F = Root; /* [/\*MI_SCREEN(mi)*\/0]; */ +		return; +	F = Root;											/* [ */ /*MI_SCREEN(mi)*/ /* 0]; */  	if (F->Buffer1 == NULL) -	  return NULL; +		return;  	u = (DBL) (F->Count) * (DBL) (F->Speed) / 1000.0;  	uu = u * u; @@ -479,7 +498,7 @@ draw_ifs(/*ModeInfo * mi*/ int *nbpt)  	/* MI_IS_DRAWN(mi) = True; */ -	Draw_Fractal(/*mi*/); +	Draw_Fractal ( /* mi */ );  	if (F->Count >= 1000 / F->Speed) {  		S = F->Components; @@ -498,12 +517,13 @@ draw_ifs(/*ModeInfo * mi*/ int *nbpt)  			*S1 = *S4;  		} -		Random_Simis(F, F->Components + 3 * F->Nb_Simi, F->Nb_Simi); +		Random_Simis (F, F->Components + 3 * F->Nb_Simi, F->Nb_Simi); -		Random_Simis(F, F->Components + 4 * F->Nb_Simi, F->Nb_Simi); +		Random_Simis (F, F->Components + 4 * F->Nb_Simi, F->Nb_Simi);  		F->Count = 0; -	} else +	} +	else  		F->Count++;  	F->Col++; @@ -518,12 +538,12 @@ draw_ifs(/*ModeInfo * mi*/ int *nbpt)  /***************************************************************/  void -release_ifs() +release_ifs ()  { -  if (Root != NULL) { -	(void) free((void *) Root); -	Root = (FRACTAL *) NULL; -  } +	if (Root != NULL) { +		(void) free ((void *) Root); +		Root = (FRACTAL *) NULL; +	}  } -/* #endif /\* MODE_ifs *\/ */ +/*#endif  */ /* MODE_ifs */ diff --git a/src/post/goom/ifs.h b/src/post/goom/ifs.h index 0b3cca3aa..c91df183a 100644 --- a/src/post/goom/ifs.h +++ b/src/post/goom/ifs.h @@ -7,28 +7,29 @@  #include "goom_config.h" -typedef struct _ifsPoint { -  gint16 x,y; -} IFSPoint; +typedef struct _ifsPoint +{ +	gint32  x, y; +} +IFSPoint; -/*  init ifs for a (width)x(height) output. */ -void init_ifs (int width, int height); +/* init ifs for a (width)x(height) output. */ +void    init_ifs (int width, int height); -/* - *  draw an ifs on the buffer (which size is width * height) - *  increment means that we draw 1/increment of the ifs's points - */ -void ifs_update (guint32 *buffer, guint32 *back, int width, int height, int increment); +/* draw an ifs on the buffer (which size is width * height) */ +/* increment means that we draw 1/increment of the ifs's points */ +void    ifs_update (guint32 * buffer, guint32 * back, int width, int height, +										int increment); -/*  free all ifs's data. */ -void release_ifs (); +/* free all ifs's data. */ +void    release_ifs ();  /* DONT USE !!! deprecated   * return a an array of points.   * WARNING !!! do not free it !!! it also has an internal use..   */ -IFSPoint * draw_ifs (int * nbPoints); +IFSPoint *draw_ifs (int *nbPoints);  #endif diff --git a/src/post/goom/ifs_display.c b/src/post/goom/ifs_display.c index 94d79b7eb..9c43ff5dd 100644 --- a/src/post/goom/ifs_display.c +++ b/src/post/goom/ifs_display.c @@ -1,216 +1,292 @@ -#include <stdlib.h>  #include "ifs.h" +#include "goom_config.h" -#define DRAWMETHOD_NORMAL data[pos] = couleur - -#define DRAWMETHOD_PLUS(x) \ -{\ -  int tra=0,i=0;\ -  unsigned char *bra = (unsigned char*)&back[pos];\ -  unsigned char *dra = (unsigned char*)&data[pos];\ -  unsigned char *cra = (unsigned char*)&couleur;\ -  for (;i<4;i++) {\ -	tra = *cra >> x;\ -	tra += *bra;\ -	if (tra>255) tra=255;\ -	*dra = tra;\ -	++dra;++cra;++bra;\ -  }\ +extern volatile int     use_asm; + +#ifdef MMX +void +ifs_fun_mmx(guint32 * data, guint32 * back, int width, int height, +            int increment, int nbpt, IFSPoint *points, int couleursl) +{ +	int i; +	for (i = 0; i < nbpt; i += increment) { +		int     x = points[i].x; +		int     y = points[i].y; + +		if ((x < width) && (y < height) && (x > 0) && (y > 0)) { +			int     pos = x + (y * width); +			register int b asm ("eax"); + +			b = back[pos]; +			__asm__ +				(" +				 movd %%eax, %%mm0 +				 movd %%edx, %%mm1 +				 paddusb %%mm1, %%mm0 +				 movd %%mm0, %%eax +				 ":: +				 "edx" (couleursl)); +			data[pos] = b; +		} +	} +	__asm__ __volatile__ ("emms");  } +#endif -#define DRAWMETHOD_OR data[pos]|=couleur +void +ifs_fun_c(guint32 * data, guint32 * back, int width, int height, +          int increment, int nbpt, IFSPoint *points, int couleursl) +{ +	int i; +	for (i = 0; i < nbpt; i += increment) { +		int     x = (int) points[i].x & 0x7fffffff; +		int     y = (int) points[i].y & 0x7fffffff; -#define DRAWMETHOD_DEMI data[pos]=((back[pos]&0xfefefefe) + (couleur & 0xfefefefe)) >> 1 +		if ((x < width) && (y < height)) { +			int     pos = x + (int) (y * width); +			int     tra = 0, i = 0; +			unsigned char *bra = (unsigned char *) &back[pos]; +			unsigned char *dra = (unsigned char *) &data[pos]; +			unsigned char *cra = (unsigned char *) &couleursl; -#define DRAWMETHOD(x) {DRAWMETHOD_DEMI;DRAWMETHOD_PLUS(x);} +			for (; i < 4; i++) { +				tra = *cra; +				tra += *bra; +				if (tra > 255) +					tra = 255; +				*dra = tra; +				++dra; +				++cra; +				++bra; +			} +		} +	} +} -void ifs_update (guint32 *data, guint32 *back, int width, int height, int increment) +void +ifs_update (guint32 * data, guint32 * back, int width, int height, +						int increment)  { -  static int couleur = 0xc0c0c0c0; -  static int v[4] = {2,4,3,2}; -  static int col[4] = {2,4,3,2}; +	static int couleur = 0xc0c0c0c0; +	static int v[4] = { 2, 4, 3, 2 }; +	static int col[4] = { 2, 4, 3, 2 }; +  #define MOD_MER 0  #define MOD_FEU 1  #define MOD_MERVER 2 -  static int mode = MOD_MERVER; -  static int justChanged = 0; -  static int cycle = 0; -  int cycle10; -   -  int nbpt; -  IFSPoint *points; -  int i; - -  points = draw_ifs (&nbpt); - -  cycle ++; -  if (cycle < 40) { -    cycle10 = cycle / 10; -    for (i = 0; i < nbpt; i+=increment) { -      int x = (int)points[i].x & 0x7fffffff; -      int y = (int)points[i].y & 0x7fffffff; -      if ((x < width) && (y < height)) { -	int pos = x + (int)(y * width); -	DRAWMETHOD(cycle10); -      } -    } -  } -  else { -    cycle10 = 7 - cycle / 10; -    for (i = 0; i < nbpt; i+=increment) { -      int x = (int)points[i].x & 0x7fffffff; -      int y = (int)points[i].y & 0x7fffffff; -      if ((x < width) && (y < height)) { -	int pos = x + (int)(y * width); -	DRAWMETHOD(cycle10); -      } -    } -    if (cycle >= 79) -      cycle = 0; -  } -   - -  justChanged --; -   -  col[ALPHA] = couleur >> (ALPHA*8) & 0xff; -  col[BLEU] = couleur >> (BLEU*8) & 0xff; -  col[VERT] = couleur >> (VERT*8) & 0xff; -  col[ROUGE] = couleur >> (ROUGE*8) & 0xff; - -  if (mode == MOD_MER) { -	col[BLEU] += v[BLEU]; -	if (col[BLEU]>255) { -	  col[BLEU]=255; v[BLEU] = - (rand () % 4) - 1; -	} -	if (col[BLEU]<32) { -	  col[BLEU]=32; v[BLEU] = (rand () % 4) + 1; -	} -	 -	col[VERT] += v[VERT]; -	if (col[VERT]>200) { -	  col[VERT]=200; v[VERT] = - (rand () % 3) - 2; -	} -	if (col[VERT]>col[BLEU]) { -	  col[VERT]=col[BLEU]; v[VERT] = v[BLEU]; -	} -	if (col[VERT]<32) { -	  col[VERT]=32; v[VERT] = (rand () % 3) + 2; -	} -	 -	col[ROUGE] += v[ROUGE]; -	if (col[ROUGE]>64) { -	  col[ROUGE]=64; v[ROUGE] = - (rand () % 4) - 1; -	} -	if (col[ROUGE]<0) { -	  col[ROUGE]=0; v[ROUGE] = (rand () % 4) + 1; -	} +	static int mode = MOD_MERVER; +	static int justChanged = 0; +	static int cycle = 0; +	int     cycle10; -  col[ALPHA] += v[ALPHA]; -  if (col[ALPHA]>0) { -	col[ALPHA]=0; v[ALPHA] = - (rand () % 4) - 1; -  } -  if (col[ALPHA]<0) { -	col[ALPHA]=0; v[ALPHA] = (rand () % 4) + 1; -  } -   -	if (((col [VERT] > 32) && (col[ROUGE]<col[VERT] + 40) && (col[VERT]<col[ROUGE] + 20) && (col [BLEU] < 64) -		 && (rand () % 20 == 0)) && (justChanged < 0)) { -	  mode = rand()%3?MOD_FEU:MOD_MERVER; -	  justChanged = 250; -	} -  } -  else if (mode == MOD_MERVER) { -	col[BLEU] += v[BLEU]; -	if (col[BLEU]>128) { -	  col[BLEU]=128; v[BLEU] = - (rand () % 4) - 1; -	} -	if (col[BLEU]<16) { -	  col[BLEU]=16; v[BLEU] = (rand () % 4) + 1; -	} -	 -	col[VERT] += v[VERT]; -	if (col[VERT]>200) { -	  col[VERT]=200; v[VERT] = - (rand () % 3) - 2; -	} -	if (col[VERT]>col[ALPHA]) { -	  col[VERT]=col[ALPHA]; v[VERT] = v[ALPHA]; -	} -	if (col[VERT]<32) { -	  col[VERT]=32; v[VERT] = (rand () % 3) + 2; -	} -	 -	col[ROUGE] += v[ROUGE]; -	if (col[ROUGE]>128) { -	  col[ROUGE]=128; v[ROUGE] = - (rand () % 4) - 1; -	} -	if (col[ROUGE]<0) { -	  col[ROUGE]=0; v[ROUGE] = (rand () % 4) + 1; -	} +	int     nbpt; +	IFSPoint *points; +	int     i; -	col[ALPHA] += v[ALPHA]; -	if (col[ALPHA]>255) { -	  col[ALPHA]=255; v[ALPHA] = - (rand () % 4) - 1; -	} -	if (col[ALPHA]<0) { -	  col[ALPHA]=0; v[ALPHA] = (rand () % 4) + 1; -	}	 - -	if (((col [VERT] > 32) && (col[ROUGE]<col[VERT] + 40) && (col[VERT]<col[ROUGE] + 20) && (col [BLEU] < 64) -		 && (rand () % 20 == 0)) && (justChanged < 0)) { -	  mode = rand()%3?MOD_FEU:MOD_MER; -	  justChanged = 250; -	} -  } -  else if (mode == MOD_FEU) { +	int     couleursl = couleur; -	col[BLEU] += v[BLEU]; -	if (col[BLEU]>64) { -	  col[BLEU]=64; v[BLEU] = - (rand () % 4) - 1; -	} -	if (col[BLEU]<0) { -	  col[BLEU]=0; v[BLEU] = (rand () % 4) + 1; -	} -	 -	col[VERT] += v[VERT]; -	if (col[VERT]>200) { -	  col[VERT]=200; v[VERT] = - (rand () % 3) - 2; -	} -	if (col[VERT]>col[ROUGE] + 20) { -	  col[VERT]=col[ROUGE] + 20; v[VERT] = - (rand () % 3) - 2; -	  v[ROUGE] = (rand () % 4) + 1; v[BLEU] = (rand () % 4) + 1; -	} -	if (col[VERT]<0) { -	  col[VERT]=0; v[VERT] = (rand () % 3) + 2; -	} -	 -	col[ROUGE] += v[ROUGE]; -	if (col[ROUGE]>255) { -	  col[ROUGE]=255; v[ROUGE] = - (rand () % 4) - 1; +	cycle++; +	if (cycle >= 80) +		cycle = 0; + +	if (cycle < 40) +		cycle10 = cycle / 10; +	else +		cycle10 = 7 - cycle / 10; + +	{ +		unsigned char *tmp = (unsigned char *) &couleursl; + +		for (i = 0; i < 4; i++) { +			*tmp = (*tmp) >> cycle10; +			tmp++; +		}  	} -	if (col[ROUGE]>col[VERT]+40) { -	  col[ROUGE]=col[VERT]+40; v[ROUGE] = - (rand () % 4) - 1; + +	points = draw_ifs (&nbpt); +	nbpt--; + +#ifdef MMX +	if (use_asm) +		ifs_fun_mmx(data, back, width, height, increment, nbpt, points, couleursl); +	else +		ifs_fun_c(data, back, width, height, increment, nbpt, points, couleursl); +#else +	ifs_fun_c(data, back, width, height, increment, nbpt, points, couleursl); +#endif /*MMX*/ +		justChanged--; + +	col[ALPHA] = couleur >> (ALPHA * 8) & 0xff; +	col[BLEU] = couleur >> (BLEU * 8) & 0xff; +	col[VERT] = couleur >> (VERT * 8) & 0xff; +	col[ROUGE] = couleur >> (ROUGE * 8) & 0xff; + +	if (mode == MOD_MER) { +		col[BLEU] += v[BLEU]; +		if (col[BLEU] > 255) { +			col[BLEU] = 255; +			v[BLEU] = -(rand () % 4) - 1; +		} +		if (col[BLEU] < 32) { +			col[BLEU] = 32; +			v[BLEU] = (rand () % 4) + 1; +		} + +		col[VERT] += v[VERT]; +		if (col[VERT] > 200) { +			col[VERT] = 200; +			v[VERT] = -(rand () % 3) - 2; +		} +		if (col[VERT] > col[BLEU]) { +			col[VERT] = col[BLEU]; +			v[VERT] = v[BLEU]; +		} +		if (col[VERT] < 32) { +			col[VERT] = 32; +			v[VERT] = (rand () % 3) + 2; +		} + +		col[ROUGE] += v[ROUGE]; +		if (col[ROUGE] > 64) { +			col[ROUGE] = 64; +			v[ROUGE] = -(rand () % 4) - 1; +		} +		if (col[ROUGE] < 0) { +			col[ROUGE] = 0; +			v[ROUGE] = (rand () % 4) + 1; +		} + +		col[ALPHA] += v[ALPHA]; +		if (col[ALPHA] > 0) { +			col[ALPHA] = 0; +			v[ALPHA] = -(rand () % 4) - 1; +		} +		if (col[ALPHA] < 0) { +			col[ALPHA] = 0; +			v[ALPHA] = (rand () % 4) + 1; +		} + +		if (((col[VERT] > 32) && (col[ROUGE] < col[VERT] + 40) +				 && (col[VERT] < col[ROUGE] + 20) && (col[BLEU] < 64) +				 && (rand () % 20 == 0)) && (justChanged < 0)) { +			mode = rand () % 3 ? MOD_FEU : MOD_MERVER; +			justChanged = 250; +		}  	} -	if (col[ROUGE]<0) { -	  col[ROUGE]=0; v[ROUGE] = (rand () % 4) + 1; +	else if (mode == MOD_MERVER) { +		col[BLEU] += v[BLEU]; +		if (col[BLEU] > 128) { +			col[BLEU] = 128; +			v[BLEU] = -(rand () % 4) - 1; +		} +		if (col[BLEU] < 16) { +			col[BLEU] = 16; +			v[BLEU] = (rand () % 4) + 1; +		} + +		col[VERT] += v[VERT]; +		if (col[VERT] > 200) { +			col[VERT] = 200; +			v[VERT] = -(rand () % 3) - 2; +		} +		if (col[VERT] > col[ALPHA]) { +			col[VERT] = col[ALPHA]; +			v[VERT] = v[ALPHA]; +		} +		if (col[VERT] < 32) { +			col[VERT] = 32; +			v[VERT] = (rand () % 3) + 2; +		} + +		col[ROUGE] += v[ROUGE]; +		if (col[ROUGE] > 128) { +			col[ROUGE] = 128; +			v[ROUGE] = -(rand () % 4) - 1; +		} +		if (col[ROUGE] < 0) { +			col[ROUGE] = 0; +			v[ROUGE] = (rand () % 4) + 1; +		} + +		col[ALPHA] += v[ALPHA]; +		if (col[ALPHA] > 255) { +			col[ALPHA] = 255; +			v[ALPHA] = -(rand () % 4) - 1; +		} +		if (col[ALPHA] < 0) { +			col[ALPHA] = 0; +			v[ALPHA] = (rand () % 4) + 1; +		} + +		if (((col[VERT] > 32) && (col[ROUGE] < col[VERT] + 40) +				 && (col[VERT] < col[ROUGE] + 20) && (col[BLEU] < 64) +				 && (rand () % 20 == 0)) && (justChanged < 0)) { +			mode = rand () % 3 ? MOD_FEU : MOD_MER; +			justChanged = 250; +		}  	} +	else if (mode == MOD_FEU) { + +		col[BLEU] += v[BLEU]; +		if (col[BLEU] > 64) { +			col[BLEU] = 64; +			v[BLEU] = -(rand () % 4) - 1; +		} +		if (col[BLEU] < 0) { +			col[BLEU] = 0; +			v[BLEU] = (rand () % 4) + 1; +		} + +		col[VERT] += v[VERT]; +		if (col[VERT] > 200) { +			col[VERT] = 200; +			v[VERT] = -(rand () % 3) - 2; +		} +		if (col[VERT] > col[ROUGE] + 20) { +			col[VERT] = col[ROUGE] + 20; +			v[VERT] = -(rand () % 3) - 2; +			v[ROUGE] = (rand () % 4) + 1; +			v[BLEU] = (rand () % 4) + 1; +		} +		if (col[VERT] < 0) { +			col[VERT] = 0; +			v[VERT] = (rand () % 3) + 2; +		} + +		col[ROUGE] += v[ROUGE]; +		if (col[ROUGE] > 255) { +			col[ROUGE] = 255; +			v[ROUGE] = -(rand () % 4) - 1; +		} +		if (col[ROUGE] > col[VERT] + 40) { +			col[ROUGE] = col[VERT] + 40; +			v[ROUGE] = -(rand () % 4) - 1; +		} +		if (col[ROUGE] < 0) { +			col[ROUGE] = 0; +			v[ROUGE] = (rand () % 4) + 1; +		} + +		col[ALPHA] += v[ALPHA]; +		if (col[ALPHA] > 0) { +			col[ALPHA] = 0; +			v[ALPHA] = -(rand () % 4) - 1; +		} +		if (col[ALPHA] < 0) { +			col[ALPHA] = 0; +			v[ALPHA] = (rand () % 4) + 1; +		} -  col[ALPHA] += v[ALPHA]; -  if (col[ALPHA]>0) { -	col[ALPHA]=0; v[ALPHA] = - (rand () % 4) - 1; -  } -  if (col[ALPHA]<0) { -	col[ALPHA]=0; v[ALPHA] = (rand () % 4) + 1; -  } -   -	if (((col [ROUGE] < 64) && (col [VERT] > 32) && (col [VERT] < col [BLEU]) && (col [BLEU] > 32) -		&& (rand () % 20 == 0)) && (justChanged < 0)) { -	  mode = rand () % 2 ? MOD_MER : MOD_MERVER; -	  justChanged = 250; +		if (((col[ROUGE] < 64) && (col[VERT] > 32) && (col[VERT] < col[BLEU]) +				 && (col[BLEU] > 32) +				 && (rand () % 20 == 0)) && (justChanged < 0)) { +			mode = rand () % 2 ? MOD_MER : MOD_MERVER; +			justChanged = 250; +		}  	} -  } -  couleur = (col[ALPHA]<<(ALPHA*8)) -	|(col[BLEU]<<(BLEU*8)) -	|(col[VERT]<<(VERT*8)) -	|(col[ROUGE]<<(ROUGE*8)); +	couleur = (col[ALPHA] << (ALPHA * 8)) +		| (col[BLEU] << (BLEU * 8)) +		| (col[VERT] << (VERT * 8)) +		| (col[ROUGE] << (ROUGE * 8));  } diff --git a/src/post/goom/lines.c b/src/post/goom/lines.c index a988f342b..28c25d57e 100644 --- a/src/post/goom/lines.c +++ b/src/post/goom/lines.c @@ -12,454 +12,418 @@  #include <stdlib.h>  #include <stdio.h>  #include "goom_tools.h" +#include "drawmethods.h" -extern unsigned int resolx,c_resoly; - -#define DRAWMETHOD_NORMAL *p = col - -#define DRAWMETHOD_PLUS \ -{\ -  int dra=0,i=0;\ -  unsigned char *tra = (unsigned char*)p;\ -  unsigned char *cra = (unsigned char*)&col;\ -  for (;i<4;i++) {\ -	dra = *cra;\ -	dra += *tra;\ -	if (dra>255) dra=255;\ -	*tra = dra;\ -	++tra;++cra;\ -  }\ -} +extern unsigned int resolx, c_resoly; -#define DRAWMETHOD_DEMIPLUS \ -{\ -  int dra=0,i=0;\ -  unsigned char *tra = (unsigned char*)p;\ -  unsigned char *cra = (unsigned char*)&col;\ -  for (;i<4;i++) {\ -	dra = *cra >> 1;\ -	dra += *tra;\ -	if (dra>255) dra=255;\ -	*tra = dra;\ -	++tra;++cra;\ -  }\ -} +#define DRAWMETHOD DRAWMETHOD_PLUS(*p,*p,col) -#define DRAWMETHOD_OR *p|=col - -#define DRAWMETHOD {DRAWMETHOD_DEMIPLUS; DRAWMETHOD_OR;} - -static void draw_line (int *data, int x1,int y1,int x2,int y2, int col, int screenx, int screeny) { -   int x, y, dx, dy, yy, xx; -   int *p; -/*    DATA32 *p; */ -/*    DATA8 aaa, nr, ng, nb, rr, gg, bb, aa, na; */ - -   /* clip to top edge */ -   if ((y1 < 0) && (y2 < 0)) -      return; -   if (y1 < 0) -   { -      x1 += (y1 * (x1 - x2)) / (y2 - y1); -      y1 = 0; -   } -   if (y2 < 0) -   { -      x2 += (y2 * (x1 - x2)) / (y2 - y1); -      y2 = 0; -   } -   /* clip to bottom edge */ -   if ((y1 >= screeny) && (y2 >= screeny)) -      return; -   if (y1 >= screeny) -   { -      x1 -= ((screeny - y1) * (x1 - x2)) / (y2 - y1); -      y1 = screeny - 1; -   } -   if (y2 >= screeny) -   { -      x2 -= ((screeny - y2) * (x1 - x2)) / (y2 - y1); -      y2 = screeny - 1; -   } -   /* clip to left edge */ -   if ((x1 < 0) && (x2 < 0)) -      return; -   if (x1 < 0) -   { -      y1 += (x1 * (y1 - y2)) / (x2 - x1); -      x1 = 0; -   } -   if (x2 < 0) -   { -      y2 += (x2 * (y1 - y2)) / (x2 - x1); -      x2 = 0; -   } -   /* clip to right edge */ -   if ((x1 >= screenx) && (x2 >= screenx)) -      return; -   if (x1 >= screenx) -   { -      y1 -= ((screenx - x1) * (y1 - y2)) / (x2 - x1); -      x1 = screenx - 1; -   } -   if (x2 >= screenx) -   { -      y2 -= ((screenx - x2) * (y1 - y2)) / (x2 - x1); -      x2 = screenx - 1; -   } -   dx = x2 - x1; -   dy = y2 - y1; -   if (x1 > x2) -   { -      int tmp; - -      tmp = x1; -      x1 = x2; -      x2 = tmp; -      tmp = y1; -      y1 = y2; -      y2 = tmp; -      dx = x2 - x1; -      dy = y2 - y1; -   } -    -   /* vertical line */ -   if (dx == 0) -	 { -	   if (y1 < y2) -		 { -		   p = &(data[(screenx * y1) + x1]); -		   for (y = y1; y <= y2; y++) -			 { -			   DRAWMETHOD; -			   p += screenx; -			 } -		 } -	   else -		 { -		   p = &(data[(screenx * y2) + x1]); -		   for (y = y2; y <= y1; y++) -			 { -			   DRAWMETHOD; -			   p += screenx; -			 } -		 } -	   return; -	 } -   /* horizontal line */ -   if (dy == 0) -	 { -	   if (x1 < x2) -		 { -		   p = &(data[(screenx * y1) + x1]); -		   for (x = x1; x <= x2; x++) -			 { -			   DRAWMETHOD; -			   p++; -			 } -		   return; -		 } -	   else -		 { -		   p = &(data[(screenx * y1) + x2]); -		   for (x = x2; x <= x1; x++) -			 { -			   DRAWMETHOD; -			   p++; -			 } -		   return; -		 } -	 } -   /* 1    */ -   /*  \   */ -   /*   \  */ -   /*    2 */ -   if (y2 > y1) -	 { -	   /* steep */ -	   if (dy > dx) -		 { -		   dx = ((dx << 16) / dy); -		   x = x1 << 16; -		   for (y = y1; y <= y2; y++) -			 { -			   xx = x >> 16; -			   p = &(data[(screenx * y) + xx]); -			   DRAWMETHOD; -			   if (xx < (screenx - 1)) -                 { -				   p++; -/* 				   DRAWMETHOD; */ -                 } -			   x += dx; -			 } -		   return; -		 } -	   /* shallow */ -	   else -		 { -		   dy = ((dy << 16) / dx); -		   y = y1 << 16; -		   for (x = x1; x <= x2; x++) -			 { -			   yy = y >> 16; -			   p = &(data[(screenx * yy) + x]); -                 DRAWMETHOD; -                 if (yy < (screeny - 1)) -				   { -					 p += screeny; -/* 					 DRAWMETHOD; */ -				   } -                 y += dy; -			 } -		 } -	 } -   /*    2 */ -   /*   /  */ -   /*  /   */ -   /* 1    */ -   else -	 { -	   /* steep */ -	   if (-dy > dx) -		 { -		   dx = ((dx << 16) / -dy); -		   x = (x1 + 1) << 16; -		   for (y = y1; y >= y2; y--) -			 { -			   xx = x >> 16; -			   p = &(data[(screenx * y) + xx]); -			   DRAWMETHOD; -			   if (xx < (screenx - 1)) -                 { -				   p--; -/* 				   DRAWMETHOD; */ -                 } -			   x += dx; -			 } -		   return; -		 } -	   /* shallow */ -	   else -		 { -		   dy = ((dy << 16) / dx); -		   y = y1 << 16; -		   for (x = x1; x <= x2; x++) -			 { -			   yy = y >> 16; -			   p = &(data[(screenx * yy) + x]); -			   DRAWMETHOD; -			   if (yy < (screeny - 1)) -                 { -				   p += screeny; -/* 				   DRAWMETHOD; */ -                 } -			   y += dy; -			 } -		   return; -		 } -	 } -} +static void +draw_line (int *data, int x1, int y1, int x2, int y2, int col, int screenx, +					 int screeny) +{ +	int     x, y, dx, dy, yy, xx, am, tmp; +	int    *p; + +/*   DATA32 *p; */ +/*   DATA8 aaa, nr, ng, nb, rr, gg, bb, aa, na; */ + +	/* clip to top edge */ +	if ((y1 < 0) && (y2 < 0)) +		return; +	if (y1 < 0) { +		x1 += (y1 * (x1 - x2)) / (y2 - y1); +		y1 = 0; +	} +	if (y2 < 0) { +		x2 += (y2 * (x1 - x2)) / (y2 - y1); +		y2 = 0; +	} +	/* clip to bottom edge */ +	if ((y1 >= screeny) && (y2 >= screeny)) +		return; +	if (y1 >= screeny) { +		x1 -= ((screeny - y1) * (x1 - x2)) / (y2 - y1); +		y1 = screeny - 1; +	} +	if (y2 >= screeny) { +		x2 -= ((screeny - y2) * (x1 - x2)) / (y2 - y1); +		y2 = screeny - 1; +	} +	/* clip to left edge */ +	if ((x1 < 0) && (x2 < 0)) +		return; +	if (x1 < 0) { +		y1 += (x1 * (y1 - y2)) / (x2 - x1); +		x1 = 0; +	} +	if (x2 < 0) { +		y2 += (x2 * (y1 - y2)) / (x2 - x1); +		x2 = 0; +	} +	/* clip to right edge */ +	if ((x1 >= screenx) && (x2 >= screenx)) +		return; +	if (x1 >= screenx) { +		y1 -= ((screenx - x1) * (y1 - y2)) / (x2 - x1); +		x1 = screenx - 1; +	} +	if (x2 >= screenx) { +		y2 -= ((screenx - x2) * (y1 - y2)) / (x2 - x1); +		x2 = screenx - 1; +	} +	dx = x2 - x1; +	dy = y2 - y1; +	if (x1 > x2) { +		int     tmp; + +		tmp = x1; +		x1 = x2; +		x2 = tmp; +		tmp = y1; +		y1 = y2; +		y2 = tmp; +		dx = x2 - x1; +		dy = y2 - y1; +	} -void genline (int id, float param, GMUnitPointer *l, int rx, int ry) { -  int i; -  switch (id) { -  case GML_HLINE: -	for (i = 0; i < 512; i++) { -	  l [i].x = ((float)i * rx) / 512.0f; -	  l [i].y = param; -	  l [i].angle = M_PI / 2.0f; +	/* vertical line */ +	if (dx == 0) { +		if (y1 < y2) { +			p = &(data[(screenx * y1) + x1]); +			for (y = y1; y <= y2; y++) { +				DRAWMETHOD; +				p += screenx; +			} +		} +		else { +			p = &(data[(screenx * y2) + x1]); +			for (y = y2; y <= y1; y++) { +				DRAWMETHOD; +				p += screenx; +			} +		} +		return;  	} -	return; -  case GML_VLINE: -	for (i = 0; i < 512; i++) { -	  l [i].y = ((float)i * ry) / 512.0f; -	  l [i].x = param; -	  l [i].angle = 0.0f; +	/* horizontal line */ +	if (dy == 0) { +		if (x1 < x2) { +			p = &(data[(screenx * y1) + x1]); +			for (x = x1; x <= x2; x++) { +				DRAWMETHOD; +				p++; +			} +			return; +		} +		else { +			p = &(data[(screenx * y1) + x2]); +			for (x = x2; x <= x1; x++) { +				DRAWMETHOD; +				p++; +			} +			return; +		} +	} +	/* 1    */ +	/* \   */ +	/* \  */ +	/* 2 */ +	if (y2 > y1) { +		/* steep */ +		if (dy > dx) { +			dx = ((dx << 16) / dy); +			x = x1 << 16; +			for (y = y1; y <= y2; y++) { +				xx = x >> 16; +				p = &(data[(screenx * y) + xx]); +				DRAWMETHOD; +				if (xx < (screenx - 1)) { +					p++; +/*                                 DRAWMETHOD; */ +				} +				x += dx; +			} +			return; +		} +		/* shallow */ +		else { +			dy = ((dy << 16) / dx); +			y = y1 << 16; +			for (x = x1; x <= x2; x++) { +				yy = y >> 16; +				p = &(data[(screenx * yy) + x]); +				DRAWMETHOD; +				if (yy < (screeny - 1)) { +					p += screeny; +/*                                       DRAWMETHOD; */ +				} +				y += dy; +			} +		} +	} +	/* 2 */ +	/* /  */ +	/* /   */ +	/* 1    */ +	else { +		/* steep */ +		if (-dy > dx) { +			dx = ((dx << 16) / -dy); +			x = (x1 + 1) << 16; +			for (y = y1; y >= y2; y--) { +				xx = x >> 16; +				p = &(data[(screenx * y) + xx]); +				DRAWMETHOD; +				if (xx < (screenx - 1)) { +					p--; +/*                                 DRAWMETHOD; */ +				} +				x += dx; +			} +			return; +		} +		/* shallow */ +		else { +			dy = ((dy << 16) / dx); +			y = y1 << 16; +			for (x = x1; x <= x2; x++) { +				yy = y >> 16; +				p = &(data[(screenx * yy) + x]); +				DRAWMETHOD; +				if (yy < (screeny - 1)) { +					p += screeny; +/*                                 DRAWMETHOD; */ +				} +				y += dy; +			} +			return; +		}  	} -	return; -  case GML_CIRCLE: -	  for (i = 0; i < 512; i++) { -		float cosa,sina; -		l [i].angle = 2.0f*M_PI*(float)i / 512.0f; -		cosa = param * cos(l[i].angle); -		sina = param * sin(l[i].angle); -		l [i].x = ((float)rx / 2.0f) + cosa; -		l [i].y = (float)ry / 2.0f + sina; -	  } -	return; -  }  } -guint32 getcouleur (int mode) { -  switch (mode) { -  case GML_RED: -	return (230 << (ROUGE * 8)) | (120 << (VERT * 8)); -  case GML_ORANGE_J: -	return (120 << (VERT * 8)) | (252 << (ROUGE * 8)); -  case GML_ORANGE_V: -	return (160 << (VERT * 8)) | (236 << (ROUGE * 8)) | (40 << (BLEU * 8)); -  case GML_BLEUBLANC: -	return (40 << (BLEU * 8)) | (220 << (ROUGE * 8)) | (140 << (VERT * 8)); -  case GML_VERT: -	return (200 << (VERT*8)) | (80 << (ROUGE*8)); -  case GML_BLEU: -	return (250 << (BLEU*8)) | (30 << (VERT*8)) | (80 << (ROUGE*8)); -  case GML_BLACK: -	return 0x10 << (BLEU*8); -  } -  return 0; +void +genline (int id, float param, GMUnitPointer * l, int rx, int ry) +{ +	int     i; + +	switch (id) { +	case GML_HLINE: +		for (i = 0; i < 512; i++) { +			l[i].x = ((float) i * rx) / 512.0f; +			l[i].y = param; +			l[i].angle = M_PI / 2.0f; +		} +		return; +	case GML_VLINE: +		for (i = 0; i < 512; i++) { +			l[i].y = ((float) i * ry) / 512.0f; +			l[i].x = param; +			l[i].angle = 0.0f; +		} +		return; +	case GML_CIRCLE: +		for (i = 0; i < 512; i++) { +			float   cosa, sina; + +			l[i].angle = 2.0f * M_PI * (float) i / 512.0f; +			cosa = param * cos (l[i].angle); +			sina = param * sin (l[i].angle); +			l[i].x = ((float) rx / 2.0f) + cosa; +			l[i].y = (float) ry / 2.0f + sina; +		} +		return; +	}  } -void goom_lines_set_res (GMLine *gml, int rx, int ry) { -  if (gml != NULL) { +guint32 getcouleur (int mode) +{ +	switch (mode) { +	case GML_RED: +		return (230 << (ROUGE * 8)) | (120 << (VERT * 8)); +	case GML_ORANGE_J: +		return (120 << (VERT * 8)) | (252 << (ROUGE * 8)); +	case GML_ORANGE_V: +		return (160 << (VERT * 8)) | (236 << (ROUGE * 8)) | (40 << (BLEU * 8)); +	case GML_BLEUBLANC: +		return (40 << (BLEU * 8)) | (220 << (ROUGE * 8)) | (140 << (VERT * 8)); +	case GML_VERT: +		return (200 << (VERT * 8)) | (80 << (ROUGE * 8)); +	case GML_BLEU: +		return (250 << (BLEU * 8)) | (30 << (VERT * 8)) | (80 << (ROUGE * 8)); +	case GML_BLACK: +		return 0x10 << (BLEU * 8); +	} +	return 0; +} -	gml->screenX = rx; -	gml->screenY = ry; +void +goom_lines_set_res (GMLine * gml, int rx, int ry) +{ +	if (gml != NULL) { +		int     i; + +		gml->screenX = rx; +		gml->screenY = ry; -	genline (gml->IDdest, gml->param, gml->points2, rx,ry); -  } +		genline (gml->IDdest, gml->param, gml->points2, rx, ry); +	}  } -void goom_lines_move (GMLine *l) { -  int i; -  unsigned char *c1,*c2; - -  for (i = 0; i < 512; i++) { -	l->points [i].x = (l->points2 [i].x + 39.0f * l->points [i].x) / 40.0f; -	l->points [i].y = (l->points2 [i].y + 39.0f * l->points [i].y) / 40.0f; -	l->points [i].angle = (l->points2 [i].angle + 39.0f * l->points [i].angle) / 40.0f; -  } - -  c1 = (unsigned char*)&l->color; -  c2 = (unsigned char*)&l->color2; -  for (i=0;i<4;i++) { -	int cc1,cc2; -	cc1 = *c1; -	cc2 = *c2; -	*c1 = (unsigned char) ((cc1 * 63 + cc2) >> 6 ); -	++c1;++c2; +void +goom_lines_move (GMLine * l) +{ +	int     i; +	unsigned char *c1, *c2; + +	for (i = 0; i < 512; i++) { +		l->points[i].x = (l->points2[i].x + 39.0f * l->points[i].x) / 40.0f; +		l->points[i].y = (l->points2[i].y + 39.0f * l->points[i].y) / 40.0f; +		l->points[i].angle = +			(l->points2[i].angle + 39.0f * l->points[i].angle) / 40.0f;  	} -  l->power += l->powinc; -  if (l->power < -1.6f) { -	l->power = -1.6f; -	l->powinc = (float)(iRAND(20) + 10) / 600.0f; -  } -  if (l->power > 1.0f) { -	l->power = 1.0f; -	l->powinc = - (float)(iRAND(20) + 10) / 600.0f; -  } +	c1 = (unsigned char *) &l->color; +	c2 = (unsigned char *) &l->color2; +	for (i = 0; i < 4; i++) { +		int     cc1, cc2; + +		cc1 = *c1; +		cc2 = *c2; +		*c1 = (unsigned char) ((cc1 * 63 + cc2) >> 6); +		++c1; +		++c2; +	} + +	l->power += l->powinc; +	if (l->power < -2.6f) { +		l->power = -2.6f; +		l->powinc = (float) (iRAND (20) + 10) / 600.0f; +	} +	if (l->power > 0.6f) { +		l->power = 0.6f; +		l->powinc = -(float) (iRAND (20) + 10) / 600.0f; +	}  } -void goom_lines_switch_to (GMLine *gml, int IDdest, float param, int col) { -  genline (IDdest, param, gml->points2, gml->screenX,gml->screenY); -  gml->IDdest = IDdest; -  gml->param = param; -  gml->color2 = getcouleur (col); -/*   printf ("couleur %d : %x\n",col,gml->color2); */ +void +goom_lines_switch_to (GMLine * gml, int IDdest, float param, int col) +{ +	genline (IDdest, param, gml->points2, gml->screenX, gml->screenY); +	gml->IDdest = IDdest; +	gml->param = param; +	gml->color2 = getcouleur (col); +/*  printf ("couleur %d : %x\n",col,gml->color2); */  } -inline unsigned char  lighten(unsigned char value,float power) +inline unsigned char +lighten (unsigned char value, float power)  { -  int val = value; -  float t = exp ((float)val / 64.0f) + power; -  if (t > 0) { -	val = (int)(64.0f * log (t)); -	if (val > 255) -	  val = 255; -	if (val < 0) -	  val=0; -	return val; -  } -  else { -	return 0; -  } +	int     val = value; +	float   t = exp ((float) val / 32.0f) + power; + +	if (t > 0) { +		val = (int) (32.0f * log (t)); +		if (val > 255) +			val = 255; +		if (val < 0) +			val = 0; +		return val; +	} +	else { +		return 0; +	}  } -void lightencolor (int *col, float power) { -  unsigned char *color; -  color = (unsigned char *)col; -  * color = lighten(*color,power); -  color++; -  * color = lighten(*color,power); -  color++;   -  * color = lighten(*color,power); -  color++;   -  * color = lighten(*color,power); +void +lightencolor (int *col, float power) +{ +	unsigned char *color; + +	color = (unsigned char *) col; +	*color = lighten (*color, power); +	color++; +	*color = lighten (*color, power); +	color++; +	*color = lighten (*color, power); +	color++; +	*color = lighten (*color, power);  } -GMLine* goom_lines_init (int rx,int ry, -						 int IDsrc, float paramS,int coulS, -						 int IDdest, float paramD, int coulD) +GMLine * +goom_lines_init (int rx, int ry, +								 int IDsrc, float paramS, int coulS, +								 int IDdest, float paramD, int coulD)  { +	int     i; +	unsigned char *color; +	unsigned char power = 4; -  GMLine *l = (GMLine*)malloc(sizeof(GMLine)); +	GMLine *l = (GMLine *) malloc (sizeof (GMLine)); -  l->points = (GMUnitPointer*)malloc(512*sizeof(GMUnitPointer)); -  l->points2 = (GMUnitPointer*)malloc(512*sizeof(GMUnitPointer)); -  l->nbPoints = 512; -   -  l->IDdest = IDdest; -  l->param = paramD; +	l->points = (GMUnitPointer *) malloc (512 * sizeof (GMUnitPointer)); +	l->points2 = (GMUnitPointer *) malloc (512 * sizeof (GMUnitPointer)); +	l->nbPoints = 512; -  genline (IDsrc, paramS, l->points, rx,ry); -  genline (IDdest, paramD, l->points2, rx,ry); -   -  l->color = getcouleur (coulS); -  l->color2 = getcouleur (coulD); +	l->IDdest = IDdest; +	l->param = paramD; -  l->screenX = rx; -  l->screenY = ry; +	genline (IDsrc, paramS, l->points, rx, ry); +	genline (IDdest, paramD, l->points2, rx, ry); -  l->power = 0.0f; -  l->powinc = 0.01f; +	l->color = getcouleur (coulS); +	l->color2 = getcouleur (coulD); -  goom_lines_switch_to (l, IDdest, paramD, coulD); +	l->screenX = rx; +	l->screenY = ry; -  return l; -} +	l->power = 0.0f; +	l->powinc = 0.01f; + +	goom_lines_switch_to (l, IDdest, paramD, coulD); -void goom_lines_free (GMLine **l) { -  free ((*l)->points); -  free (*l); -  l = NULL; +	return l;  } -void goom_lines_draw(GMLine *line, -		     gint16 data [512], -		     unsigned int* p) +void +goom_lines_free (GMLine ** l) +{ +	free ((*l)->points); +	free (*l); +	l = NULL; +} +void +goom_lines_draw (GMLine * line, gint16 data[512], unsigned int *p)  { -  if (line != NULL) { -	int i,x1,y1; -	guint32 color = line->color; -	GMUnitPointer *pt = &(line->points[0]); -	   -	float cosa = cos(pt->angle) / 1000.0f; -	float sina = sin(pt->angle) / 1000.0f; - -	lightencolor (&color, line->power); -	 -	x1 = (int) (pt->x + cosa * data[0]); -	y1 = (int) (pt->y + sina * data[0]); -	 -	for (i=1;i<512;i++) { -	  int x2,y2; -	  GMUnitPointer *pt = &(line->points[i]); -	   -	  float cosa = cos(pt->angle) / 1000.0f; -	  float sina = sin(pt->angle) / 1000.0f; -	   -	  x2 = (int) (pt->x + cosa * data[i]); -	  y2 = (int) (pt->y + sina * data[i]); -	   -	  draw_line (p, x1,y1,x2,y2,color,line->screenX,line->screenY); -	  x1=x2; -	  y1=y2; +	if (line != NULL) { +		int     i, x1, y1; +		guint32 color = line->color; +		GMUnitPointer *pt = &(line->points[0]); + +		float   cosa = cos (pt->angle) / 1000.0f; +		float   sina = sin (pt->angle) / 1000.0f; + +		lightencolor (&color, line->power); + +		x1 = (int) (pt->x + cosa * data[0]); +		y1 = (int) (pt->y + sina * data[0]); + +		for (i = 1; i < 512; i++) { +			int     x2, y2; +			GMUnitPointer *pt = &(line->points[i]); + +			float   cosa = cos (pt->angle) / 1000.0f; +			float   sina = sin (pt->angle) / 1000.0f; + +			x2 = (int) (pt->x + cosa * data[i]); +			y2 = (int) (pt->y + sina * data[i]); + +			draw_line (p, x1, y1, x2, y2, color, line->screenX, line->screenY); +			DRAWMETHOD_DONE (); +			x1 = x2; +			y1 = y2; +		} +		goom_lines_move (line);  	} -	goom_lines_move (line); -  }  } - diff --git a/src/post/goom/lines.h b/src/post/goom/lines.h index 24dcd4fc9..bb1b2e416 100644 --- a/src/post/goom/lines.h +++ b/src/post/goom/lines.h @@ -9,45 +9,49 @@  #include "graphic.h"  #include "goom_config.h" -typedef struct _GMUNITPOINTER { -  float x; -  float y; -  float angle; -} GMUnitPointer; - -/*  tableau de points */ -typedef struct _GMLINE { - -  GMUnitPointer *points; -  GMUnitPointer *points2; -  int IDdest; -  float param; - -  int nbPoints; -  guint32 color; /* pr l'instant je stocke la ouuleur -				  * a terme, on stockera le mode couleur.. et l'on animera -				  */ -  guint32 color2; - -  int screenX; -  int screenY; - -  float power; -  float powinc; -} GMLine; - -/*  les ID possibles */ +typedef struct _GMUNITPOINTER +{ +	float   x; +	float   y; +	float   angle; +} +GMUnitPointer; + +/* tableau de points */ +typedef struct _GMLINE +{ + +	GMUnitPointer *points; +	GMUnitPointer *points2; +	int     IDdest; +	float   param; + +	int     nbPoints; +	guint32 color;								/* pr l'instant je stocke la ouuleur * * a * +																 * * * terme, on stockera le mode couleur.. +																 * et * * * l'on animera */ +	guint32 color2; + +	int     screenX; +	int     screenY; + +	float   power; +	float   powinc; +} +GMLine; + +/* les ID possibles */  #define GML_CIRCLE 0 -/*  (param = radius) */ +/* (param = radius) */  #define GML_HLINE 1 -/*  (param = y) */ +/* (param = y) */  #define GML_VLINE 2 -/*  (param = x) */ +/* (param = x) */ -/*  les modes couleur possible (si tu mets un autre c'est noir) */ +/* les modes couleur possible (si tu mets un autre c'est noir) */  #define GML_BLEUBLANC 0  #define GML_RED 1 @@ -59,17 +63,17 @@ typedef struct _GMLINE {  /* construit un effet de line (une ligne horitontale pour commencer) */  GMLine *goom_lines_init (int rx, int ry, -						 int IDsrc, float paramS, int modeCoulSrc, -						 int IDdest, float paramD, int modeCoulDest); +												 int IDsrc, float paramS, int modeCoulSrc, +												 int IDdest, float paramD, int modeCoulDest); + +void    goom_lines_switch_to (GMLine * gml, int IDdest, float param, -void goom_lines_switch_to (GMLine *gml, int IDdest, float param, int modeCoul); +															int modeCoul); -void goom_lines_set_res (GMLine *gml, int rx, int ry); +void    goom_lines_set_res (GMLine * gml, int rx, int ry); -void goom_lines_free (GMLine **gml); +void    goom_lines_free (GMLine ** gml); -void goom_lines_draw (GMLine *gml, -					  gint16 data [512], -					  unsigned int* p); -/* void goom_lines_conf(gint16 config [25]); */ +void    goom_lines_draw (GMLine * gml, gint16 data[512], unsigned int *p); +/*void goom_lines_conf(gint16 config [25]); */ diff --git a/src/post/goom/ppc_zoom_ultimate.s b/src/post/goom/ppc_zoom_ultimate.s new file mode 100644 index 000000000..171f9674a --- /dev/null +++ b/src/post/goom/ppc_zoom_ultimate.s @@ -0,0 +1,149 @@ +.data +.text +.section regular,__DATA +.globl _ppc_zoom	;// name of the function to call by C program + +; notes : +; this routine dynamically computes and applies a zoom filter +; do not use r0, r1, r2 and r13 +; registers are not saved so the call to this function must be the last thing done in the calling C function + +; parameters : +; r3  <=> unsigned int * frompixmap +; r4  <=> unsigned int * topixmap +; r5  <=> unsigned int sizeX (in pixels) +; r6  <=> unsigned int sizeY (in pixels) +; r7  <=> unsigned int * brutS +; r8  <=> unsigned int * brutD +; r9  <=> unsigned int buffratio + +; globals after init +; r3  <=> frompixmap - 1 byte needed for preincremental fetch (replaces r3) +; r4  <=> topixmap - 1 byte needed for preincremental fetch (replaces r4) +; r5 <=> ax = x max in 16th of pixels (replaces old r5) +; r6 <=> ay = y max in 16th of pixels (replaces old r6) +; r15 <=> row size in bytes +; r16 <=> 0xFF00FF (mask for parallel 32 bits pixs computing) +; r30 <=> brutS - 1 byte needed for preincremental fetch (replaces r7) +; r31 <=> brutD - 1 byte needed for preincremental fetch (replaces r8) + + + +_ppc_zoom: + +; init +li      r16,0xFF +mullw   r17,r5,r6   ; number of pixels to compute +subi    r30,r8,4 +mulli	r15,r5,4 +slwi    r16,r16,16 +subi    r5,r5,1 +subi    r6,r6,1 +mtspr	ctr,r17     ; number of pixels to compute +subi    r31,r7,4 +subi    r4,r4,4 +ori     r16,r16,0xFF +mulli   r5,r5,16 +mulli   r6,r6,16 + + +boucle: + +; computes dynamically the position to fetch +lwzu	r8,4(r30)    ; px2 +lwzu	r17,4(r31)   ; px +lwzu	r10,4(r30)   ; py2 +lwzu	r29,4(r31)   ; py +sub     r8,r8,r17 +sub     r10,r10,r29 +mullw   r8,r8,r9 +mullw   r10,r10,r9 +srawi   r8,r8,16 +srawi   r10,r10,16 +add     r17,r17,r8 +add     r29,r29,r10 + + +; if px>ax or py>ay or px<0 or py <0 goto outofrange +cmpw 	cr1,r17,r5 +bgt-	cr1,outofrange +cmpwi 	cr1,r17,0 +blt-	cr1,outofrange +cmpw 	cr1,r29,r6 +bgt-	cr1,outofrange +cmpwi 	cr1,r29,0 +blt-	cr1,outofrange + + +; computes the attenuation coeffs +andi.   r8,r17,0x0F   ;coefh +andi.   r10,r29,0x0F  ;coefv +subfic  r18,r8,15     ;diffcoefh +subfic  r7,r10,15     ;diffcoefv +mullw   r21,r18,r7    ; coeff +mullw   r22,r8,r7     ; coeff << 8 +mullw   r23,r18,r10   ; coeff << 16 +mullw   r24,r8,r10    ; coeff << 24 + + +; calcul de l adresse du point d origine +srawi   r17,r17,4    ; pertedec +srawi   r29,r29,4    ; pertedec +srwi    r7,r15,2 +mullw   r29, r29,r7 +add     r17,r17,r29 +slwi    r17,r17,2 +add	r17,r17,r3 + + +; computes final pixel color +lwz	r25,0(r17)		; chargement de col1 ->r25 +and	r8, r25,r16 +lwz	r26,4(r17)		; chargement de col2 ->r26 +mullw	r8, r8, r21 +andi.	r18, r25,0xFF00 +add	r17,r17,r15 +and	r10, r26,r16 +mullw	r18, r18, r21 +lwz	r27,0(r17)		; chargement de col3 ->r27 +mullw	r10, r10, r22 +andi.	r29, r26, 0xFF00 +lwz	r28,4(r17)		; chargement de col4 ->r28 +add	r8, r8,r10 +mullw	r29, r29, r22 +and	r10, r27,r16 +add	r18, r18, r29 +mullw	r10, r10, r23 +andi.	r29, r27, 0xFF00 +add	r8, r8,r10 +mullw	r29, r29, r23 +and	r10, r28,r16 +add	r18, r18, r29 +mullw	r10, r10, r24 +andi.	r29, r28, 0xFF00 +add	r8, r8,r10 +mullw	r29, r29, r24 + +srawi	r7,r8,8 +add	r18, r18, r29 +and	r7, r7,r16 + +srawi	r18, r18, 8 +andi.   r18,r18,0xFF00 +or	r7, r18, r7 + +b       end ;goto end + + +; if out of range +outofrange: +li      r7,0 + +end: +stwu	r7, 4(r4) + + +bdnz+	boucle + + +blr diff --git a/src/post/goom/xine_goom.c b/src/post/goom/xine_goom.c index 34d204ae1..9be2aef6b 100644 --- a/src/post/goom/xine_goom.c +++ b/src/post/goom/xine_goom.c @@ -17,7 +17,7 @@   * along with this program; if not, write to the Free Software   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA   * - * $Id: xine_goom.c,v 1.14 2003/01/03 02:38:09 tmmm Exp $ + * $Id: xine_goom.c,v 1.15 2003/01/03 21:29:20 tmattern Exp $   *   * GOOM post plugin.   * @@ -28,20 +28,39 @@  #include <stdio.h> +#include "config.h"  #include "xine_internal.h"  #include "xineutils.h"  #include "post.h" +#include "goom_config.h"  #include "goom_core.h" -#define FPS 20 -#define DURATION 90000/FPS +#define FPS 10  #define GOOM_WIDTH  320  #define GOOM_HEIGHT 240 +/* colorspace conversion methods */ +const char * goom_csc_methods[]={ +  "Fast but not photorealistic", +  "Slow but looks better (mmx)", +  NULL +}; +  typedef struct post_plugin_goom_s post_plugin_goom_t; +typedef struct post_class_goom_s post_class_goom_t; + +struct post_class_goom_s { +  post_class_t class; + +  int width, height; +  int fps; +  int use_asm; +  int csc_method; +}; +  struct post_plugin_goom_s {    post_plugin_t post; @@ -49,6 +68,8 @@ struct post_plugin_goom_s {    xine_video_port_t *vo_port;    xine_stream_t     *stream; +  post_class_goom_t *class;   +      gint16 data [2][512];    int bits; @@ -105,17 +126,53 @@ static void goom_port_put_buffer (xine_audio_port_t *this, audio_buffer_t *buf,  static void *goom_init_plugin(xine_t *xine, void *data)  { -  post_class_t *class = (post_class_t *)malloc(sizeof(post_class_t)); -   -  if (!class) +  post_class_goom_t *this = (post_class_goom_t *)malloc(sizeof(post_class_goom_t)); +  config_values_t *cfg; + +  if (!this)      return NULL; -  class->open_plugin     = goom_open_plugin; -  class->get_identifier  = goom_get_identifier; -  class->get_description = goom_get_description; -  class->dispose         = goom_class_dispose; +  this->class.open_plugin     = goom_open_plugin; +  this->class.get_identifier  = goom_get_identifier; +  this->class.get_description = goom_get_description; +  this->class.dispose         = goom_class_dispose; +   +  cfg = xine->config; + +  this->fps = cfg->register_num (cfg, "post.goom_fps", FPS, +                                 _("Frames per second to generate with Goom"), +                                 NULL, 10, NULL, NULL); + +  this->width = cfg->register_num (cfg, "post.goom_width", GOOM_WIDTH, +                                   _("Goom image width in pixels"), +                                   NULL, 20, NULL, NULL); +   +  this->height = cfg->register_num (cfg, "post.goom_height", GOOM_HEIGHT, +                                    _("Goom image height in pixels"), +                                    NULL, 20, NULL, NULL); +   +#ifdef ARCH_X86 +  if (xine_mm_accel() & MM_ACCEL_X86_MMX) { +    this->use_asm = cfg->register_bool (cfg, "post.goom_use_asm", 1, +                                        _("Use Goom asm optimizations"), +                                        NULL, 10, NULL, NULL); +  } else { +    this->use_asm = 0; +  } +#endif -  return class; +#ifdef ARCH_PPC +  this->use_asm = cfg->register_bool (cfg, "post.goom_use_asm", 1, +                                      _("Use Goom asm optimizations"), +                                      NULL, 10, NULL, NULL); +#endif +   +  this->csc_method = cfg->register_enum (cfg, "post.goom_csc_method", 0, +                                         (char **)goom_csc_methods, +                                         _("Colorspace conversion method used by Goom"), +                                         NULL, 20, NULL, NULL); + +  return &this->class;  } @@ -128,7 +185,7 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs,    post_goom_out_t    *output = (post_goom_out_t *)malloc(sizeof(post_goom_out_t));    post_goom_out_t    *outputv = (post_goom_out_t *)malloc(sizeof(post_goom_out_t));    post_audio_port_t  *port; -   +    if (!this || !input || !output || !outputv || !video_target || !video_target[0] ||        !audio_target || !audio_target[0] ) {      free(this); @@ -138,7 +195,10 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs,      return NULL;    } -  goom_init (GOOM_WIDTH, GOOM_HEIGHT, 0); +  this->class = (post_class_goom_t *) class_gen; + +  goom_init (this->class->width, this->class->height, 0); +  goom_setAsmUse(this->class->use_asm);    this->sample_counter = 0;    this->stream  = NULL;    this->vo_port = video_target[0]; @@ -282,7 +342,7 @@ static int goom_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream,    this->bits = bits;    this->mode = mode;    this->channels = mode_channels(mode); -  this->samples_per_frame = rate / FPS; +  this->samples_per_frame = rate / this->class->fps;    this->sample_rate = rate;     this->stream = stream;    init_yuv_planes(&this->yuv, GOOM_WIDTH, GOOM_HEIGHT); @@ -336,9 +396,9 @@ static void goom_port_put_buffer (xine_audio_port_t *port_gen,        }      } -    goom_frame = (uint8_t *)goom_update (this->data, 0); +    goom_frame = (uint8_t *)goom_update (this->data, 0, 0, NULL, NULL); -    frame = this->vo_port->get_frame (this->vo_port, GOOM_WIDTH, GOOM_HEIGHT, +    frame = this->vo_port->get_frame (this->vo_port, this->class->width, this->class->height,                                        XINE_VO_ASPECT_SQUARE, XINE_IMGFMT_YUY2,                                        VO_BOTH_FIELDS);      frame->pts = buf->vpts; @@ -346,9 +406,10 @@ static void goom_port_put_buffer (xine_audio_port_t *port_gen,      /* Try to be fast */      dest_ptr = frame -> base[0]; -    goom_frame_end = goom_frame + 4 * (GOOM_WIDTH * GOOM_HEIGHT); +    goom_frame_end = goom_frame + 4 * (this->class->width * this->class->height); -    if (xine_mm_accel() & MM_ACCEL_X86_MMX) { +    if ((this->class->csc_method == 1) &&  +        (xine_mm_accel() & MM_ACCEL_X86_MMX)) {        int plane_ptr = 0;        while (goom_frame < goom_frame_end) { diff --git a/src/post/goom/zoom_filter_mmx.c b/src/post/goom/zoom_filter_mmx.c new file mode 100644 index 000000000..ff7a44214 --- /dev/null +++ b/src/post/goom/zoom_filter_mmx.c @@ -0,0 +1,119 @@ +#include "goom_config.h" +#ifdef MMX +#define BUFFPOINTNB 16 +#define BUFFPOINTMASK 0xffff +#define BUFFINCR 0xff + +#define sqrtperte 16 +/* faire : a % sqrtperte <=> a & pertemask */ +#define PERTEMASK 0xf +/* faire : a / sqrtperte <=> a >> PERTEDEC */ +#define PERTEDEC 4 + +void zoom_filter_mmx (int prevX, int prevY, +					  unsigned int *expix1, unsigned int *expix2, +					  int *brutS, int *brutD, int buffratio, +					  int precalCoef[16][16]) +{ +  unsigned int ax = (prevX-1)<<PERTEDEC, ay = (prevY-1)<<PERTEDEC; +   +  int bufsize = prevX * prevY; +  int loop; + +  __asm__ ("pxor %mm7,%mm7"); +   +  for (loop=0; loop<bufsize; loop++) +	{ +	  int couleur; +	  int px,py; +	  int pos; +	  int coeffs; + +	  int myPos = loop << 1, +		myPos2 = myPos + 1; +	  int brutSmypos = brutS[myPos]; +	   +	  px = brutSmypos + (((brutD[myPos] - brutSmypos)*buffratio) >> BUFFPOINTNB); +	  brutSmypos = brutS[myPos2]; +	  py = brutSmypos + (((brutD[myPos2] - brutSmypos)*buffratio) >> BUFFPOINTNB); +	   +	  if ((py>=ay) || (px>=ax)) { +		pos=coeffs=0; +	  } +	  else { +		pos = ((px >> PERTEDEC) + prevX * (py >> PERTEDEC)); +		/* coef en modulo 15 */ +		coeffs = precalCoef [px & PERTEMASK][py & PERTEMASK]; +	  } + +	  __asm__ __volatile__ (" +               movd %%eax,%%mm6 +			   ;/* recuperation des deux premiers pixels dans mm0 et mm1 */ +	   	       movq (%%edx,%%ebx,4), %%mm0		/* b1-v1-r1-a1-b2-v2-r2-a2 */ +			   movq %%mm0, %%mm1				/* b1-v1-r1-a1-b2-v2-r2-a2 */ +			    +			   ;/* depackage du premier pixel */ +			   punpcklbw %%mm7, %%mm0	/* 00-b2-00-v2-00-r2-00-a2 */ +			    +			   movq %%mm6, %%mm5			/* ??-??-??-??-c4-c3-c2-c1 */ +			   ;/* depackage du 2ieme pixel */ +			   punpckhbw %%mm7, %%mm1	/* 00-b1-00-v1-00-r1-00-a1 */ +							    +			   ;/* extraction des coefficients... */ +			   punpcklbw %%mm5, %%mm6	/* c4-c4-c3-c3-c2-c2-c1-c1 */ +			   movq %%mm6, %%mm4			/* c4-c4-c3-c3-c2-c2-c1-c1 */ +			   movq %%mm6, %%mm5			/* c4-c4-c3-c3-c2-c2-c1-c1 */ +											    +			   punpcklbw %%mm5, %%mm6	/* c2-c2-c2-c2-c1-c1-c1-c1 */ +			   punpckhbw %%mm5, %%mm4	/* c4-c4-c4-c4-c3-c3-c3-c3 */ + +			   movq %%mm6, %%mm3			/* c2-c2-c2-c2-c1-c1-c1-c1 */ +			   punpcklbw %%mm7, %%mm6	/* 00-c1-00-c1-00-c1-00-c1 */ +			   punpckhbw %%mm7, %%mm3	/* 00-c2-00-c2-00-c2-00-c2 */ +	 +			   ;/* multiplication des pixels par les coefficients */ +			   pmullw %%mm6, %%mm0		/* c1*b2-c1*v2-c1*r2-c1*a2 */ +			   pmullw %%mm3, %%mm1		/* c2*b1-c2*v1-c2*r1-c2*a1 */ +			   paddw %%mm1, %%mm0 +			    +			   ;/* ...extraction des 2 derniers coefficients */ +			   movq %%mm4, %%mm5			/* c4-c4-c4-c4-c3-c3-c3-c3 */ +			   punpcklbw %%mm7, %%mm4	/* 00-c3-00-c3-00-c3-00-c3 */ +			   punpckhbw %%mm7, %%mm5	/* 00-c4-00-c4-00-c4-00-c4 */ + +			   /* ajouter la longueur de ligne a esi */ +			   addl 8(%%ebp),%%ebx +	    +			   ;/* recuperation des 2 derniers pixels */ +			   movq (%%edx,%%ebx,4), %%mm1 +			   movq %%mm1, %%mm2 +			 +			   ;/* depackage des pixels */ +			   punpcklbw %%mm7, %%mm1 +			   punpckhbw %%mm7, %%mm2 +			 +			   ;/* multiplication pas les coeffs */ +			   pmullw %%mm4, %%mm1 +			   pmullw %%mm5, %%mm2 +			    +			   ;/* ajout des valeurs obtenues ŕ la valeur finale */ +			   paddw %%mm1, %%mm0 +			   paddw %%mm2, %%mm0 +			    +			   ;/* division par 256 = 16+16+16+16, puis repackage du pixel final */ +			   psrlw $8, %%mm0 +			   packuswb %%mm7, %%mm0 + +               movd %%mm0,%%eax +			   " +							:"=eax"(expix2[loop]) +							:"ebx"(pos),"eax"(coeffs),"edx"(expix1) +							 +				); +	   +/*	  expix2[loop] = couleur; */ +	   +	  __asm__ __volatile__ ("emms"); +	} +} +#endif | 
