Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5130 → Rev 5131

/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_Circle.c
0,0 → 1,101
/*!
\file Draw_Circle.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#define SDL_DRAW_PUTPIXEL_BPP(A, B, C) \
*(##A##(##B##(Uint8*)super->pixels + (y0+y)*super->pitch + \
(x0+x)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0-y)*super->pitch + \
(x0+x)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0+y)*super->pitch + \
(x0-x)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0-y)*super->pitch + \
(x0-x)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0+x)*super->pitch + \
(x0+y)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0-x)*super->pitch + \
(x0+y)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0+x)*super->pitch + \
(x0-y)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0-x)*super->pitch + \
(x0-y)*SDL_DRAW_BPP)) = ##C##;
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP(0+,0+,color)
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint16*),0+,color)
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_PUTPIXEL_BPP(0+,1+,colorbyte1) \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte2) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte0) \
}else{ \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte0) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte2) \
}
 
#elif SDL_DRAW_BPP == 4
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color)
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0, Sint16 y0, Uint16 r,
Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
Sint16 x = 0;
Sint16 y = r-1; /*radius zero == draw nothing*/
Sint16 d = 3 - 2*r;
Sint16 diagonalInc = 10 - 4*r;
Sint16 rightInc = 6;
 
while (x <= y) {
 
SDL_DRAW_PUTPIXEL
 
if (d >= 0) {
d += diagonalInc;
diagonalInc += 8;
y -= 1;
} else {
d += rightInc;
diagonalInc += 4;
}
rightInc += 4;
x += 1;
}
 
}/*Draw_Circle*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_Ellipse.c
0,0 → 1,137
/*!
\file Draw_Ellipse.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#define SDL_DRAW_PUTPIXEL_BPP(A, B, C) \
*(##A##(##B##(Uint8*)super->pixels + (y0+y)*super->pitch + \
(x0+x)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0-y)*super->pitch + \
(x0+x)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0+y)*super->pitch + \
(x0-x)*SDL_DRAW_BPP)) = ##C##; \
*(##A##(##B##(Uint8*)super->pixels + (y0-y)*super->pitch + \
(x0-x)*SDL_DRAW_BPP)) = ##C##;
 
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP(0+,0+,color)
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint16*),0+,color)
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_PUTPIXEL_BPP(0+,1+,colorbyte1) \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte2) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte0) \
}else{ \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte0) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte2) \
}
 
#elif SDL_DRAW_BPP == 4
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color)
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0, Sint16 y0,
Uint16 Xradius, Uint16 Yradius,
Uint32 color)
{
Sint32 x, y;
Sint32 Xchange, Ychange;
Sint32 EllipseError;
Sint32 TwoASquare, TwoBSquare;
Sint32 StoppingX, StoppingY;
 
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
TwoASquare = 2*Xradius*Xradius;
TwoBSquare = 2*Yradius*Yradius;
 
/*1st set of points*/
x = Xradius-1; /*radius zero == draw nothing*/
y = 0;
 
Xchange = Yradius*Yradius*(1-2*Xradius);
Ychange = Xradius*Xradius;
 
EllipseError = 0;
 
StoppingX = TwoBSquare*Xradius;
StoppingY = 0;
 
/*Plot four ellipse points by iteration*/
while (StoppingX > StoppingY) {
 
SDL_DRAW_PUTPIXEL
 
++y;
StoppingY += TwoASquare;
EllipseError += Ychange;
Ychange += TwoASquare;
if (( 2*EllipseError + Xchange) > 0) {
--x;
StoppingX -= TwoBSquare;
EllipseError += Xchange;
Xchange += TwoBSquare;
}
}/*while*/
 
/*2nd set of points*/
x = 0;
y = Yradius-1; /*radius zero == draw nothing*/
Xchange = Yradius*Yradius;
Ychange = Xradius*Xradius*(1-2*Yradius);
EllipseError = 0;
StoppingX = 0;
StoppingY = TwoASquare*Yradius;
 
/*Plot four ellipse points by iteration*/
while (StoppingX < StoppingY) {
 
SDL_DRAW_PUTPIXEL
 
++x;
StoppingX += TwoBSquare;
EllipseError += Xchange;
Xchange += TwoBSquare;
if ((2*EllipseError + Ychange) > 0) {
--y;
StoppingY -= TwoASquare;
EllipseError += Ychange;
Ychange += TwoASquare;
}
}
 
}/*Draw_Ellipse*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_FillCircle.c
0,0 → 1,216
/*!
\file Draw_FillCircle.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL \
memset(p0, color, 2*x+1); \
memset(p1, color, 2*x+1); \
p0 = ((Uint8*)super->pixels+ (y0+x)*super->pitch+ (x0-y)); \
p1 = ((Uint8*)super->pixels+ (y0-x)*super->pitch+ (x0-y)); \
memset(p0, color, 2*y+1); \
memset(p1, color, 2*y+1);
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL \
i = 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 3: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 2: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 1: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
}while( (i-=4) > 0 ); \
} \
p0 = ((Uint8*)super->pixels+ (y0+x)*super->pitch+ (x0-y)*2); \
p1 = ((Uint8*)super->pixels+ (y0-x)*super->pitch+ (x0-y)*2); \
i = 2*y+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 3: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 2: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 1: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_BPP_3_AUX \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
p0[0] = colorbyte2; \
p0[1] = colorbyte1; \
p0[2] = colorbyte0; \
p1[0] = colorbyte2; \
p1[1] = colorbyte1; \
p1[2] = colorbyte0; \
} else { \
p0[0] = colorbyte0; \
p0[1] = colorbyte1; \
p0[2] = colorbyte2; \
p1[0] = colorbyte0; \
p1[1] = colorbyte1; \
p1[2] = colorbyte2; \
}
 
#define SDL_DRAW_PUTPIXEL \
i = 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 3: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 2: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 1: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
}while( (i-=4) > 0 ); \
} \
p0 = ((Uint8*)super->pixels+ (y0+x)*super->pitch+ (x0-y)*3); \
p1 = ((Uint8*)super->pixels+ (y0-x)*super->pitch+ (x0-y)*3); \
i = 2*y+1; \
switch( i % 4 ) { \
do{ \
case 0: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 3: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 2: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 1: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 4
 
#ifdef __linux__
#define SDL_DRAW_WMEMSET_START \
if (sizeof(wchar_t) == sizeof(Uint32)) { \
wmemset((wchar_t*)p0, color, 2*x+1); \
wmemset((wchar_t*)p1, color, 2*x+1); \
p0 = ((Uint8*)super->pixels+ (y0+x)*super->pitch+ (x0-y)*4); \
p1 = ((Uint8*)super->pixels+ (y0-x)*super->pitch+ (x0-y)*4); \
wmemset((wchar_t*)p0, color, 2*y+1); \
wmemset((wchar_t*)p1, color, 2*y+1); \
} else {
#define SDL_DRAW_WMEMSET_END }
#else
#define SDL_DRAW_WMEMSET_START
#define SDL_DRAW_WMEMSET_END
#endif
 
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_WMEMSET_START \
i = 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 3: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 2: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 1: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
}while( (i-=4) > 0 ); \
} \
p0 = ((Uint8*)super->pixels+ (y0+x)*super->pitch+ (x0-y)*4); \
p1 = ((Uint8*)super->pixels+ (y0-x)*super->pitch+ (x0-y)*4); \
i = 2*y+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 3: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 2: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 1: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
}while( (i-=4) > 0 ); \
} \
SDL_DRAW_WMEMSET_END
 
#endif /*SDL_DRAW_BPP*/
 
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0, Sint16 y0, Uint16 r,
Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
register Uint8 *p0;
register Uint8 *p1;
#if SDL_DRAW_BPP != 1
register Sint16 i;
#endif
 
