}
DrawAllPlayers();
+
+ if (options.debug) /* calculate frames per second */
+ {
+ static unsigned long fps_counter = 0;
+ static int fps_frames = 0;
+ unsigned long fps_delay_ms = Counter() - fps_counter;
+
+ fps_frames++;
+
+ if (fps_delay_ms >= 500) /* calculate fps every 0.5 seconds */
+ {
+ global.frames_per_second = 1000 * (float)fps_frames / fps_delay_ms;
+
+ fps_frames = 0;
+ fps_counter = Counter();
+ }
+
+ redraw_mask |= REDRAW_FPS;
+ }
}
static boolean AllPlayersInSight(struct PlayerInfo *player, int x, int y)
boolean serveronly;
boolean network;
boolean verbose;
+ boolean debug;
};
struct SetupJoystickInfo
struct GlobalInfo
{
- int dummy;
+ float frames_per_second;
};
extern Display *display;
#define REDRAW_MAIN (REDRAW_FIELD | \
REDRAW_TILES | \
REDRAW_MICROLEVEL)
+#define REDRAW_FPS (1 << 10)
#define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
/* areas in bitmap PIX_DOOR */
options.serveronly = FALSE;
options.network = FALSE;
options.verbose = FALSE;
+ options.debug = FALSE;
+
+ /* initialize some more global variables */
+ global.frames_per_second = 0;
while (*options_left)
{
"Options:\n"
" -d, --display machine:0 X server display\n"
" -b, --basepath directory alternative base directory\n"
- " -l, --level directory alternative level directory\n"
+ " -l, --level directory alternative level directory\n"
" -s, --serveronly only start network server\n"
" -n, --network network multiplayer game\n"
" -v, --verbose verbose mode\n",
{
options.verbose = TRUE;
}
+ else if (strncmp(option, "-debug", option_len) == 0)
+ {
+ options.debug = TRUE;
+ }
else if (*option == '-')
{
Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str);
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,
#endif
}
}
+
redraw_mask &= ~REDRAW_MAIN;
}
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++)