EnttPong/src/libs/SDL2_gfx/SDL2_rotozoom.c
/*!

\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.

Rotates and zooms 8 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control 
parameters by scanning the destination surface.
Assumes src and dst surfaces are of 8 bit depth.
Assumes dst surface was allocated with the correct dimensions.

\param src Source surface.
\param dst Destination surface.
\param cx Horizontal center coordinate.
\param cy Vertical center coordinate.
\param isin Integer version of sine of angle.
\param icos Integer version of cosine of angle.
\param flipx Flag indicating horizontal mirroring should be applied.
\param flipy Flag indicating vertical mirroring should be applied.
*/
\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.
Rotates and zooms 8 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
parameters by scanning the destination surface.
Assumes src and dst surfaces are of 8 bit depth.
Assumes dst surface was allocated with the correct dimensions.

\param src Source surface.
\param dst Destination surface.
\param cx Horizontal center coordinate.
\param cy Vertical center coordinate.
\param isin Integer version of sine of angle.
\param icos Integer version of cosine of angle.
\param flipx Flag indicating horizontal mirroring should be applied.
\param flipy Flag indicating vertical mirroring should be applied.
\ brief Rotates and zooms 8 bit palette / Y ' src ' surface to ' dst ' surface without smoothing . Rotates and zooms 8 bit RGBA / ABGR ' src ' surface to ' dst ' surface based on the control parameters by scanning the destination surface . Assumes src and dst surfaces are of 8 bit depth . Assumes dst surface was allocated with the correct dimensions . \ param src Source surface . \ param dst Destination surface . \ param cx Horizontal center coordinate . \ param cy Vertical center coordinate . \ param isin Integer version of sine of angle . \ param icos Integer version of cosine of angle . \ param flipx Flag indicating horizontal mirroring should be applied . \ param flipy Flag indicating vertical mirroring should be applied .
void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
{
	int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay;
	tColorY *pc, *sp;
	int gap;
	xd = ((src->w - dst->w) << 15);
	yd = ((src->h - dst->h) << 15);
	ax = (cx << 16) - (icos * cx);
	ay = (cy << 16) - (isin * cx);
	pc = (tColorY*) dst->pixels;
	gap = dst->pitch - dst->w;
	memset(pc, (int)(_colorkey(src) & 0xff), dst->pitch * dst->h);
	for (y = 0; y < dst->h; y++) {
		dy = cy - y;
		sdx = (ax + (isin * dy)) + xd;
		sdy = (ay - (icos * dy)) + yd;
		for (x = 0; x < dst->w; x++) {
			dx = (short) (sdx >> 16);
			dy = (short) (sdy >> 16);
			if (flipx) dx = (src->w-1)-dx;
			if (flipy) dy = (src->h-1)-dy;
			if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
				sp = (tColorY *) (src->pixels);
				sp += (src->pitch * dy + dx);
				*pc = *sp;
			}
			sdx += icos;
			sdy += isin;
			pc++;
		}
		pc += gap;
	}
}
void transformSurfaceY ( SDL_Surface * src , SDL_Surface * dst , int cx , int cy , int isin , int icos , int flipx , int flipy ) { int x , y , dx , dy , xd , yd , sdx , sdy , ax , ay ; tColorY * pc , * sp ; int gap ; xd = ( ( src -> w - dst -> w ) << 15 ) ; yd = ( ( src -> h - dst -> h ) << 15 ) ; ax = ( cx << 16 ) - ( icos * cx ) ; ay = ( cy << 16 ) - ( isin * cx ) ; pc = ( tColorY * ) dst -> pixels ; gap = dst -> pitch - dst -> w ; memset ( pc , ( int ) ( _colorkey ( src ) & 0xff ) , dst -> pitch * dst -> h ) ; for ( y = 0 ; y < dst -> h ; y ++ ) { dy = cy - y ; sdx = ( ax + ( isin * dy ) ) + xd ; sdy = ( ay - ( icos * dy ) ) + yd ; for ( x = 0 ; x < dst -> w ; x ++ ) { dx = ( short ) ( sdx >> 16 ) ; dy = ( short ) ( sdy >> 16 ) ; if ( flipx ) dx = ( src -> w - 1 ) - dx ; if ( flipy ) dy = ( src -> h - 1 ) - dy ; if ( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < src -> w ) && ( dy < src -> h ) ) { sp = ( tColorY * ) ( src -> pixels ) ; sp += ( src -> pitch * dy + dx ) ; * pc = * sp ; } sdx += icos ; sdy += isin ; pc ++ ; } pc += gap ; } }
\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.
\ brief Rotates and zooms 8 bit palette / Y ' src ' surface to ' dst ' surface without smoothing .
/*
	* Variable setup 
	*/ /*
	* Clear surface to colorkey 
	*/ /*
	* Iterate through destination surface 
	*/