Sint16 x = 0;
Sint16 y = r-1; /*radius zero == draw nothing*/
Sint16 d = 3 - 2*r;
Sint16 diagonalInc = 10 - 4*r;
Sint16 rightInc = 6;
 
while (x <= y) {
 
p0 = ((Uint8*)super->pixels+ (y0+y)*super->pitch+ (x0-x)*SDL_DRAW_BPP);
p1 = ((Uint8*)super->pixels+ (y0-y)*super->pitch+ (x0-x)*SDL_DRAW_BPP);
 
SDL_DRAW_PUTPIXEL
 
if (d >= 0) {
d += diagonalInc;
diagonalInc += 8;
y -= 1;
} else {
d += rightInc;
diagonalInc += 4;
}
rightInc += 4;
x += 1;
}
 
}/*Draw_FillCircle*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
 
#undef SDL_DRAW_WMEMSET_START
#undef SDL_DRAW_WMEMSET_END
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_FillEllipse.c
0,0 → 1,217
/*!
\file Draw_FillEllipse.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL \
memset(((Uint8*)super->pixels+ (y0+y)*super->pitch+ (x0-x)), \
color, 2*x+1); \
memset(((Uint8*)super->pixels+ (y0-y)*super->pitch+ (x0-x)), \
color, 2*x+1);
 
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL \
{ \
p0 = ((Uint8*)super->pixels+ (y0+y)*super->pitch+ (x0-x)*2); \
p1 = ((Uint8*)super->pixels+ (y0-y)*super->pitch+ (x0-x)*2); \
i = 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 3: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 2: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 1: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
}while( (i-=4) > 0 ); \
} \
}
 
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_BPP_3_AUX \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
p0[0] = colorbyte2; \
p0[1] = colorbyte1; \
p0[2] = colorbyte0; \
p1[0] = colorbyte2; \
p1[1] = colorbyte1; \
p1[2] = colorbyte0; \
} else { \
p0[0] = colorbyte0; \
p0[1] = colorbyte1; \
p0[2] = colorbyte2; \
p1[0] = colorbyte0; \
p1[1] = colorbyte1; \
p1[2] = colorbyte2; \
}
 
#define SDL_DRAW_PUTPIXEL \
{ \
p0 = ((Uint8*)super->pixels+ (y0+y)*super->pitch+ (x0-x)*3); \
p1 = ((Uint8*)super->pixels+ (y0-y)*super->pitch+ (x0-x)*3); \
i = 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 3: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 2: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 1: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
}while( (i-=4) > 0 ); \
} \
}
 
 
#elif SDL_DRAW_BPP == 4
 
#ifdef __linux__
#define SDL_DRAW_WMEMSET_START \
if (sizeof(wchar_t) == sizeof(Uint32)) { \
wmemset( (wchar_t*)((Uint8*)super->pixels+ (y0+y)*super->pitch+ (x0-x)*4), \
color, 2*x+1); \
wmemset( (wchar_t*)((Uint8*)super->pixels+ (y0-y)*super->pitch+ (x0-x)*4), \
color, 2*x+1); \
} else {
#define SDL_DRAW_WMEMSET_END }
#else
#define SDL_DRAW_WMEMSET_START
#define SDL_DRAW_WMEMSET_END
#endif
 
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_WMEMSET_START \
p0 = ((Uint8*)super->pixels+ (y0+y)*super->pitch+ (x0-x)*4); \
p1 = ((Uint8*)super->pixels+ (y0-y)*super->pitch+ (x0-x)*4); \
i = 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 3: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 2: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 1: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
}while( (i-=4) > 0 ); \
} \
SDL_DRAW_WMEMSET_END
 
#endif /*SDL_DRAW_BPP*/
 
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0, Sint16 y0,
Uint16 Xradius, Uint16 Yradius,
Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
#if SDL_DRAW_BPP != 1
register Uint8 *p0;
register Uint8 *p1;
register Sint16 i;
#endif
 
Sint32 x, y;
Sint32 Xchange, Ychange;
Sint32 EllipseError;
Sint32 TwoASquare, TwoBSquare;
Sint32 StoppingX, StoppingY;
 
TwoASquare = 2*Xradius*Xradius;
TwoBSquare = 2*Yradius*Yradius;
 
/*1st set of points*/
x = Xradius-1; /*radius zero == draw nothing*/
y = 0;
 
Xchange = Yradius*Yradius*(1-2*Xradius);
Ychange = Xradius*Xradius;
 
EllipseError = 0;
 
