Frontend: Display emulation speed
This commit is contained in:
parent
4d22bec8fd
commit
162a0df922
|
@ -81,6 +81,13 @@ bool System::Initialize()
|
|||
|
||||
bool System::DoState(StateWrapper& sw)
|
||||
{
|
||||
if (!sw.DoMarker("System"))
|
||||
return false;
|
||||
|
||||
sw.Do(&m_frame_number);
|
||||
sw.Do(&m_internal_frame_number);
|
||||
sw.Do(&m_global_tick_counter);
|
||||
|
||||
if (!sw.DoMarker("CPU") || !m_cpu->DoState(sw))
|
||||
return false;
|
||||
|
||||
|
@ -127,6 +134,8 @@ void System::Reset()
|
|||
m_spu->Reset();
|
||||
m_mdec->Reset();
|
||||
m_frame_number = 1;
|
||||
m_internal_frame_number = 0;
|
||||
m_global_tick_counter = 0;
|
||||
}
|
||||
|
||||
bool System::LoadState(ByteStream* state)
|
||||
|
@ -268,10 +277,11 @@ bool System::SetExpansionROM(const char* filename)
|
|||
|
||||
void System::Synchronize()
|
||||
{
|
||||
m_cpu->ResetDowncount();
|
||||
|
||||
const TickCount pending_ticks = m_cpu->GetPendingTicks();
|
||||
m_cpu->ResetPendingTicks();
|
||||
m_cpu->ResetDowncount();
|
||||
|
||||
m_global_tick_counter += static_cast<u32>(pending_ticks);
|
||||
|
||||
m_gpu->Execute(pending_ticks);
|
||||
m_timers->AddSystemTicks(pending_ticks);
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
|
||||
u32 GetFrameNumber() const { return m_frame_number; }
|
||||
u32 GetInternalFrameNumber() const { return m_internal_frame_number; }
|
||||
u32 GetGlobalTickCounter() const { return m_global_tick_counter; }
|
||||
void IncrementFrameNumber() { m_frame_number++; }
|
||||
void IncrementInternalFrameNumber() { m_internal_frame_number++; }
|
||||
|
||||
|
@ -79,6 +80,7 @@ private:
|
|||
std::unique_ptr<MDEC> m_mdec;
|
||||
u32 m_frame_number = 1;
|
||||
u32 m_internal_frame_number = 1;
|
||||
u32 m_global_tick_counter = 0;
|
||||
|
||||
Settings m_settings;
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue