rnd-20000901-1-src
authorHolger Schemel <info@artsoft.org>
Fri, 1 Sep 2000 17:55:53 +0000 (19:55 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:34:52 +0000 (10:34 +0200)
src/events.c
src/main.h
src/misc.c
src/tools.c

index d7466911d0ac044b89be05bc38ee56a1a19013f0..a46f3548117071086e8be052b6024e40e7c0647b 100644 (file)
@@ -619,6 +619,38 @@ void HandleKey(Key key, int key_status)
                 GAME_FRAME_DELAY * 100 / GameFrameDelay, GameFrameDelay);
          break;
 
+       case KEY_d:
+         if (options.debug)
+         {
+           options.debug = FALSE;
+           printf("debug mode disabled\n");
+         }
+         else
+         {
+           options.debug = TRUE;
+           printf("debug mode enabled\n");
+         }
+         break;
+
+       case KEY_s:
+         if (!global.fps_slowdown)
+         {
+           global.fps_slowdown = TRUE;
+           global.fps_slowdown_factor = 2;
+           printf("fps slowdown enabled -- display only every 2nd frame\n");
+         }
+         else if (global.fps_slowdown_factor == 2)
+         {
+           global.fps_slowdown_factor = 4;
+           printf("fps slowdown enabled -- display only every 4th frame\n");
+         }
+         else
+         {
+           global.fps_slowdown = FALSE;
+           global.fps_slowdown_factor = 1;
+           printf("fps slowdown disabled\n");
+         }
+         break;
 
 #if 0
        case KEY_a:
index dfec496c843bb5491109a66fa61c187e2f4faa77..fca22e59f5e0d49a54fc373461e0819866d93057 100644 (file)
@@ -445,6 +445,8 @@ struct GameInfo
 struct GlobalInfo
 {
   float frames_per_second;
+  boolean fps_slowdown;
+  int fps_slowdown_factor;
 };
 
 extern Display        *display;
index 90bbe16a0ffc1baeb99fac530ca07264ad977ebd..2389f59a8c8bdd2bb69f71fd4412a002fff3e12d 100644 (file)
@@ -468,6 +468,8 @@ void GetOptions(char *argv[])
 
   /* initialize some more global variables */
   global.frames_per_second = 0;
+  global.fps_slowdown = FALSE;
+  global.fps_slowdown_factor = 1;
 
   while (*options_left)
   {
index d4e42abbafe356c94354a505e4c547aecba8a343..89ad7c741bdd1103a25f181a5111eef4390a6182 100644 (file)
@@ -99,49 +99,36 @@ void BackToFront()
   if (!redraw_mask)
     return;
 
-
-
-  if (1 &&   game_status == PLAYING)
+  if (global.fps_slowdown && game_status == PLAYING)
   {
-    static boolean last_frame_skipped = 0;
-    int fps_slowdown_factor = 2;
-    boolean skip_even_when_not_scrolling = 1;
+    static boolean last_frame_skipped = FALSE;
+    boolean skip_even_when_not_scrolling = TRUE;
     boolean just_scrolling = (ScreenMovDir != 0);
-    boolean p = 0;
-
-    /*
-    printf("ScreenMovDir = %d\n", ScreenMovDir);
-    */
+    boolean verbose = FALSE;
 
-    /*
-    printf("ScreenGfxPos = %d\n", ScreenGfxPos);
-    */
-
-    if (fps_slowdown_factor > 1 &&
-       (FrameCounter % fps_slowdown_factor) &&
+    if (global.fps_slowdown_factor > 1 &&
+       (FrameCounter % global.fps_slowdown_factor) &&
        (just_scrolling || skip_even_when_not_scrolling))
     {
       redraw_mask &= ~REDRAW_MAIN;
 
-      if (p)
-       printf("FRAME SKIPPED\n");
+      last_frame_skipped = TRUE;
 
-      last_frame_skipped = 1;
+      if (verbose)
+       printf("FRAME SKIPPED\n");
     }
     else
     {
       if (last_frame_skipped)
        redraw_mask |= REDRAW_FIELD;
 
-      last_frame_skipped = 0;
+      last_frame_skipped = FALSE;
 
-      if (p)
+      if (verbose)
        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,
@@ -254,8 +241,13 @@ void BackToFront()
   if (redraw_mask & REDRAW_FPS)                /* display frames per second */
   {
     char text[100];
+    char info1[100];
+
+    sprintf(info1, " (only every %d. frame)", global.fps_slowdown_factor);
+    if (!global.fps_slowdown)
+      info1[0] = '\0';
 
-    sprintf(text, "%.1f fps", global.frames_per_second);
+    sprintf(text, "%.1f fps%s", global.frames_per_second, info1);
     DrawTextExt(window, gc, SX, SY, text, FS_SMALL, FC_YELLOW);
   }