StoppingX = TwoBSquare*Xradius;
StoppingY = 0;
 
/*Plot 2 ellipse scan lines for iteration*/
while (StoppingX > StoppingY) {
 
SDL_DRAW_PUTPIXEL
 
++y;
StoppingY += TwoASquare;
EllipseError += Ychange;
Ychange += TwoASquare;
if (( 2*EllipseError + Xchange) > 0) {
--x;
StoppingX -= TwoBSquare;
EllipseError += Xchange;
Xchange += TwoBSquare;
}
}/*while*/
 
/*2nd set of points*/
x = 0;
y = Yradius-1; /*radius zero == draw nothing*/
Xchange = Yradius*Yradius;
Ychange = Xradius*Xradius*(1-2*Yradius);
EllipseError = 0;
StoppingX = 0;
StoppingY = TwoASquare*Yradius;
 
/*Plot 2 ellipse scan lines for iteration*/
while (StoppingX < StoppingY) {
 
SDL_DRAW_PUTPIXEL
 
++x;
StoppingX += TwoBSquare;
EllipseError += Xchange;
Xchange += TwoBSquare;
if ((2*EllipseError + Ychange) > 0) {
--y;
StoppingY -= TwoASquare;
EllipseError += Ychange;
Ychange += TwoASquare;
}
}
}/*Draw_FillEllipse*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
 
#undef SDL_DRAW_WMEMSET_START
#undef SDL_DRAW_WMEMSET_END
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_FillRound.c
0,0 → 1,248
/*!
\file Draw_FillRound.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL \
memset(p0, color, X2center - Xcenter + 2*corner+1); \
memset(p1, color, X2center - Xcenter + 2*corner+1); \
p0 = ((Uint8*)super->pixels+(Y2center+corner)*super->pitch+(Xcenter-x)); \
p1 = ((Uint8*)super->pixels+(Ycenter-corner)*super->pitch +(Xcenter-x)); \
memset(p0, color, X2center - Xcenter + 2*x+1); \
memset(p1, color, X2center - Xcenter + 2*x+1);
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL \
i = X2center - Xcenter + 2*corner+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 3: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 2: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 1: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
}while( (i-=4) > 0 ); \
} \
p0 = ((Uint8*)super->pixels+(Y2center+corner)*super->pitch+(Xcenter-x)*2); \
p1 = ((Uint8*)super->pixels+(Ycenter-corner)*super->pitch +(Xcenter-x)*2); \
i = X2center - Xcenter + 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 3: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 2: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
case 1: *(Uint16*)p0 = color; *(Uint16*)p1 = color; \
p0+=2; p1+=2; \
}while( (i-=4) > 0 ); \
}
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_BPP_3_AUX \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
p0[0] = colorbyte2; \
p0[1] = colorbyte1; \
p0[2] = colorbyte0; \
p1[0] = colorbyte2; \
p1[1] = colorbyte1; \
p1[2] = colorbyte0; \
} else { \
p0[0] = colorbyte0; \
p0[1] = colorbyte1; \
p0[2] = colorbyte2; \
p1[0] = colorbyte0; \
p1[1] = colorbyte1; \
p1[2] = colorbyte2; \
}
 
#define SDL_DRAW_PUTPIXEL \
i = X2center - Xcenter + 2*corner+1; \
switch( i % 4 ) { \
do{ \
case 0: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 3: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 2: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 1: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
}while( (i-=4) > 0 ); \
} \
p0 = ((Uint8*)super->pixels+(Y2center+corner)*super->pitch+(Xcenter-x)*3); \
p1 = ((Uint8*)super->pixels+(Ycenter-corner)*super->pitch +(Xcenter-x)*3); \
i = X2center - Xcenter + 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 3: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 2: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 1: SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 4
 
#ifdef __linux__
#define SDL_DRAW_WMEMSET_START \
if (sizeof(wchar_t) == sizeof(Uint32)) { \
wmemset((wchar_t*)p0, color, X2center - Xcenter + 2*corner+1); \
wmemset((wchar_t*)p1, color, X2center - Xcenter + 2*corner+1); \
p0 = ((Uint8*)super->pixels+(Y2center+corner)*super->pitch+(Xcenter-x)*4); \
p1 = ((Uint8*)super->pixels+(Ycenter-corner)*super->pitch +(Xcenter-x)*4); \
wmemset((wchar_t*)p0, color, X2center - Xcenter + 2*x+1); \
wmemset((wchar_t*)p1, color, X2center - Xcenter + 2*x+1); \
} else {
#define SDL_DRAW_WMEMSET_END }
#else
#define SDL_DRAW_WMEMSET_START
#define SDL_DRAW_WMEMSET_END
#endif
 
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_WMEMSET_START \
i = X2center - Xcenter + 2*corner+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 3: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 2: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 1: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
}while( (i-=4) > 0 ); \
} \
p0 = ((Uint8*)super->pixels+(Y2center+corner)*super->pitch+(Xcenter-x)*4); \
p1 = ((Uint8*)super->pixels+(Ycenter-corner)*super->pitch +(Xcenter-x)*4); \
i = X2center - Xcenter + 2*x+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 3: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 2: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
case 1: *(Uint32*)p0 = color; *(Uint32*)p1 = color; \
p0+=4; p1+=4; \
}while( (i-=4) > 0 ); \
} \
SDL_DRAW_WMEMSET_END
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0,Sint16 y0, Uint16 w,Uint16 h,
Uint16 corner, Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
register Uint8 *p0;
register Uint8 *p1;
#if SDL_DRAW_BPP != 1
register Sint16 i;
#endif
Sint16 dx, dy;
 
Sint16 Xcenter, Ycenter, X2center, Y2center;
 
Sint16 x = 0;
Sint16 rightInc = 6;
Sint16 d, diagonalInc;
 
SDL_Rect r;
 
 
if (w==0 || h==0) return;
 
/*TODO: We can do better :-)*/
if (corner!=0) {
d = w<h ? w : h;
--corner;
if (corner!=0 && corner+2 >= d ) {
if (corner+2 == d) --corner;
else corner = 0;
}
}
 
