Skip to content

Commit

Permalink
Add option to lock/unlock fps
Browse files Browse the repository at this point in the history
  • Loading branch information
aceiii committed Apr 8, 2024
1 parent 2207dcc commit b4689a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace fs = std::filesystem;

constexpr int kDefaultFPS = 60;
constexpr int kMaxSamples = 512;
constexpr int kMaxSamplesPerUpdate = 4096;
constexpr int kAudioSampleRate = 44100;
Expand Down Expand Up @@ -80,6 +81,10 @@ void Interface::initialize() {
});
PlayAudioStream(stream);

if (lock_fps) {
SetTargetFPS(kDefaultFPS);
}

SetExitKey(KEY_NULL);
rlImGuiSetup(true);

Expand Down Expand Up @@ -529,6 +534,15 @@ void Interface::render_main_menu() {
ImGui::MenuItem("Registers", nullptr, &show_registers);
ImGui::MenuItem("Miscellaneous", nullptr, &show_misc);
ImGui::Separator();
if (ImGui::MenuItem("Lock FPS", nullptr, &lock_fps)) {
if (lock_fps) {
spdlog::debug("Locking FPS");
SetTargetFPS(kDefaultFPS);
} else {
spdlog::debug("Unlocking FPS");
SetTargetFPS(0);
}
}
ImGui::MenuItem("Show FPS", nullptr, &show_fps);
ImGui::MenuItem("ImGui Demo", nullptr, &show_demo);
ImGui::Separator();
Expand Down
1 change: 1 addition & 0 deletions src/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Interface {

std::vector<uint8_t> rom;

bool lock_fps = true;
bool init_dock = true;
bool should_close = false;
bool show_demo = false;
Expand Down

0 comments on commit b4689a8

Please sign in to comment.