From: Holger Schemel Date: Fri, 15 May 2015 12:50:57 +0000 (+0200) Subject: removed unused code for single-tile playfield redraw X-Git-Tag: 4.0.0.0-rc1~209 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=fdd2829c52e8f4ec204e089b5d35ed5aef50e4e6 removed unused code for single-tile playfield redraw --- diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 860cb365..05ac1a02 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -97,68 +97,18 @@ void BlitScreenToBitmap_EM(Bitmap *target_bitmap) void BackToFront_EM(void) { - static int screen_x_last = -1, screen_y_last = -1; - static boolean scrolling_last = FALSE; - int left = screen_x / TILEX; - int top = screen_y / TILEY; - boolean scrolling = (screen_x != screen_x_last || screen_y != screen_y_last); int x, y; - if (redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last) - { - /* blit all (up to four) parts of the scroll buffer to the backbuffer */ - BlitScreenToBitmap_EM(backbuffer); - - /* blit the completely updated backbuffer to the window (in one blit) */ - BlitBitmap(backbuffer, window, SX, SY, SXSIZE, SYSIZE, SX, SY); - } - else - { - boolean half_shifted_x = (screen_x % TILEX != 0); - boolean half_shifted_y = (screen_y % TILEY != 0); - - int sx, sy; - int xsize = SXSIZE; - int ysize = SYSIZE; - int full_xsize = lev.width * TILEX; - int full_ysize = lev.height * TILEY; - - sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); - sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); + /* blit all (up to four) parts of the scroll buffer to the backbuffer */ + BlitScreenToBitmap_EM(backbuffer); - int x1 = 0, x2 = SCR_FIELDX - (half_shifted_x ? 0 : 1); - int y1 = 0, y2 = SCR_FIELDY - (half_shifted_y ? 0 : 1); - int scroll_xoffset = (half_shifted_x ? TILEX / 2 : 0); - int scroll_yoffset = (half_shifted_y ? TILEY / 2 : 0); - - InitGfxClipRegion(TRUE, SX, SY, SXSIZE, SYSIZE); - - for (x = x1; x <= x2; x++) - { - for (y = y1; y <= y2; y++) - { - int xx = (left + x) % MAX_BUF_XSIZE; - int yy = (top + y) % MAX_BUF_YSIZE; - - if (redraw[xx][yy]) - BlitBitmap(screenBitmap, window, - xx * TILEX, yy * TILEY, TILEX, TILEY, - sx + x * TILEX - scroll_xoffset, - sy + y * TILEY - scroll_yoffset); - } - } - - InitGfxClipRegion(FALSE, -1, -1, -1, -1); - } + /* blit the completely updated backbuffer to the window (in one blit) */ + BlitBitmap(backbuffer, window, SX, SY, SXSIZE, SYSIZE, SX, SY); for (x = 0; x < MAX_BUF_XSIZE; x++) for (y = 0; y < MAX_BUF_YSIZE; y++) redraw[x][y] = FALSE; redraw_tiles = 0; - - screen_x_last = screen_x; - screen_y_last = screen_y; - scrolling_last = scrolling; } void blitscreen(void) diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 271a6404..e7664f76 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -239,65 +239,14 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) void BackToFront_SP(void) { - static int scroll_x_last = -1, scroll_y_last = -1; - static boolean scrolling_last = FALSE; - static boolean ExplosionShakeMurphy_last = -1; - boolean scrolling = (mScrollX != scroll_x_last || mScrollY != scroll_y_last); int x, y; - if (0 || - redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last || - ExplosionShakeMurphy != 0 || ExplosionShakeMurphy_last != 0) - { - BlitScreenToBitmap_SP(window); - } - else - { - int scroll_xoffset = mScrollX - mScrollX_last + game_sp.scroll_xoffset; - int scroll_yoffset = mScrollY - mScrollY_last + game_sp.scroll_yoffset; - int x1 = 0, x2 = SCR_FIELDX - (scroll_xoffset != 0 ? 0 : 1); - int y1 = 0, y2 = SCR_FIELDY - (scroll_yoffset != 0 ? 0 : 1); - int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR; - int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR; - int xsize = SXSIZE; - int ysize = SYSIZE; - int sxsize = (full_xsize < xsize ? full_xsize : xsize); - int sysize = (full_ysize < ysize ? full_ysize : ysize); - int sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); - int sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); - - InitGfxClipRegion(TRUE, sx, sy, sxsize, sysize); - - scroll_xoffset = scroll_xoffset * TILESIZE_VAR / TILESIZE; - scroll_yoffset = scroll_yoffset * TILESIZE_VAR / TILESIZE; - - for (x = x1; x <= x2; x++) - { - for (y = y1; y <= y2; y++) - { - int xx = 2 + x; - int yy = 2 + y; - - if (redraw[xx][yy]) - BlitBitmap(bitmap_db_field_sp, window, - xx * TILEX_VAR, yy * TILEY_VAR, TILEX_VAR, TILEY_VAR, - sx + x * TILEX_VAR - scroll_xoffset, - sy + y * TILEY_VAR - scroll_yoffset); - } - } - - InitGfxClipRegion(FALSE, -1, -1, -1, -1); - } + BlitScreenToBitmap_SP(window); for (x = 0; x < 2 + MAX_PLAYFIELD_WIDTH + 2; x++) for (y = 0; y < 2 + MAX_PLAYFIELD_HEIGHT + 2; y++) redraw[x][y] = FALSE; redraw_tiles = 0; - - scroll_x_last = mScrollX; - scroll_y_last = mScrollY; - scrolling_last = scrolling; - ExplosionShakeMurphy_last = ExplosionShakeMurphy; } void DDScrollBuffer_ScrollTo(int X, int Y) diff --git a/src/libgame/system.h b/src/libgame/system.h index 645e82bf..86dc01ac 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -311,11 +311,6 @@ REDRAW_MICROLEVEL) #define REDRAW_FPS (1 << 11) -/* on modern graphics systems and when using the SDL target, the old tile redraw - optimization can slow things down a lot due to many small blits compared to - one single playfield-sized blit (especially observed on Mac OS X with SDL) */ -#define REDRAWTILES_THRESHOLD 0 - #define IN_GFX_FIELD_PLAY(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ y >= gfx.sy && y < gfx.sy + gfx.sysize) #define IN_GFX_FIELD_FULL(x, y) (x >= gfx.real_sx && \ diff --git a/src/tools.c b/src/tools.c index 9c8263b6..be46e021 100644 --- a/src/tools.c +++ b/src/tools.c @@ -448,17 +448,9 @@ void BackToFront() int x, y; DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field); - if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD) - redraw_mask |= REDRAW_FIELD; - -#if 0 // never redraw single tiles, always redraw the whole field - // (redrawing single tiles up to a certain threshold was faster on old, - // now legacy graphics, but slows things down on modern graphics now) - // UPDATE: this is now globally defined by value of REDRAWTILES_THRESHOLD if (redraw_mask & REDRAW_TILES) redraw_mask |= REDRAW_FIELD; -#endif #if 0 /* !!! TEST ONLY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ @@ -585,70 +577,6 @@ void BackToFront() redraw_mask &= ~REDRAW_MICROLEVEL; } - if (redraw_mask & REDRAW_TILES) - { - int sx = SX; - int sy = SY; - - int dx = 0, dy = 0; - int dx_var = dx * TILESIZE_VAR / TILESIZE; - int dy_var = dy * TILESIZE_VAR / TILESIZE; - int ffx, ffy; - int fx = FX, fy = FY; - - int scr_fieldx = SCR_FIELDX + (EVEN(SCR_FIELDX) ? 2 : 0); - int scr_fieldy = SCR_FIELDY + (EVEN(SCR_FIELDY) ? 2 : 0); - - InitGfxClipRegion(TRUE, SX, SY, SXSIZE, SYSIZE); - - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; - ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; - - if (EVEN(SCR_FIELDX)) - { - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) - { - fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; - - if (fx % TILEX_VAR) - sx -= TILEX_VAR / 2; - else - sx -= TILEX_VAR; - } - else - { - fx += (dx_var > 0 ? TILEX_VAR : 0); - } - } - - if (EVEN(SCR_FIELDY)) - { - if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) - { - fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR; - - if (fy % TILEY_VAR) - sy -= TILEY_VAR / 2; - else - sy -= TILEY_VAR; - } - else - { - fy += (dy_var > 0 ? TILEY_VAR : 0); - } - } - - for (x = 0; x < scr_fieldx; x++) - for (y = 0 ; y < scr_fieldy; y++) - if (redraw[redraw_x1 + x][redraw_y1 + y]) - BlitBitmap(buffer, window, - FX + x * TILEX_VAR, FY + y * TILEY_VAR, - TILEX_VAR, TILEY_VAR, - sx + x * TILEX_VAR, sy + y * TILEY_VAR); - - InitGfxClipRegion(FALSE, -1, -1, -1, -1); - } - if (redraw_mask & REDRAW_FPS) /* display frames per second */ { char text[100];