d = 3 - (corner<<1);
diagonalInc = 10 - (corner<<2);
 
/*Rectangles*/
dx = w - (corner<<1);
Xcenter = x0+corner;
dy = h - (corner<<1);
Ycenter = y0+corner;
 
/*Centers*/
X2center=Xcenter+dx-1;
Y2center=Ycenter+dy-1;
 
r.x = x0; r.y = Ycenter;
r.w = w; r.h = dy;
SDL_FillRect(super, &r, color);
 
while (x < corner) {
 
p0 = ((Uint8*)super->pixels+(Ycenter-x)*super->pitch +
(Xcenter-corner)*SDL_DRAW_BPP);
p1 = ((Uint8*)super->pixels+(Y2center+x)*super->pitch +
(Xcenter-corner)*SDL_DRAW_BPP);
 
SDL_DRAW_PUTPIXEL
 
if (d >= 0) {
d += diagonalInc;
diagonalInc += 8;
--corner;
} else {
d += rightInc;
diagonalInc += 4;
}
rightInc += 4;
++x;
}/*while*/
 
}/*Draw_FillRound*/
 
 
#undef SDL_DRAW_PUTPIXEL
 
#undef SDL_DRAW_WMEMSET_START
#undef SDL_DRAW_WMEMSET_END
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_HLine.c
0,0 → 1,117
/*!
\file Draw_HLine.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL \
memset(p, color, x1-x0+1);
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL \
i = x1-x0+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint16*)p = color; p+=2; \
case 3: *(Uint16*)p = color; p+=2; \
case 2: *(Uint16*)p = color; p+=2; \
case 1: *(Uint16*)p = color; p+=2; \
}while( (i-=4) > 0 ); \
}
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_BPP_3_AUX \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
p[0] = colorbyte2; \
p[1] = colorbyte1; \
p[2] = colorbyte0; \
} else { \
p[0] = colorbyte0; \
p[1] = colorbyte1; \
p[2] = colorbyte2; \
}
 
#define SDL_DRAW_PUTPIXEL \
i = x1-x0+1; \
switch( i % 4 ) { \
do{ \
case 0: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=3; \
case 3: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=3; \
case 2: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=3; \
case 1: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=3; \
}while( (i-=4) > 0 ); \
}
 
#elif SDL_DRAW_BPP == 4
 
#ifdef __linux__
#define SDL_DRAW_WMEMSET_START \
if (sizeof(wchar_t) == sizeof(Uint32)) { \
wmemset((wchar_t*)p, color, x1-x0+1); \
} else {
#define SDL_DRAW_WMEMSET_END }
#else
#define SDL_DRAW_WMEMSET_START
#define SDL_DRAW_WMEMSET_END
#endif
 
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_WMEMSET_START \
i = x1-x0+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint32*)p = color; p+=4; \
case 3: *(Uint32*)p = color; p+=4; \
case 2: *(Uint32*)p = color; p+=4; \
case 1: *(Uint32*)p = color; p+=4; \
}while( (i-=4) > 0 ); \
} \
SDL_DRAW_WMEMSET_END
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0,Sint16 y0, Sint16 x1,
Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
register Uint8 *p;
register Sint16 i;
 
if (x0 > x1) { i=x1; x1=x0; x0=i; }
p = (Uint8*)super->pixels + y0 * super->pitch + x0 * SDL_DRAW_BPP;
 
SDL_DRAW_PUTPIXEL
 
}/*Draw_HLine*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
 
#undef SDL_DRAW_WMEMSET_START
#undef SDL_DRAW_WMEMSET_END
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_Line.c
0,0 → 1,135
/*!
\file Draw_Line.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define SDL_DRAW_PUTPIXEL_BPP(A, B, C) \
*(##A##(##B##(Uint8*)super->pixels + y*super->pitch + x*SDL_DRAW_BPP))=##C##;
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP(0+,0+,color)
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint16*),0+,color)
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_PUTPIXEL_BPP(0+,1+,(Uint8)colorbyte1) \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,(Uint8)colorbyte2) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,(Uint8)colorbyte0) \
}else{ \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,(Uint8)colorbyte0) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,(Uint8)colorbyte2) \
}
 
#elif SDL_DRAW_BPP == 4
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color)
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
Sint16 x = x1;
Sint16 y = y1;
Sint16 dy = y2 - y1;
Sint16 dx = x2 - x1;
 
Sint16 G, DeltaG1, DeltaG2, minG, maxG;
Sint16 swap;
Sint16 inc = 1;
 
SDL_DRAW_PUTPIXEL
 
if (abs(dy) < abs(dx)) { /* -1 < ramp < 1 */
if (dx < 0) {
dx = -dx;
dy = -dy;
 
swap = y2;
y2 = y1;
y1 = swap;
 
swap = x2;
x2 = x1;
x1 = swap;
}
if (dy < 0) {
dy = -dy;
inc = -1;
}
 
G = 2 * dy - dx;
DeltaG1 = 2 * (dy - dx);
DeltaG2 = 2 * dy;
 
