mGUI: Fix FPS counter after closing menu

This commit is contained in:
Vicki Pfau 2022-02-27 21:17:06 -08:00
parent 64d8dd1b69
commit c284506c1b
2 changed files with 9 additions and 5 deletions

View File

@ -41,6 +41,7 @@ Other fixes:
- FFmpeg: Fix GIF recording (fixes mgba.io/i/2393)
- GB: Fix temporary saves
- GB, GBA: Save writeback-pending masked saves on unload (fixes mgba.io/i/2396)
- mGUI: Fix FPS counter after closing menu
- VFS: Failed file mapping should return NULL on POSIX
Misc:
- Core: Suspend runloop when a core crashes

View File

@ -25,8 +25,8 @@ mLOG_DECLARE_CATEGORY(GUI_RUNNER);
mLOG_DEFINE_CATEGORY(GUI_RUNNER, "GUI Runner", "gui.runner");
#define AUTOSAVE_GRANULARITY 600
#define FPS_GRANULARITY 120
#define FPS_BUFFER_SIZE 3
#define FPS_GRANULARITY 30
#define FPS_BUFFER_SIZE 4
enum {
RUNNER_CONTINUE = 1,
@ -491,10 +491,10 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
runner->gameLoaded(runner);
}
mLOG(GUI_RUNNER, INFO, "Game starting");
runner->fps = 0;
while (running) {
CircleBufferClear(&runner->fpsBuffer);
runner->totalDelta = 0;
runner->fps = 0;
struct timeval tv;
gettimeofday(&tv, 0);
runner->lastFpsCheck = 1000000LL * tv.tv_sec + tv.tv_usec;
@ -593,7 +593,8 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
}
runner->params.drawEnd();
if (runner->core->frameCounter(runner->core) % FPS_GRANULARITY == 0) {
++frame;
if (frame % FPS_GRANULARITY == 0) {
if (drawFps) {
struct timeval tv;
gettimeofday(&tv, 0);
@ -618,7 +619,9 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
frame = 0;
_tryAutosave(runner);
}
++frame;
if (frame == FPS_GRANULARITY * AUTOSAVE_GRANULARITY) {
frame = 0;
}
}
}
if (!running) {