| author | ecalot
<ecalot> 2004-07-18 18:21:43 UTC |
| committer | ecalot
<ecalot> 2004-07-18 18:21:43 UTC |
| parent | 04944a48e4baf7c68953f73529f85c5838f70a44 |
| FP/src/include/output.h | +5 | -4 |
| FP/src/ker/kernel.c | +5 | -8 |
| FP/src/out/output.c | +12 | -7 |
diff --git a/FP/src/include/output.h b/FP/src/include/output.h index a1f6c99..2b02691 100644 --- a/FP/src/include/output.h +++ b/FP/src/include/output.h @@ -72,17 +72,17 @@ void outputFreeBitmap(void* image); */ /* Graph: Primitives for the kernel */ -void outputDrawBitmap(SDL_Surface *screen, void* image,int x, int y); +void outputDrawBitmap(void* image,int x, int y); /* Draws an abstract image */ -void outputClearScreen(SDL_Surface *screen); -void outputUpdateScreen(SDL_Surface *screen); +void outputClearScreen(); +void outputUpdateScreen(); /* Crears the screen */ /* Initialization */ -SDL_Surface *outputInit(); +int outputInit(); /* This function must be called before starting using the output functions * it will initialize the screen and the output module. Returns a pointer * to the initialized screen, or NULL if an error occurs. */ @@ -92,3 +92,4 @@ void outputStop(); */ #endif + diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c index 35da4d9..ae1d7a3 100644 --- a/FP/src/ker/kernel.c +++ b/FP/src/ker/kernel.c @@ -45,16 +45,13 @@ int kernel(int optionflag,int level) { * must be called optionflag */ - SDL_Surface *screen /* , *test */; SDL_Event e; int i,location,direction,upIsPressed; tData* runningAnimation[4]; tData* animation; tData* fondo; - screen = outputInit(); - - if (!screen) { + if (outputInit()) { fprintf(stderr, "Unable to initialize screen: %s\n", SDL_GetError()); exit(1); } @@ -119,10 +116,10 @@ int kernel(int optionflag,int level) { } } } - outputClearScreen(screen); - outputDrawBitmap(screen, fondo->pFrames[0], 0, 0); - outputDrawBitmap(screen, animation->pFrames[i], location, 141); - outputUpdateScreen(screen); + outputClearScreen(); + outputDrawBitmap(fondo->pFrames[0], 0, 0); + outputDrawBitmap(animation->pFrames[i], location, 141); + outputUpdateScreen(); i++; SDL_Delay(50); animation=runningAnimation[(upIsPressed<<1)|(direction)]; diff --git a/FP/src/out/output.c b/FP/src/out/output.c index 85ddb5f..350dd16 100644 --- a/FP/src/out/output.c +++ b/FP/src/out/output.c @@ -39,6 +39,9 @@ output.c: Free Prince : Output Devices Handler #include "resources.h" /* tMemory structure */ #include "output.h" +/* Main screen object */ +SDL_Surface *screen; + /* Text Primitives*/ void outputDrawText(int x, int y, const char *fmt, ...) { @@ -48,6 +51,9 @@ void outputDrawMessage(const char* fmt, ...) { } +void outputClearLastMessage() +{ +} /* Sound */ void outputPlayWav(tMemory sound) {} /* Starts the reproduction of the sample and returns */ @@ -139,7 +145,7 @@ outputLoadBitmap(const unsigned char* data, int size, void outputFreeBitmap(void* image) {} /* Graphics: Primitives for the kernel */ -void outputDrawBitmap(SDL_Surface *screen, void* image, int x, int y) { +void outputDrawBitmap(void* image, int x, int y) { /* Draws an abstract image */ SDL_Surface *s = (SDL_Surface *)image; SDL_Rect dest; @@ -152,21 +158,20 @@ void outputDrawBitmap(SDL_Surface *screen, void* image, int x, int y) { if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); } -void outputClearScreen(SDL_Surface *screen) +void outputClearScreen() { SDL_FillRect(screen, NULL, 0); } -void outputUpdateScreen(SDL_Surface *screen) +void outputUpdateScreen() { SDL_Flip(screen); } /* Initialization */ -SDL_Surface *outputInit() +int outputInit() { int i; - SDL_Surface *screen; SDL_Color colors[256]; SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO); atexit(outputStop); @@ -178,9 +183,9 @@ SDL_Surface *outputInit() colors[i].b=255-i; } screen = SDL_SetVideoMode(320, 200, 8, SDL_SWSURFACE|SDL_HWPALETTE); - if (!screen) return NULL; + if (!screen) return -1; /*SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);*/ - return screen; + return 0; } /* Finish all output modes, including the screen mode */