rnd-20000831-1-src
[rocksndiamonds.git] / src / tools.c
index 685323c8a45ac9497ec0748431db40dd0133812d..d4e42abbafe356c94354a505e4c547aecba8a343 100644 (file)
@@ -99,6 +99,49 @@ void BackToFront()
   if (!redraw_mask)
     return;
 
+
+
+  if (1 &&   game_status == PLAYING)
+  {
+    static boolean last_frame_skipped = 0;
+    int fps_slowdown_factor = 2;
+    boolean skip_even_when_not_scrolling = 1;
+    boolean just_scrolling = (ScreenMovDir != 0);
+    boolean p = 0;
+
+    /*
+    printf("ScreenMovDir = %d\n", ScreenMovDir);
+    */
+
+    /*
+    printf("ScreenGfxPos = %d\n", ScreenGfxPos);
+    */
+
+    if (fps_slowdown_factor > 1 &&
+       (FrameCounter % fps_slowdown_factor) &&
+       (just_scrolling || skip_even_when_not_scrolling))
+    {
+      redraw_mask &= ~REDRAW_MAIN;
+
+      if (p)
+       printf("FRAME SKIPPED\n");
+
+      last_frame_skipped = 1;
+    }
+    else
+    {
+      if (last_frame_skipped)
+       redraw_mask |= REDRAW_FIELD;
+
+      last_frame_skipped = 0;
+
+      if (p)
+       printf("frame not skipped\n");
+    }
+  }
+
+
+
   /* synchronize X11 graphics at this point; if we would synchronize the
      display immediately after the buffer switching (after the XFlush),
      this could mean that we have to wait for the graphics to complete,
@@ -151,6 +194,7 @@ void BackToFront()
 #endif
       }
     }
+
     redraw_mask &= ~REDRAW_MAIN;
   }
 
@@ -207,6 +251,14 @@ void BackToFront()
                     SX + x * TILEX, SY + y * TILEY);
   }
 
+  if (redraw_mask & REDRAW_FPS)                /* display frames per second */
+  {
+    char text[100];
+
+    sprintf(text, "%.1f fps", global.frames_per_second);
+    DrawTextExt(window, gc, SX, SY, text, FS_SMALL, FC_YELLOW);
+  }
+
   FlushDisplay();
 
   for(x=0; x<MAX_BUF_XSIZE; x++)