CheckLevelTime();
AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */
+
+ if (options.debug) /* calculate frames per second */
+ {
+ static unsigned int fps_counter = 0;
+ static int fps_frames = 0;
+ unsigned int 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;
+ }
}
void GameActions_EM_Main()
DrawAllPlayers();
PlayAllPlayersSound();
- if (options.debug) /* calculate frames per second */
- {
- static unsigned int fps_counter = 0;
- static int fps_frames = 0;
- unsigned int 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;
- }
-
if (local_player->show_envelope != 0 && local_player->MovPos == 0)
{
ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1);
redraw_mask |= REDRAW_FIELD;
}
+void DrawFramesPerSecond()
+{
+ char text[100];
+ int font_nr = FONT_TEXT_2;
+ int font_width = getFontWidth(font_nr);
+
+ sprintf(text, "%04.1f fps", global.frames_per_second);
+
+ DrawTextExt(backbuffer, WIN_XSIZE - font_width * strlen(text), 0, text,
+ font_nr, BLIT_OPAQUE);
+}
+
void BackToFront()
{
if (redraw_mask == REDRAW_NONE)
// draw masked border to all viewports, if defined
DrawMaskedBorder(redraw_mask);
+ // draw frames per second (only if debug mode is enabled)
+ if (redraw_mask & REDRAW_FPS)
+ DrawFramesPerSecond();
+
// redraw complete window if both playfield and (some) doors need redraw
if (redraw_mask & REDRAW_FIELD && redraw_mask & REDRAW_DOORS)
redraw_mask = REDRAW_ALL;