Skip to content
Browse files

make LEDs round

  • Loading branch information...
1 parent a826543 commit b40d2bc3c1ad9ea35981fd7e52a65a19e0a29ab1 @sebseb7 committed Nov 22, 2011
View
4 firmware/sim/Makefile
@@ -6,6 +6,10 @@ BINARIES=$(SOURCES:../apps/%.c=%)
LIB_SOURCES=$(wildcard ../libs/*.c)
LIB_HEADERS=$(wildcard ../libs/*.h)
+LIB_SOURCES+= sdl_draw/SDL_draw.c
+LIB_HEADERS+= sdl_draw/SDL_draw.h
+
+
FLAGS=--std=gnu99 -Wall
ifeq ($(UNAME), Darwin)
View
23 firmware/sim/main.c
@@ -6,12 +6,14 @@
#include <SDL/SDL.h>
#include "main.h"
+#include "sdl_draw/SDL_draw.h"
#define ZOOM 50
int leds[LED_HEIGHT][LED_WIDTH];
int interval;
+
uint16_t volatile current_adc_value = 900;
tick_fun tick_fp;
@@ -67,6 +69,20 @@ int main(int argc, char *argv[]) {
SDL_Surface* screen = SDL_SetVideoMode(LED_WIDTH * ZOOM, LED_HEIGHT * ZOOM,
32, SDL_SWSURFACE | SDL_DOUBLEBUF);
+ SDL_Rect rect = { 0, 0, LED_WIDTH*ZOOM, LED_HEIGHT*ZOOM };
+ SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, 0x20,0x20,0x60));
+
+ unsigned int color[] = {
+ SDL_MapRGB(screen->format, 0x57,0x10,0x10),
+ SDL_MapRGB(screen->format, 0x6f,0x20,0x20),
+ SDL_MapRGB(screen->format, 0x87,0x30,0x30),
+ SDL_MapRGB(screen->format, 0x9f,0x40,0x40),
+ SDL_MapRGB(screen->format, 0xb7,0x50,0x50),
+ SDL_MapRGB(screen->format, 0xcf,0x60,0x60),
+ SDL_MapRGB(screen->format, 0xe7,0x70,0x70),
+ SDL_MapRGB(screen->format, 0xff,0x80,0x80)
+ };
+
int running = 1;
while(running) {
SDL_Event ev;
@@ -92,15 +108,10 @@ int main(int argc, char *argv[]) {
running &= !tick_fp();
- const unsigned int color[] = {
- // 0x000000, 0x7f0000, 0xcf0000, 0xff3f3f,
- 0x000000, 0x240000, 0x480000,0x6c0000,0x900000,0xb40000,0xd90000, 0xff3f3f,
- };
int x, y;
for(x = 0; x < LED_WIDTH; x++) {
for(y = 0; y < LED_HEIGHT; y++) {
- SDL_Rect rect = { x * ZOOM, (LED_HEIGHT - y - 1) * ZOOM, ZOOM, ZOOM };
- SDL_FillRect(screen, &rect, color[leds[y][x]]);
+ Draw_FillCircle(screen, ZOOM*x+(ZOOM/2),ZOOM*(LED_HEIGHT - y - 1)+(ZOOM/2), (ZOOM*0.4), color[leds[y][x]]);
}
}
SDL_Flip(screen);
View
109 firmware/sim/sdl_draw/Draw_Circle.c
@@ -0,0 +1,109 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ while (x <= y) {
+
+ SDL_DRAW_PUTPIXEL
+
+ if (d >= 0) {
+ d += diagonalInc;
+ diagonalInc += 8;
+ y -= 1;
+ } else {
+ d += rightInc;
+ diagonalInc += 4;
+ }
+ rightInc += 4;
+ x += 1;
+ }
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_Circle*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP
+
View
145 firmware/sim/sdl_draw/Draw_Ellipse.c
@@ -0,0 +1,145 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ /*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;
+ }
+ }
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_Ellipse*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP
+
View
224 firmware/sim/sdl_draw/Draw_FillCircle.c
@@ -0,0 +1,224 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ 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;
+ }
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_FillCircle*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
+
+#undef SDL_DRAW_WMEMSET_START
+#undef SDL_DRAW_WMEMSET_END
+
View
226 firmware/sim/sdl_draw/Draw_FillEllipse.c
@@ -0,0 +1,226 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ /*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;
+ }
+ }
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_FillEllipse*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
+
+#undef SDL_DRAW_WMEMSET_START
+#undef SDL_DRAW_WMEMSET_END
+
View
256 firmware/sim/sdl_draw/Draw_FillRound.c
@@ -0,0 +1,256 @@
+/*!
+ \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);
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ 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*/
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_FillRound*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+
+#undef SDL_DRAW_WMEMSET_START
+#undef SDL_DRAW_WMEMSET_END
+
View
125 firmware/sim/sdl_draw/Draw_HLine.c
@@ -0,0 +1,125 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ SDL_DRAW_PUTPIXEL
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_HLine*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
+
+#undef SDL_DRAW_WMEMSET_START
+#undef SDL_DRAW_WMEMSET_END
+
View
167 firmware/sim/sdl_draw/Draw_Line.c
@@ -0,0 +1,167 @@
+/*!
+ \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
+
+ Based in Kenny Hoff sourcer.
+*/
+/*
+ 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, D) *(A(B(Uint8*)D))=C;
+
+#if SDL_DRAW_BPP == 1
+#define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP(0+,0+,color,D)
+
+#elif SDL_DRAW_BPP == 2
+#define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP((Uint16*),0+,color,D)
+
+#elif SDL_DRAW_BPP == 3
+#define SDL_DRAW_PUTPIXEL(D) \
+ SDL_DRAW_PUTPIXEL_BPP(0+,1+,(Uint8)colorbyte1,D) \
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
+ SDL_DRAW_PUTPIXEL_BPP(0+,0+,(Uint8)colorbyte2,D) \
+ SDL_DRAW_PUTPIXEL_BPP(0+,2+,(Uint8)colorbyte0,D) \
+ }else{ \
+ SDL_DRAW_PUTPIXEL_BPP(0+,0+,(Uint8)colorbyte0,D) \
+ SDL_DRAW_PUTPIXEL_BPP(0+,2+,(Uint8)colorbyte2,D) \
+ }
+
+#elif SDL_DRAW_BPP == 4
+#define SDL_DRAW_PUTPIXEL(D) SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color,D)
+
+#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
+
+ register Sint16 dx;
+ register Sint16 dy;
+
+ Sint16 fbXincr, fbYincr, fbXYincr;
+ Sint16 dPr, dPru, P;
+
+ Sint16 pixx = super->format->BytesPerPixel;
+ Sint16 pixy = super->pitch;
+
+ Uint8 *AfbAddr, *BfbAddr;
+
+ /* Clip line and test if we have to draw only if we need to do it */
+/* It is in next version.
+#ifdef SDL_DRAW_CLIP
+ if (!(clipLine(super, &x1, &y1, &x2, &y2))) { return; }
+#endif
+*/
+ /* Store the fremebuffer Endpoint-Addresses (A and B) */
+ AfbAddr = ((Uint8*)super->pixels) + pixx * (int)x1 + pixy * (int)y1;
+ BfbAddr = ((Uint8*)super->pixels) + pixx * (int)x2 + pixy * (int)y2;
+
+
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ fbXincr=pixx;
+ if ( (dx=x2-x1) >= 0 ) goto AFTERNEGX;
+ dx = -dx;
+ fbXincr = -pixx;
+ AFTERNEGX:
+
+ fbYincr=pixy; //debug
+ if ( (dy=y2-y1) >= 0) goto AFTERNEGY;
+ fbYincr = -pixy;
+ dy = -dy;
+ AFTERNEGY:
+
+ fbXYincr = fbXincr+fbYincr;
+
+ if (dy > dx) goto YisIndependent; /*Check if X or Y is independent vaiable */
+
+ /*XisIndependent;*/
+ dPr = dy+dy;
+ P = -dx;
+ dPru = P+P;
+ dy = dx>>1;
+ XLOOP:
+ SDL_DRAW_PUTPIXEL(AfbAddr); /*Plot the pixel from end of pointer one*/
+ SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot the pixel from end of pointer two*/
+ if ((P+=dPr) > 0) goto RightAndUp;
+ /*Up:*/
+ AfbAddr+=fbXincr;
+ BfbAddr-=fbXincr;
+ if ((dy=dy-1) > 0) goto XLOOP;
+ SDL_DRAW_PUTPIXEL(AfbAddr) /*(Fix midpoint problem) Plot last PT from end pointer one*/
+ if (( dx & 1) == 0) goto END_P;
+ SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if independent is odd*/
+ goto END_P;
+ RightAndUp:
+ AfbAddr+=fbXYincr; /*Advance to next point from end of pointer one*/
+ BfbAddr-=fbXYincr; /*Advance to next point from end of pointer two*/
+ P+=dPru;
+ if ((dy=dy-1) > 0) goto XLOOP;
+ SDL_DRAW_PUTPIXEL(AfbAddr); /*(Fix midpoint problem) Plot last PT from end of pointer one*/
+ if ((dx & 1) == 0) goto END_P;
+ SDL_DRAW_PUTPIXEL(BfbAddr); /*Plot last PT from end of pointer two if indepent is odd*/
+ goto END_P;
+
+ YisIndependent:
+ dPr = dx+dx;
+ P = -dy;
+ dPru = P+P;
+ dx = dy >>1;
+ YLOOP: /* PROCESS EACH POINT IN THE LINE ONE AT A TIME (use dX as loop counter) */
+ SDL_DRAW_PUTPIXEL(AfbAddr); /* PLOT THE PIXEL FROM END A */
+ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT THE PIXEL FROM END B */
+ if ((P+=dPr) > 0) goto RightAndUp2; /* INCREMENT DECISION, CHECK IF THE PIXEL IS GOING RIGHT AND UP */
+ /*Up:*/
+ AfbAddr+=fbYincr; /* ADVANCE TO NEXT POINT FROM END A */
+ BfbAddr-=fbYincr; /* ADVANCE TO NEXT POINT FROM END B */
+ if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */
+ SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */
+ if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */
+ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */
+ goto END_P;
+ RightAndUp2:
+ AfbAddr+=fbXYincr; /* ADVANCE TO NEXT POINT FROM END A */
+ BfbAddr-=fbXYincr; /* ADVANCE TO NEXT POINT FROM END B */
+ P+=dPru; /* INCREMENT DECISION (for up) */
+ if ((dx=dx-1) > 0) goto YLOOP; /* DECREMENT LOOP VARIABLE AND LOOP */
+ SDL_DRAW_PUTPIXEL(AfbAddr); /* (FIX MIDPOINT PROBLEM) PLOT THE LAST POINT FROM END A */
+ if ((dy & 1) == 0) goto END_P; /* FINISHED IF INDEPENDENT IS EVEN (ODD # STEPS) */
+ SDL_DRAW_PUTPIXEL(BfbAddr); /* PLOT LAST PT FROM END B IF INDEPENDENT IS ODD (EVEN # STEPS) */
+
+END_P:
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_Line*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP
+
View
72 firmware/sim/sdl_draw/Draw_Pixel.c
@@ -0,0 +1,72 @@
+/*!
+ \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
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ SDL_DRAW_PUTPIXEL
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_Pixel*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP
+
View
244 firmware/sim/sdl_draw/Draw_Rect.c
@@ -0,0 +1,244 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ SDL_DRAW_PUTPIXEL
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_Rect*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
+
+#undef SDL_DRAW_WMEMSET_START
+#undef SDL_DRAW_WMEMSET_END
+
View
334 firmware/sim/sdl_draw/Draw_Round.c
@@ -0,0 +1,334 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ 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*/
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*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
+
View
117 firmware/sim/sdl_draw/Draw_VLine.c
@@ -0,0 +1,117 @@
+/*!
+ \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;
+
+ /* Lock surface */
+ if (SDL_MUSTLOCK(super)) {
+ if (SDL_LockSurface(super) < 0) { return; }
+ }
+
+ SDL_DRAW_PUTPIXEL
+
+ /* Unlock surface */
+ if (SDL_MUSTLOCK(super)) { SDL_UnlockSurface(super); }
+
+}/*Draw_VLine*/
+
+
+#undef SDL_DRAW_PUTPIXEL
+#undef SDL_DRAW_PUTPIXEL_BPP_3_AUX
+
View
537 firmware/sim/sdl_draw/SDL_draw.c
@@ -0,0 +1,537 @@
+/*!
+ \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*/
+
+
+/* Draw_Init is defined at the end */
+static void Draw_Init(void);
+
+/*==================== 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_Init(SDL_Surface *super,
+ Sint16 x, Sint16 y, Uint32 color)
+{
+ Draw_Init();
+ Draw_Pixel(super, x, y, color);
+}
+
+void (*Draw_Pixel)(SDL_Surface *super,
+ Sint16 x, Sint16 y, Uint32 color) = Draw_Pixel_Init;
+
+/*===================== 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_Init(SDL_Surface *super,
+ Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_Line(super, x1, y1, x2, y2, color);
+}
+
+void (*Draw_Line)(SDL_Surface *super,
+ Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
+ Uint32 color) = Draw_Line_Init;
+
+/*===================== 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_Init(SDL_Surface *super,
+ Sint16 x0, Sint16 y0, Uint16 r,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_Circle(super, x0, y0, r, color);
+}
+
+
+void (*Draw_Circle)(SDL_Surface *super,
+ Sint16 x0, Sint16 y0, Uint16 r,
+ Uint32 color) = Draw_Circle_Init;
+
+/*==================== 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_Init(SDL_Surface *super,
+ Sint16 x0, Sint16 y0, Uint16 r,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_FillCircle(super, x0, y0, r, color);
+}
+
+
+void (*Draw_FillCircle)(SDL_Surface *super,
+ Sint16 x0, Sint16 y0, Uint16 r,
+ Uint32 color) = Draw_FillCircle_Init;
+
+/*================== 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_Init(SDL_Surface *super,
+ Sint16 x0,Sint16 y0, Sint16 x1,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_HLine(super, x0, y0, x1, color);
+}
+
+void (*Draw_HLine)(SDL_Surface *super,
+ Sint16 x0,Sint16 y0, Sint16 x1,
+ Uint32 color) = Draw_HLine_Init;
+
+/*==================== 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_Init(SDL_Surface *super,
+ Sint16 x0,Sint16 y0, Sint16 y1,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_VLine(super, x0, y0, y1, color);
+}
+
+void (*Draw_VLine)(SDL_Surface *super,
+ Sint16 x0,Sint16 y0, Sint16 y1,
+ Uint32 color) = Draw_VLine_Init;
+
+/*==================== 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_Init(SDL_Surface *super,
+ Sint16 x,Sint16 y, Uint16 w,Uint16 h,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_Rect(super, x, y, w, h, color);
+}
+
+void (*Draw_Rect)(SDL_Surface *super,
+ Sint16 x,Sint16 y, Uint16 w,Uint16 h,
+ Uint32 color) = Draw_Rect_Init;
+
+/*===================== 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_Init(SDL_Surface *super,
+ Sint16 x0, Sint16 y0,
+ Uint16 Xradius, Uint16 Yradius,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_Ellipse(super, x0, y0, Xradius, Yradius, color);
+}
+
+
+void (*Draw_Ellipse)(SDL_Surface *super,
+ Sint16 x0, Sint16 y0,
+ Uint16 Xradius, Uint16 Yradius,
+ Uint32 color) = Draw_Ellipse_Init;
+
+/*==================== 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_Init(SDL_Surface *super,
+ Sint16 x0, Sint16 y0,
+ Uint16 Xradius, Uint16 Yradius,
+ Uint32 color)
+{
+ Draw_Init();
+ Draw_FillEllipse(super, x0, y0, Xradius, Yradius, color);
+}
+
+
+void (*Draw_FillEllipse)(SDL_Surface *super,
+ Sint16 x0, Sint16 y0,
+ Uint16 Xradius, Uint16 Yradius,
+ Uint32 color) = Draw_FillEllipse_Init;
+
+/*================== 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"