diff --git a/include/app/app.h b/include/app/app.h index 213ee73..a0dbf0e 100644 --- a/include/app/app.h +++ b/include/app/app.h @@ -86,9 +86,10 @@ enum bind_actions { BIND_EMULATOR_PAUSE, BIND_EMULATOR_STOP, BIND_EMULATOR_RESET, + BIND_EMULATOR_SHOW_FPS, + BIND_EMULATOR_SETTINGS, BIND_EMULATOR_ALT_SPEED_HOLD, BIND_EMULATOR_ALT_SPEED_TOGGLE, - BIND_EMULATOR_SETTINGS, BIND_EMULATOR_QUICKSAVE_1, BIND_EMULATOR_QUICKSAVE_2, BIND_EMULATOR_QUICKSAVE_3, @@ -160,6 +161,12 @@ struct settings { // BIOS Path char *bios_path; + // Skip BIOS + bool skip_bios; + + // Show FPS + bool show_fps; + // Speed // <= 0: Unlimited // 1.0: 60fps @@ -174,9 +181,6 @@ struct settings { // etc. float alt_speed; - // Skip BIOS - bool skip_bios; - // Backup storage struct { bool autodetect; diff --git a/source/app/bindings.c b/source/app/bindings.c index 62456f6..a717c38 100644 --- a/source/app/bindings.c +++ b/source/app/bindings.c @@ -40,6 +40,7 @@ app_bindings_setup_default( app_bindings_keyboard_binding_build(&app->binds.keyboard[BIND_EMULATOR_RESET], SDL_GetKeyFromName("R"), true, false, false); app_bindings_keyboard_binding_build(&app->binds.keyboard[BIND_EMULATOR_MUTE], SDL_GetKeyFromName("M"), true, false, false); app_bindings_keyboard_binding_build(&app->binds.keyboard[BIND_EMULATOR_PAUSE], SDL_GetKeyFromName("P"), true, false, false); + app_bindings_keyboard_binding_build(&app->binds.keyboard[BIND_EMULATOR_SHOW_FPS], SDL_GetKeyFromName("F"), true, false, false); app_bindings_keyboard_binding_build(&app->binds.keyboard[BIND_EMULATOR_SETTINGS], SDL_GetKeyFromName("Escape"), false, false, false); app_bindings_keyboard_binding_build(&app->binds.keyboard[BIND_EMULATOR_SCREENSHOT], SDL_GetKeyFromName("F12"), false, false, false); app_bindings_keyboard_binding_build(&app->binds.keyboard[BIND_EMULATOR_ALT_SPEED_HOLD], SDL_GetKeyFromName("Space"), false, false, false); @@ -216,11 +217,10 @@ app_bindings_handle( // Bindings that can be used both in and outside of a game switch (bind) { - case BIND_EMULATOR_SETTINGS: { - app->ui.settings.open ^= true; - break; - }; - default: break; + case BIND_EMULATOR_MUTE: app->settings.audio.mute ^= true; break; + case BIND_EMULATOR_SHOW_FPS: app->settings.emulation.show_fps ^= true; break; + case BIND_EMULATOR_SETTINGS: app->ui.settings.open ^= true; break; + default: break; } if (!app->emulation.is_started) { @@ -229,7 +229,6 @@ app_bindings_handle( // Bindings that can only be used in game. switch (bind) { - case BIND_EMULATOR_MUTE: app->settings.audio.mute ^= 1; break; case BIND_EMULATOR_SCREENSHOT: app_emulator_screenshot(app); break; case BIND_EMULATOR_PAUSE: app->emulation.is_running ? app_emulator_pause(app) : app_emulator_run(app); break; case BIND_EMULATOR_STOP: app_emulator_stop(app); break; diff --git a/source/app/config.c b/source/app/config.c index 483d22a..8b72cee 100644 --- a/source/app/config.c +++ b/source/app/config.c @@ -76,6 +76,14 @@ app_config_load( int b; double d; + if (mjson_get_bool(data, data_len, "$.emulation.skip_bios", &b)) { + app->settings.emulation.skip_bios = b; + } + + if (mjson_get_bool(data, data_len, "$.emulation.show_fps", &b)) { + app->settings.emulation.show_fps = b; + } + if (mjson_get_number(data, data_len, "$.emulation.speed", &d)) { app->settings.emulation.speed = d; } @@ -99,10 +107,6 @@ app_config_load( if (mjson_get_number(data, data_len, "$.emulation.gpio.type", &d)) { app->settings.emulation.gpio_device.type = max(GPIO_MIN, min((int)d, GPIO_MAX)); } - - if (mjson_get_bool(data, data_len, "$.emulation.skip_bios", &b)) { - app->settings.emulation.skip_bios = b; - } } // Video @@ -294,6 +298,7 @@ app_config_save( // Emulation "emulation": { "skip_bios": %B, + "show_fps": %B, "speed": %g, "alt_speed": %g, "backup_storage": { @@ -342,6 +347,7 @@ app_config_save( app->file.recent_roms[8], app->file.recent_roms[9], (int)app->settings.emulation.skip_bios, + (int)app->settings.emulation.show_fps, app->settings.emulation.speed, app->settings.emulation.alt_speed, (int)app->settings.emulation.backup_storage.autodetect, diff --git a/source/app/windows/menubar.c b/source/app/windows/menubar.c index 9fba9ba..b9da0d3 100644 --- a/source/app/windows/menubar.c +++ b/source/app/windows/menubar.c @@ -488,8 +488,13 @@ void app_win_menubar_fps_counter( struct app *app ) { - /* FPS Counter */ - if (app->emulation.is_started && app->emulation.is_running && igGetWindowWidth() >= GBA_SCREEN_WIDTH * 2 * app->ui.scale) { + // FPS Counter + if ( + app->settings.emulation.show_fps + && app->emulation.is_started + && app->emulation.is_running + && igGetWindowWidth() >= GBA_SCREEN_WIDTH * 2 * app->ui.scale + ) { float spacing; ImVec2 out; diff --git a/source/app/windows/settings.c b/source/app/windows/settings.c index 5a031c1..66bdaa0 100644 --- a/source/app/windows/settings.c +++ b/source/app/windows/settings.c @@ -68,9 +68,10 @@ char const * const binds_pretty_name[] = { [BIND_EMULATOR_PAUSE] = "Pause", [BIND_EMULATOR_STOP] = "Stop", [BIND_EMULATOR_RESET] = "Reset", + [BIND_EMULATOR_SHOW_FPS] = "Show FPS", + [BIND_EMULATOR_SETTINGS] = "Settings", [BIND_EMULATOR_ALT_SPEED_TOGGLE] = "Alt. Speed (Toggle)", [BIND_EMULATOR_ALT_SPEED_HOLD] = "Alt. Speed (Hold)", - [BIND_EMULATOR_SETTINGS] = "Settings", [BIND_EMULATOR_QUICKSAVE_1] = "Quicksave 1", [BIND_EMULATOR_QUICKSAVE_2] = "Quicksave 2", [BIND_EMULATOR_QUICKSAVE_3] = "Quicksave 3", @@ -110,9 +111,10 @@ char const * const binds_slug[] = { [BIND_EMULATOR_PAUSE] = "pause", [BIND_EMULATOR_STOP] = "stop", [BIND_EMULATOR_RESET] = "reset", + [BIND_EMULATOR_SHOW_FPS] = "show_fps", + [BIND_EMULATOR_SETTINGS] = "settings", [BIND_EMULATOR_ALT_SPEED_TOGGLE] = "alternative_speed_toggle", [BIND_EMULATOR_ALT_SPEED_HOLD] = "alternative_speed_hold", - [BIND_EMULATOR_SETTINGS] = "settings", [BIND_EMULATOR_QUICKSAVE_1] = "quicksave_1", [BIND_EMULATOR_QUICKSAVE_2] = "quicksave_2", [BIND_EMULATOR_QUICKSAVE_3] = "quicksave_3", @@ -329,6 +331,23 @@ app_win_settings_emulation( igEndTable(); } + + igSeparatorText("Misc"); + + if (igBeginTable("##EmulationSettingsMisc", 2, ImGuiTableFlags_None, (ImVec2){ .x = 0.f, .y = 0.f }, 0.f)) { + igTableSetupColumn("##EmulationSettingsMiscLabel", ImGuiTableColumnFlags_WidthFixed, vp->WorkSize.x / 5.f, 0); + igTableSetupColumn("##EmulationSettingsMiscValue", ImGuiTableColumnFlags_WidthStretch, 0.f, 0); + + // Show FPS + igTableNextRow(ImGuiTableRowFlags_None, 0.f); + igTableNextColumn(); + igTextWrapped("Show FPS"); + + igTableNextColumn(); + igCheckbox("##ShowFPS", &app->settings.emulation.show_fps); + + igEndTable(); + } } static