while (x++ < x2) {
if (G > 0) { G += DeltaG1; y += inc; }
else G += DeltaG2;
 
SDL_DRAW_PUTPIXEL
}/*while*/
 
} else { /* ramp < -1 or ramp > 1 */
if (dy < 0) {
dx = -dx;
dy = -dy;
 
swap = y2;
y2 = y1;
y1 = swap;
 
swap = x2;
x2 = x1;
x1 = swap;
}
if (dx < 0) {
dx = -dx;
inc = -1;
}
 
G = 2 * dx - dy;
minG = maxG = G;
DeltaG1 = 2 * (dx - dy);
DeltaG2 = 2 * dx;
 
while (y++ < y2) {
if (G > 0) { G += DeltaG1; x += inc; }
else G += DeltaG2;
 
SDL_DRAW_PUTPIXEL
}/*while*/
 
}/*if*/
 
}/*Draw_Line*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_Pixel.c
0,0 → 1,64
/*!
\file Draw_Pixel.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define SDL_DRAW_PUTPIXEL_BPP(A, B, C) \
*(##A##(##B##(Uint8*)super->pixels + y*super->pitch + x*SDL_DRAW_BPP))=##C##;
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP(0+,0+,(Uint8)color)
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint16*),0+,(Uint16)color)
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_PUTPIXEL_BPP(0+,1+,colorbyte1) \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte2) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte0) \
}else{ \
SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte0) \
SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte2) \
}
 
#elif SDL_DRAW_BPP == 4
#define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color)
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x, Sint16 y, Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
SDL_DRAW_PUTPIXEL
 
}/*Draw_Pixel*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_Rect.c
0,0 → 1,236
/*!
\file Draw_Rect.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL \
memset(p0, color, w); \
memset(p1, color, w); \
\
if (h<3) return; \
p0 = (Uint8*)super->pixels + (y+1)*super->pitch + x; \
p1 = (Uint8*)super->pixels + (y+1)*super->pitch + (x+w-1); \
i = h-2; \
switch( i % 4 ) { \
do{ \
case 0: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
case 3: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
case 2: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
case 1: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL \
i = w; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
case 3: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
case 2: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
case 1: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
}while( (i-=4) > 0 ); \
} \
if (h<3) return; \
p0 = (Uint8*)super->pixels + (y+1)*super->pitch + x*2; \
p1 = (Uint8*)super->pixels + (y+1)*super->pitch + (x+w-1)*2; \
i = h-2; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
case 3: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
case 2: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
case 1: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_BPP_3_AUX \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
p0[0] = colorbyte2; \
p0[1] = colorbyte1; \
p0[2] = colorbyte0; \
p1[0] = colorbyte2; \
p1[1] = colorbyte1; \
p1[2] = colorbyte0; \
} else { \
p0[0] = colorbyte0; \
p0[1] = colorbyte1; \
p0[2] = colorbyte2; \
p1[0] = colorbyte0; \
p1[1] = colorbyte1; \
p1[2] = colorbyte2; \
}
 
#define SDL_DRAW_PUTPIXEL \
i = w; \
switch( i % 4 ) { \
do{ \
case 0: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 3: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 2: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 1: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
}while( (i-=4) > 0 ); \
} \
if (h<3) return; \
p0 = (Uint8*)super->pixels + (y+1)*super->pitch + x*3; \
p1 = (Uint8*)super->pixels + (y+1)*super->pitch + (x+w-1)*3; \
i = h-2; \
switch( i % 4 ) { \
do{ \
case 0: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
case 3: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
case 2: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
case 1: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 4
 
#ifdef __linux__
#define SDL_DRAW_WMEMSET_START \
if (sizeof(wchar_t) == sizeof(Uint32)) { \
wmemset((wchar_t*)p0, color, w); \
wmemset((wchar_t*)p1, color, w); \
} else {
#define SDL_DRAW_WMEMSET_END }
#else
#define SDL_DRAW_WMEMSET_START
#define SDL_DRAW_WMEMSET_END
#endif
 
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_WMEMSET_START \
i = w; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
case 3: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
case 2: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
case 1: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
}while( (i-=4) > 0 ); \
} \
SDL_DRAW_WMEMSET_END \
if (h<3) return; \
p0 = (Uint8*)super->pixels + (y+1)*super->pitch + x*4; \
p1 = (Uint8*)super->pixels + (y+1)*super->pitch + (x+w-1)*4; \
i = h-2; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
case 3: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
case 2: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
case 1: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x, Sint16 y, Uint16 w, Uint16 h,
Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
register Uint8 *p0;
register Uint8 *p1;
register Sint16 i;
 
if (w==0 || h==0) return;
 
p0 = (Uint8*)super->pixels + y * super->pitch + x * SDL_DRAW_BPP;
p1 = (Uint8*)super->pixels + (y+h-1) * super->pitch + x * SDL_DRAW_BPP;
 
SDL_DRAW_PUTPIXEL
 
}/*Draw_Rect*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
 
#undef SDL_DRAW_WMEMSET_START
#undef SDL_DRAW_WMEMSET_END
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_Round.c
0,0 → 1,326
/*!
\file Draw_Round.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
/*Circle arcs*/
#define SDL_DRAW_PUTPIXEL_CIRCLE_BPP(A, B, C) \
*(##A##(##B##(Uint8*)super->pixels + (Ycenter-x)*super->pitch + \
(Xcenter - corner)*SDL_DRAW_BPP)) = C##; \
*(##A##(##B##(Uint8*)super->pixels + (Ycenter-corner)*super->pitch + \
(Xcenter - x)*SDL_DRAW_BPP)) = C##; \
*(##A##(##B##(Uint8*)super->pixels + (Ycenter-corner)*super->pitch + \
(X2center + x)*SDL_DRAW_BPP)) = C##; \
*(##A##(##B##(Uint8*)super->pixels + (Ycenter-x)*super->pitch + \
(X2center + corner)*SDL_DRAW_BPP)) = C##; \
*(##A##(##B##(Uint8*)super->pixels + (Y2center+corner)*super->pitch + \
(X2center + x)*SDL_DRAW_BPP)) = C##; \
*(##A##(##B##(Uint8*)super->pixels + (Y2center+x)*super->pitch + \
(X2center + corner)*SDL_DRAW_BPP)) = C##; \
*(##A##(##B##(Uint8*)super->pixels + (Y2center+corner)*super->pitch + \
(Xcenter - x)*SDL_DRAW_BPP)) = C##; \
*(##A##(##B##(Uint8*)super->pixels + (Y2center+x)*super->pitch + \
(Xcenter - corner)*SDL_DRAW_BPP)) = C##;
 
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL_CIRCLE SDL_DRAW_PUTPIXEL_CIRCLE_BPP(0+,0+,color)
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL_CIRCLE SDL_DRAW_PUTPIXEL_CIRCLE_BPP((Uint16*),0+,color)
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_CIRCLE \
SDL_DRAW_PUTPIXEL_CIRCLE_BPP(0+,1+,colorbyte1) \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
SDL_DRAW_PUTPIXEL_CIRCLE_BPP(0+,0+,colorbyte2) \
SDL_DRAW_PUTPIXEL_CIRCLE_BPP(0+,2+,colorbyte0) \
}else{ \
SDL_DRAW_PUTPIXEL_CIRCLE_BPP(0+,0+,colorbyte0) \
SDL_DRAW_PUTPIXEL_CIRCLE_BPP(0+,2+,colorbyte2) \
}
 
