X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=77f574db3c25be10c396853295bf822bf25191ea;hb=a8b2caa1d373c84c1b3fc2f615370c2a319051ca;hp=3bf2c5a5ad9644c6587e4a4b1655528ff763a7e9;hpb=b9c7e4a42762c8526702726f1404d3e75dbc29f5;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 3bf2c5a5..77f574db 100644 --- a/src/tools.c +++ b/src/tools.c @@ -99,6 +99,36 @@ void BackToFront() if (!redraw_mask) return; + if (global.fps_slowdown && game_status == PLAYING) + { + static boolean last_frame_skipped = FALSE; + boolean skip_even_when_not_scrolling = TRUE; + boolean just_scrolling = (ScreenMovDir != 0); + boolean verbose = FALSE; + + if (global.fps_slowdown_factor > 1 && + (FrameCounter % global.fps_slowdown_factor) && + (just_scrolling || skip_even_when_not_scrolling)) + { + redraw_mask &= ~REDRAW_MAIN; + + last_frame_skipped = TRUE; + + if (verbose) + printf("FRAME SKIPPED\n"); + } + else + { + if (last_frame_skipped) + redraw_mask |= REDRAW_FIELD; + + last_frame_skipped = FALSE; + + 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, @@ -151,6 +181,7 @@ void BackToFront() #endif } } + redraw_mask &= ~REDRAW_MAIN; } @@ -207,6 +238,19 @@ void BackToFront() SX + x * TILEX, SY + y * TILEY); } + 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%s", global.frames_per_second, info1); + DrawTextExt(window, gc, SX, SY, text, FS_SMALL, FC_YELLOW); + } + FlushDisplay(); for(x=0; x