removed unused code for single-tile playfield redraw
authorHolger Schemel <info@artsoft.org>
Fri, 15 May 2015 12:50:57 +0000 (14:50 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 15 May 2015 12:54:11 +0000 (14:54 +0200)
src/game_em/graphics.c
src/game_sp/DDScrollBuffer.c
src/libgame/system.h
src/tools.c

index 860cb36513544eaa4972a6d29e7569d18d5ac99c..05ac1a0231e197b6df1a430d0b30ba3081903d5e 100644 (file)
@@ -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)
index 271a6404a8626b0a52815798daa59f87a9250ea6..e7664f7651fc2ef81016562f805461a4179611bd 100644 (file)
@@ -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)
index 645e82bfd58c19d2af357a1641bf9f87696167bb..86dc01ac0ab0c6ac995fa8fc7595ffee8b632337 100644 (file)
                                 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 && \
index 9c8263b60c801a55eea4a89febbd1e134f895c42..be46e0211fc126d8e229b777bb7ef61c42b4a897 100644 (file)
@@ -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];