From 12a8eb6ca28aa97f422e7cf9317f01eb0dfc9a11 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 14 May 2014 21:57:09 +0200 Subject: [PATCH] rnd-20140514-2-src * cleanup of functions RedrawPlayfield() and BlitScreenToBitmap() --- ChangeLog | 7 +++- src/cartoons.c | 4 ++ src/conftime.h | 2 +- src/game.c | 16 ++++++- src/tools.c | 110 ++++++++++++++++++++++++++++++------------------- src/tools.h | 4 ++ 6 files changed, 97 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33999ffa..84e7d51c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-05-14 + * cleanup of functions RedrawPlayfield() and BlitScreenToBitmap() + 2014-05-13 * fixed level redraw after quick-loading tape with small tile graphics @@ -81,8 +84,8 @@ 2013-12-11 * removed limitation of artwork files to selected file types (this means that every file type supported by SDL_image and SDL_mixer can be used) - * changed default graphics vom PCX to PNG (needed for Android version to - prevent painfully slow loading of images, although not compressing PCX + * changed default graphics from PCX to PNG (needed for Android version + to prevent painfully slow image loading, although not compressing PCX files in the assets directory of the APK package might also work fine) * fixed bug with SDL_BlitSurface creating garbage when source and target surface are the same (this bug also existed in versions of SDL 1.2.x) diff --git a/src/cartoons.c b/src/cartoons.c index 8ca4bdd5..1f430493 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -26,6 +26,9 @@ static void PrepareBackbuffer() if (game_status != GAME_MODE_PLAYING) return; +#if 1 + BlitScreenToBitmap(backbuffer); +#else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) { BlitScreenToBitmap_EM(backbuffer); @@ -43,6 +46,7 @@ static void PrepareBackbuffer() BlitBitmap(fieldbuffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY); } +#endif } boolean ToonNeedsRedraw() diff --git a/src/conftime.h b/src/conftime.h index 3355c2e7..ee495261 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-05-14 01:51" +#define COMPILE_DATE_STRING "2014-05-14 21:52" diff --git a/src/game.c b/src/game.c index 335bfdea..9e6ecbd9 100644 --- a/src/game.c +++ b/src/game.c @@ -4507,15 +4507,19 @@ void InitGame() { InitGameEngine_EM(); +#if 0 /* blit playfield from scroll buffer to normal back buffer for fading in */ BlitScreenToBitmap_EM(backbuffer); +#endif } else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) { InitGameEngine_SP(); +#if 0 /* blit playfield from scroll buffer to normal back buffer for fading in */ BlitScreenToBitmap_SP(backbuffer); +#endif } else { @@ -4526,16 +4530,26 @@ void InitGame() if (game.timegate_time_left == 0) CloseAllOpenTimegates(); +#if 0 + /* blit playfield from scroll buffer to normal back buffer for fading in */ #if NEW_TILESIZE BlitScreenToBitmap(backbuffer); #else - /* blit playfield from scroll buffer to normal back buffer for fading in */ if (setup.soft_scrolling) BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); #endif +#endif +#if 0 redraw_mask |= REDRAW_FROM_BACKBUFFER; +#endif } +#if 1 + /* blit playfield from scroll buffer to normal back buffer for fading in */ + BlitScreenToBitmap(backbuffer); + + redraw_mask |= REDRAW_FROM_BACKBUFFER; +#endif /* !!! FIX THIS (END) !!! */ #if 1 diff --git a/src/tools.c b/src/tools.c index ea92646c..62cd26a8 100644 --- a/src/tools.c +++ b/src/tools.c @@ -298,59 +298,59 @@ void SetDrawtoField(int mode) #if 1 -void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height) +static void RedrawPlayfield_RND() { - if (game_status == GAME_MODE_PLAYING && - level.game_engine_type == GAME_ENGINE_TYPE_EM) - { - /* currently there is no partial redraw -- always redraw whole playfield */ - RedrawPlayfield_EM(TRUE); + int x, y; - /* blit playfield from scroll buffer to normal back buffer for fading in */ - BlitScreenToBitmap_EM(backbuffer); - } - else if (game_status == GAME_MODE_PLAYING && - level.game_engine_type == GAME_ENGINE_TYPE_SP) - { - /* currently there is no partial redraw -- always redraw whole playfield */ - RedrawPlayfield_SP(TRUE); + if (game.envelope_active) + return; - /* blit playfield from scroll buffer to normal back buffer for fading in */ - BlitScreenToBitmap_SP(backbuffer); - } - else if (game_status == GAME_MODE_PLAYING && - !game.envelope_active) - { #if 0 - DrawLevel(); + DrawLevel(); #else - SetMainBackgroundImage(IMG_BACKGROUND_PLAYING); - // SetDrawBackgroundMask(REDRAW_FIELD); // !!! CHECK THIS !!! + SetMainBackgroundImage(IMG_BACKGROUND_PLAYING); + // SetDrawBackgroundMask(REDRAW_FIELD); // !!! CHECK THIS !!! - for (x = BX1; x <= BX2; x++) - for (y = BY1; y <= BY2; y++) - DrawScreenField(x, y); + for (x = BX1; x <= BX2; x++) + for (y = BY1; y <= BY2; y++) + DrawScreenField(x, y); - redraw_mask |= REDRAW_FIELD; + redraw_mask |= REDRAW_FIELD; #endif - DrawAllPlayers(); + DrawAllPlayers(); +#if 0 #if NEW_TILESIZE - BlitScreenToBitmap(backbuffer); + BlitScreenToBitmap(backbuffer); #else - /* blit playfield from scroll buffer to normal back buffer */ - if (setup.soft_scrolling) - { - int fx = FX, fy = FY; + /* blit playfield from scroll buffer to normal back buffer */ + if (setup.soft_scrolling) + { + int fx = FX, fy = FY; - fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0); - fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0); + fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0); + fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0); - BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY); - } -#endif + BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY); } +#endif +#endif +} + +void RedrawPlayfield() +{ + if (game_status != GAME_MODE_PLAYING) + return; + + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + RedrawPlayfield_EM(TRUE); + else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + RedrawPlayfield_SP(TRUE); + else if (level.game_engine_type == GAME_ENGINE_TYPE_RND) + RedrawPlayfield_RND(); + + BlitScreenToBitmap(backbuffer); BlitBitmap(drawto, window, gfx.sx, gfx.sy, gfx.sxsize, gfx.sysize, gfx.sx, gfx.sy); @@ -497,7 +497,7 @@ void DrawMaskedBorder(int redraw_mask) } } -void BlitScreenToBitmap(Bitmap *target_bitmap) +static void BlitScreenToBitmap_RND(Bitmap *target_bitmap) { DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field); int fx = FX, fy = FY; @@ -594,6 +594,16 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) } } +void BlitScreenToBitmap(Bitmap *target_bitmap) +{ + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + BlitScreenToBitmap_EM(target_bitmap); + else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + BlitScreenToBitmap_SP(target_bitmap); + else if (level.game_engine_type == GAME_ENGINE_TYPE_RND) + BlitScreenToBitmap_RND(target_bitmap); +} + void BackToFront() { int x, y; @@ -723,7 +733,7 @@ void BackToFront() else { #if 1 - BlitScreenToBitmap(window); + BlitScreenToBitmap_RND(window); #else int fx = FX, fy = FY; @@ -3339,12 +3349,16 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) if (game_status == GAME_MODE_PLAYING) { #if 1 +#if 1 + BlitScreenToBitmap(backbuffer); +#else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) BlitScreenToBitmap_SP(backbuffer); else - BlitScreenToBitmap(backbuffer); + BlitScreenToBitmap_RND(backbuffer); +#endif #else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); @@ -4655,10 +4669,14 @@ static boolean RequestDoor(char *text, unsigned int req_state) if (game_status == GAME_MODE_PLAYING) { +#if 1 + BlitScreenToBitmap(backbuffer); +#else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) BlitScreenToBitmap_SP(backbuffer); +#endif } /* disable deactivated drawing when quick-loading level tape recording */ @@ -4852,12 +4870,16 @@ static boolean RequestEnvelope(char *text, unsigned int req_state) if (game_status == GAME_MODE_PLAYING) { #if 1 +#if 1 + BlitScreenToBitmap(backbuffer); +#else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) BlitScreenToBitmap_SP(backbuffer); else - BlitScreenToBitmap(backbuffer); + BlitScreenToBitmap_RND(backbuffer); +#endif #else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); @@ -5074,10 +5096,14 @@ boolean Request(char *text, unsigned int req_state) if (game_status == GAME_MODE_PLAYING) { +#if 1 + BlitScreenToBitmap(backbuffer); +#else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) BlitScreenToBitmap_SP(backbuffer); +#endif } /* disable deactivated drawing when quick-loading level tape recording */ diff --git a/src/tools.h b/src/tools.h index 3d7c96ea..e042fa66 100644 --- a/src/tools.h +++ b/src/tools.h @@ -80,7 +80,11 @@ void DrawMaskedBorder_ALL(); void DrawMaskedBorder(int); void SetDrawtoField(int); +#if 1 +void RedrawPlayfield(); +#else void RedrawPlayfield(boolean, int, int, int, int); +#endif void BlitScreenToBitmap(Bitmap *); void BackToFront(); -- 2.34.1