Frontend: Display emulation speed

This commit is contained in:
Connor McLaughlin
2019-10-04 20:48:29 +10:00
parent 4d22bec8fd
commit 162a0df922
4 changed files with 32 additions and 3 deletions

View File

@ -562,7 +562,17 @@ void SDLInterface::RenderMainMenuBar()
ImGui::EndMenu();
}
ImGui::SetCursorPosX(ImGui::GetIO().DisplaySize.x - 170.0f);
ImGui::SetCursorPosX(ImGui::GetIO().DisplaySize.x - 205.0f);
const u32 rounded_speed = static_cast<u32>(std::round(m_speed));
if (m_speed < 90.0f)
ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "%u%%", rounded_speed);
else if (m_speed < 110.0f)
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.0f), "%u%%", rounded_speed);
else
ImGui::TextColored(ImVec4(0.4f, 1.0f, 0.4f, 1.0f), "%u%%", rounded_speed);
ImGui::SetCursorPosX(ImGui::GetIO().DisplaySize.x - 165.0f);
ImGui::Text("FPS: %.2f", m_fps);
ImGui::SetCursorPosX(ImGui::GetIO().DisplaySize.x - 80.0f);
@ -680,6 +690,11 @@ void SDLInterface::Run()
m_fps = static_cast<float>(
static_cast<double>(m_system->GetInternalFrameNumber() - m_last_internal_frame_number) / time);
m_last_internal_frame_number = m_system->GetInternalFrameNumber();
m_speed =
static_cast<float>(static_cast<double>(m_system->GetGlobalTickCounter() - m_last_global_tick_counter) /
(static_cast<double>(MASTER_CLOCK) * time)) *
100.0f;
m_last_global_tick_counter = m_system->GetGlobalTickCounter();
m_fps_timer.Reset();
}
}

View File

@ -84,8 +84,10 @@ private:
float m_vps = 0.0f;
float m_fps = 0.0f;
float m_speed = 1.0f;
u32 m_last_frame_number = 0;
u32 m_last_internal_frame_number = 0;
u32 m_last_global_tick_counter = 0;
Timer m_fps_timer;
// UI options