From 414a959b6997787858fe2a6a6b65ecefeec777ce Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Tue, 9 Jan 2024 10:46:12 -0600 Subject: [PATCH] fix(nes): remove sleep during run * Removed sleep from run_nes_rom, run_sms_rom, and run_gameboy_rom since the sleep does not affect performance but it degrades sound (specifically on NES) --- components/gbc/src/gameboy.cpp | 3 --- components/nes/src/nes.cpp | 3 --- components/sms/src/sms.cpp | 3 --- 3 files changed, 9 deletions(-) diff --git a/components/gbc/src/gameboy.cpp b/components/gbc/src/gameboy.cpp index 58fe0a6a..b26bee69 100644 --- a/components/gbc/src/gameboy.cpp +++ b/components/gbc/src/gameboy.cpp @@ -115,9 +115,6 @@ void run_to_vblank() { auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration(end-start).count(); update_frame_time(elapsed); - // frame rate should be 60 FPS, so 1/60th second is what we want to sleep for - static constexpr auto delay = std::chrono::duration(1.0f/60.0f); - std::this_thread::sleep_until(start + delay); } void reset_gameboy() { diff --git a/components/nes/src/nes.cpp b/components/nes/src/nes.cpp index 69d43cee..7eb5f060 100644 --- a/components/nes/src/nes.cpp +++ b/components/nes/src/nes.cpp @@ -61,9 +61,6 @@ void run_nes_rom() { auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration(end-start).count(); update_frame_time(elapsed); - // frame rate should be 60 FPS, so 1/60th second is what we want to sleep for - static constexpr auto delay = std::chrono::duration(1.0f/60.0f); - std::this_thread::sleep_until(start + delay); } void load_nes(std::string_view save_path) { diff --git a/components/sms/src/sms.cpp b/components/sms/src/sms.cpp index 18981116..ae3e9eda 100644 --- a/components/sms/src/sms.cpp +++ b/components/sms/src/sms.cpp @@ -192,9 +192,6 @@ void run_sms_rom() { auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration(end-start).count(); update_frame_time(elapsed); - // frame rate should be 60 FPS, so 1/60th second is what we want to sleep for - static constexpr auto delay = std::chrono::duration(1.0f/60.0f); - std::this_thread::sleep_until(start + delay); } void load_sms(std::string_view save_path) {