#elif SDL_DRAW_BPP == 4
#define SDL_DRAW_PUTPIXEL_CIRCLE SDL_DRAW_PUTPIXEL_CIRCLE_BPP((Uint32*),0+,color)
 
#endif /*SDL_DRAW_BPP*/
 
 
/*Rectangles*/
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL \
memset(p0, color, dx); \
memset(p1, color, dx); \
\
if (h<3) return; \
p0 = (Uint8*)super->pixels + Ycenter*super->pitch + x0; \
p1 = (Uint8*)super->pixels + Ycenter*super->pitch + x0+w-1; \
i=dy; \
switch( i % 4 ) { \
do{ \
case 0: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
case 3: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
case 2: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
case 1: \
*p0 = color; p0+=super->pitch; \
*p1 = color; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL \
i=dx; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
case 3: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
case 2: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
case 1: \
*(Uint16*)p0 = color; p0+=2; \
*(Uint16*)p1 = color; p1+=2; \
}while( (i-=4) > 0 ); \
} \
if (h<3) return; \
p0 = (Uint8*)super->pixels + Ycenter*super->pitch + x0*2; \
p1 = (Uint8*)super->pixels + Ycenter*super->pitch + (x0+w-1)*2; \
i=dy; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
case 3: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
case 2: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
case 1: \
*(Uint16*)p0 = color; p0+=super->pitch; \
*(Uint16*)p1 = color; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_BPP_3_AUX \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
p0[0] = colorbyte2; \
p0[1] = colorbyte1; \
p0[2] = colorbyte0; \
p1[0] = colorbyte2; \
p1[1] = colorbyte1; \
p1[2] = colorbyte0; \
} else { \
p0[0] = colorbyte0; \
p0[1] = colorbyte1; \
p0[2] = colorbyte2; \
p1[0] = colorbyte0; \
p1[1] = colorbyte1; \
p1[2] = colorbyte2; \
}
 
