projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d2457f7
)
fixed displaying frames per second (debug mode only)
author
Holger Schemel
<info@artsoft.org>
Tue, 19 May 2015 07:36:20 +0000
(09:36 +0200)
committer
Holger Schemel
<info@artsoft.org>
Tue, 19 May 2015 07:36:20 +0000
(09:36 +0200)
src/game.c
patch
|
blob
|
history
src/tools.c
patch
|
blob
|
history
diff --git
a/src/game.c
b/src/game.c
index 49acec5bed46a4c70b979dd4fc3f5d795284c645..2be5985f4466cde783be13950cba59ce4a7c79b0 100644
(file)
--- a/
src/game.c
+++ b/
src/game.c
@@
-11202,6
+11202,25
@@
void GameActions()
CheckLevelTime();
AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */
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()
}
void GameActions_EM_Main()
@@
-11735,25
+11754,6
@@
void GameActions_RND()
DrawAllPlayers();
PlayAllPlayersSound();
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);
if (local_player->show_envelope != 0 && local_player->MovPos == 0)
{
ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1);
diff --git
a/src/tools.c
b/src/tools.c
index 39a0d68140e3f6e47f374e489a15767d7eb27e10..0813343df51fcdc5cee07479518aff07ef59739d 100644
(file)
--- a/
src/tools.c
+++ b/
src/tools.c
@@
-419,6
+419,18
@@
void BlitScreenToBitmap(Bitmap *target_bitmap)
redraw_mask |= REDRAW_FIELD;
}
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)
void BackToFront()
{
if (redraw_mask == REDRAW_NONE)
@@
-431,6
+443,10
@@
void BackToFront()
// draw masked border to all viewports, if defined
DrawMaskedBorder(redraw_mask);
// 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;
// redraw complete window if both playfield and (some) doors need redraw
if (redraw_mask & REDRAW_FIELD && redraw_mask & REDRAW_DOORS)
redraw_mask = REDRAW_ALL;