#define SDL_DRAW_PUTPIXEL \
i=dx; \
switch( i % 4 ) { \
do{ \
case 0: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 3: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 2: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
case 1: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=3; p1+=3; \
}while( (i-=4) > 0 ); \
} \
if (h<3) return; \
p0 = (Uint8*)super->pixels + Ycenter*super->pitch + x0*3; \
p1 = (Uint8*)super->pixels + Ycenter*super->pitch + (x0+w-1)*3; \
i=dy; \
switch( i % 4 ) { \
do{ \
case 0: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
case 3: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
case 2: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
case 1: \
SDL_DRAW_PUTPIXEL_BPP_3_AUX \
p0+=super->pitch; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 4
#ifdef __linux__
#define SDL_DRAW_WMEMSET_START \
if (sizeof(wchar_t) == sizeof(Uint32)) { \
wmemset((wchar_t*)p0, color, dx); \
wmemset((wchar_t*)p1, color, dx); \
} else {
#define SDL_DRAW_WMEMSET_END }
#else
#define SDL_DRAW_WMEMSET_START
#define SDL_DRAW_WMEMSET_END
#endif
 
#define SDL_DRAW_PUTPIXEL \
SDL_DRAW_WMEMSET_START \
i=dx; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
case 3: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
case 2: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
case 1: \
*(Uint32*)p0 = color; p0+=4; \
*(Uint32*)p1 = color; p1+=4; \
}while( (i-=4) > 0 ); \
} \
SDL_DRAW_WMEMSET_END \
if (h<3) return; \
p0 = (Uint8*)super->pixels + Ycenter*super->pitch + x0*4; \
p1 = (Uint8*)super->pixels + Ycenter*super->pitch + (x0+w-1)*4; \
i=dy; \
switch( i % 4 ) { \
do{ \
case 0: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
case 3: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
case 2: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
case 1: \
*(Uint32*)p0 = color; p0+=super->pitch; \
*(Uint32*)p1 = color; p1+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
#endif /*SDL_DRAW_BPP*/
 
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0,Sint16 y0, Uint16 w,Uint16 h,
Uint16 corner, Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
register Uint8 *p0;
register Uint8 *p1;
register Sint16 i;
Sint16 dx, dy;
 
Sint16 Xcenter, Ycenter, X2center, Y2center;
 
Sint16 x = 0;
Sint16 rightInc = 6;
Sint16 d, diagonalInc;
 
if (w==0 || h==0) return;
 
/*TODO: We can do better :-)*/
if (corner!=0) {
d = w<h ? w : h;
--corner;
if (corner!=0 && corner+2 >= d ) {
if (corner+2 == d) --corner;
else corner = 0;
}
}
 
d = 3 - (corner<<1);
diagonalInc = 10 - (corner<<2);
 
/*Rectangles*/
dx = w - (corner<<1);
Xcenter = x0+corner;
dy = h - (corner<<1);
Ycenter = y0+corner;
 
/*Centers*/
X2center=Xcenter+dx-1;
Y2center=Ycenter+dy-1;
 
p0 = (Uint8*)super->pixels + y0 * super->pitch + Xcenter*SDL_DRAW_BPP;
p1 = (Uint8*)super->pixels + (y0+h-1) * super->pitch + Xcenter*SDL_DRAW_BPP;
 
SDL_DRAW_PUTPIXEL
 
while (x < corner) {
 
SDL_DRAW_PUTPIXEL_CIRCLE
 
if (d >= 0) {
d += diagonalInc;
diagonalInc += 8;
--corner;
} else {
d += rightInc;
diagonalInc += 4;
}
rightInc += 4;
++x;
}/*while*/
 
}/*Draw_Round*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_CIRCLE
#undef SDL_DRAW_PUTPIXEL_CIRCLE_BPP
 
#undef SDL_DRAW_WMEMSET_START
#undef SDL_DRAW_WMEMSET_END
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/Draw_VLine.c
0,0 → 1,109
/*!
\file Draw_VLine.c
\author Mario Palomo <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#if SDL_DRAW_BPP == 1
#define SDL_DRAW_PUTPIXEL \
i = y1-y0+1; \
switch( i % 4 ) { \
do{ \
case 0: *p = color; p+=super->pitch; \
case 3: *p = color; p+=super->pitch; \
case 2: *p = color; p+=super->pitch; \
case 1: *p = color; p+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
#elif SDL_DRAW_BPP == 2
#define SDL_DRAW_PUTPIXEL \
i = y1-y0+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint16*)p = color; p+=super->pitch; \
case 3: *(Uint16*)p = color; p+=super->pitch; \
case 2: *(Uint16*)p = color; p+=super->pitch; \
case 1: *(Uint16*)p = color; p+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
#elif SDL_DRAW_BPP == 3
#define SDL_DRAW_PUTPIXEL_BPP_3_AUX \
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
p[0] = colorbyte2; \
p[1] = colorbyte1; \
p[2] = colorbyte0; \
} else { \
p[0] = colorbyte0; \
p[1] = colorbyte1; \
p[2] = colorbyte2; \
}
 
#define SDL_DRAW_PUTPIXEL \
i = y1-y0+1; \
switch( i % 4 ) { \
do{ \
case 0: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=super->pitch; \
case 3: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=super->pitch; \
case 2: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=super->pitch; \
case 1: SDL_DRAW_PUTPIXEL_BPP_3_AUX p+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
 
#elif SDL_DRAW_BPP == 4
#define SDL_DRAW_PUTPIXEL \
i = y1-y0+1; \
switch( i % 4 ) { \
do{ \
case 0: *(Uint32*)p = color; p+=super->pitch; \
case 3: *(Uint32*)p = color; p+=super->pitch; \
case 2: *(Uint32*)p = color; p+=super->pitch; \
case 1: *(Uint32*)p = color; p+=super->pitch; \
}while( (i-=4) > 0 ); \
}
 
#endif /*SDL_DRAW_BPP*/
 
 
void SDL_DRAWFUNCTION(SDL_Surface *super,
Sint16 x0,Sint16 y0, Sint16 y1,
Uint32 color)
{
#if SDL_DRAW_BPP == 3
Uint8 colorbyte0 = (Uint8) (color & 0xff);
Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
#endif
 
register Uint8 *p;
register Sint16 i;
 
if (y0 > y1) { i=y1; y1=y0; y0=i; }
p = (Uint8*)super->pixels + y0 * super->pitch + x0 * SDL_DRAW_BPP;
 
SDL_DRAW_PUTPIXEL
 
}/*Draw_VLine*/
 
 
#undef SDL_DRAW_PUTPIXEL
#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
 
/contrib/sdk/sources/SDL-1.2.2/SDL_draw/src/SDL_draw.c
0,0 → 1,546
/*!
\file SDL_draw.c
\author Mario Palomo Torrero <mpalomo@ihman.com>
\author Jose M. de la Huerga Fernández
\author Pepe González Mora
\date 05-2002
 
Drawing primitives for SDL. Main implementation file.
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "SDL_draw.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h> /*wmemset*/
 
 
/*==================== BEGIN of Draw_Pixel ======================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_Pixel_1
#include "Draw_Pixel.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_Pixel_2
#include "Draw_Pixel.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_Pixel_3
#include "Draw_Pixel.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_Pixel_4
#include "Draw_Pixel.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_Pixel_error(SDL_Surface *super,
Sint16 x, Sint16 y, Uint32 color)
{
SDL_printf("SDL_draw: Draw_Pixel ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
void (*Draw_Pixel)(SDL_Surface *super,
Sint16 x, Sint16 y, Uint32 color) = Draw_Pixel_error;
 
/*===================== END of Draw_Pixel =======================*/
 
/*==================== BEGIN of Draw_Line ======================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_Line_1
#include "Draw_Line.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_Line_2
#include "Draw_Line.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_Line_3
#include "Draw_Line.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_Line_4
#include "Draw_Line.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_Line_error(SDL_Surface *super,
Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_Line ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
void (*Draw_Line)(SDL_Surface *super,
Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
Uint32 color) = Draw_Line_error;
 
/*===================== END of Draw_Line =======================*/
 
/*=================== BEGIN of Draw_Circle =====================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_Circle_1
#include "Draw_Circle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_Circle_2
#include "Draw_Circle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_Circle_3
#include "Draw_Circle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_Circle_4
#include "Draw_Circle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_Circle_error(SDL_Surface *super,
Sint16 x0, Sint16 y0, Uint16 r,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_Circle ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
 
void (*Draw_Circle)(SDL_Surface *super,
Sint16 x0, Sint16 y0, Uint16 r,
Uint32 color) = Draw_Circle_error;
 
/*==================== END of Draw_Circle ======================*/
 
/*================= BEGIN of Draw_FillCircle ===================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_FillCircle_1
#include "Draw_FillCircle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_FillCircle_2
#include "Draw_FillCircle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_FillCircle_3
#include "Draw_FillCircle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_FillCircle_4
#include "Draw_FillCircle.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_FillCircle_error(SDL_Surface *super,
Sint16 x0, Sint16 y0, Uint16 r,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_FillCircle ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
 
void (*Draw_FillCircle)(SDL_Surface *super,
Sint16 x0, Sint16 y0, Uint16 r,
Uint32 color) = Draw_FillCircle_error;
 
/*================== END of Draw_FillCircle ====================*/
 
/*=================== BEGIN of Draw_HLine =====================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_HLine_1
#include "Draw_HLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_HLine_2
#include "Draw_HLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_HLine_3
#include "Draw_HLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_HLine_4
#include "Draw_HLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_HLine_error(SDL_Surface *super,
Sint16 x0,Sint16 y0, Sint16 x1,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_HLine ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
void (*Draw_HLine)(SDL_Surface *super,
Sint16 x0,Sint16 y0, Sint16 x1,
Uint32 color) = Draw_HLine_error;
 
/*==================== END of Draw_HLine ======================*/
 
/*=================== BEGIN of Draw_VLine =====================*/
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_VLine_1
#include "Draw_VLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_VLine_2
#include "Draw_VLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_VLine_3
#include "Draw_VLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_VLine_4
#include "Draw_VLine.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_VLine_error(SDL_Surface *super,
Sint16 x0,Sint16 y0, Sint16 y1,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_VLine ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
 
void (*Draw_VLine)(SDL_Surface *super,
Sint16 x0,Sint16 y0, Sint16 y1,
Uint32 color) = Draw_VLine_error;
 
/*==================== END of Draw_VLine ======================*/
 
/*==================== BEGIN of Draw_Rect ======================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_Rect_1
#include "Draw_Rect.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_Rect_2
#include "Draw_Rect.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_Rect_3
#include "Draw_Rect.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_Rect_4
#include "Draw_Rect.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_Rect_error(SDL_Surface *super,
Sint16 x,Sint16 y, Uint16 w,Uint16 h,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_Rect ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
void (*Draw_Rect)(SDL_Surface *super,
Sint16 x,Sint16 y, Uint16 w,Uint16 h,
Uint32 color) = Draw_Rect_error;
 
/*===================== END of Draw_Rect =======================*/
 
/*=================== BEGIN of Draw_Ellipse ====================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_Ellipse_1
#include "Draw_Ellipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_Ellipse_2
#include "Draw_Ellipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_Ellipse_3
#include "Draw_Ellipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_Ellipse_4
#include "Draw_Ellipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_Ellipse_error(SDL_Surface *super,
Sint16 x0, Sint16 y0,
Uint16 Xradius, Uint16 Yradius,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_Ellipse ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
 
void (*Draw_Ellipse)(SDL_Surface *super,
Sint16 x0, Sint16 y0,
Uint16 Xradius, Uint16 Yradius,
Uint32 color) = Draw_Ellipse_error;
 
/*==================== END of Draw_Ellipse =====================*/
 
/*================= BEGIN of Draw_FillEllipse ==================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_FillEllipse_1
#include "Draw_FillEllipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_FillEllipse_2
#include "Draw_FillEllipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_FillEllipse_3
#include "Draw_FillEllipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_FillEllipse_4
#include "Draw_FillEllipse.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_FillEllipse_error(SDL_Surface *super,
Sint16 x0, Sint16 y0,
Uint16 Xradius, Uint16 Yradius,
Uint32 color)
{
SDL_printf("SDL_draw: Draw_FillEllipse ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
 
void (*Draw_FillEllipse)(SDL_Surface *super,
Sint16 x0, Sint16 y0,
Uint16 Xradius, Uint16 Yradius,
Uint32 color) = Draw_FillEllipse_error;
 
/*================== END of Draw_FillEllipse ===================*/
 
/*==================== BEGIN of Draw_Round =====================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_Round_1
#include "Draw_Round.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_Round_2
#include "Draw_Round.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_Round_3
#include "Draw_Round.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_Round_4
#include "Draw_Round.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_Round_error(SDL_Surface *super,
Sint16 x0,Sint16 y0, Uint16 w,Uint16 h,
Uint16 corner, Uint32 color)
{
SDL_printf("SDL_draw: Draw_Round ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
void (*Draw_Round)(SDL_Surface *super,
Sint16 x0,Sint16 y0, Uint16 w,Uint16 h,
Uint16 corner, Uint32 color) = Draw_Round_error;
 
/*===================== END of Draw_Round ======================*/
 
/*================== BEGIN of Draw_FillRound ===================*/
 
#define SDL_DRAW_BPP 1
#define SDL_DRAWFUNCTION Draw_FillRound_1
#include "Draw_FillRound.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 2
#define SDL_DRAWFUNCTION Draw_FillRound_2
#include "Draw_FillRound.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 3
#define SDL_DRAWFUNCTION Draw_FillRound_3
#include "Draw_FillRound.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
#define SDL_DRAW_BPP 4
#define SDL_DRAWFUNCTION Draw_FillRound_4
#include "Draw_FillRound.c"
#undef SDL_DRAWFUNCTION
#undef SDL_DRAW_BPP
 
static
void Draw_FillRound_error(SDL_Surface *super,
Sint16 x0,Sint16 y0, Uint16 w,Uint16 h,
Uint16 corner, Uint32 color)
{
SDL_printf("SDL_draw: Draw_FillRound ERROR!!."
" Have you call to SDL_Draw_Init()?\n");
exit(-1);
}
 
void (*Draw_FillRound)(SDL_Surface *super,
Sint16 x0,Sint16 y0, Uint16 w,Uint16 h,
Uint16 corner, Uint32 color) = Draw_FillRound_error;
 
/*=================== END of Draw_FillRound ====================*/
 
 
/*Assignment of function pointers:*/
#define SDL_DRAW_FUNCTIONS_BPP(x) \
Draw_Pixel = Draw_Pixel_##x; \
Draw_Line = Draw_Line_##x; \
Draw_Circle = Draw_Circle_##x; \
Draw_FillCircle = Draw_FillCircle_##x; \
Draw_HLine = Draw_HLine_##x; \
Draw_VLine = Draw_VLine_##x; \
Draw_Rect = Draw_Rect_##x; \
Draw_Ellipse = Draw_Ellipse_##x; \
Draw_FillEllipse = Draw_FillEllipse_##x; \
Draw_Round = Draw_Round_##x; \
Draw_FillRound = Draw_FillRound_##x
 
/*IMPORTANT: Call this function AFTER the call to 'SDL_SetVideoMode'*/
void Draw_Init(void)
{
SDL_Surface *screen = SDL_GetVideoSurface();
if (!screen) {
SDL_printf("SDL_draw: SDL_Draw_Init ERROR!!."
" Video Surface not found\n");
exit(-2);
}
 
 
switch(screen->format->BytesPerPixel) {
case 1:
SDL_DRAW_FUNCTIONS_BPP(1);
break;
 
case 2:
SDL_DRAW_FUNCTIONS_BPP(2);
break;
 
case 3:
SDL_DRAW_FUNCTIONS_BPP(3);
break;
 
case 4:
SDL_DRAW_FUNCTIONS_BPP(4);
break;
}/*switch*/
 
}/*Draw_Init*/
 
#undef SDL_DRAW_FUNCTIONS_BPP