diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index feabd7ec62..0e31aad5ac 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -270,6 +270,31 @@ static const char* ReportVideoMode() } } +Fixed100 GetVerticalFrequency() +{ + switch (gsVideoMode) + { + case GS_VideoMode::Uninitialized: // SYSCALL instruction hasn't executed yet, give some temporary values. + return 60; + case GS_VideoMode::PAL: + return EmuConfig.GS.FrameratePAL; + case GS_VideoMode::NTSC: + return EmuConfig.GS.FramerateNTSC; + case GS_VideoMode::HDTV_480P: + return 59.94; + case GS_VideoMode::HDTV_1080P: + case GS_VideoMode::HDTV_1080I: + case GS_VideoMode::HDTV_576P: + case GS_VideoMode::HDTV_720P: + case GS_VideoMode::VESA: + case GS_VideoMode::BIOS: + return 60; + default: + // Pass NTSC vertical frequency value when unknown video mode is detected. + return FRAMERATE_NTSC * 2; + } +} + u32 UpdateVSyncRate() { // Notice: (and I probably repeat this elsewhere, but it's worth repeating) @@ -278,7 +303,7 @@ u32 UpdateVSyncRate() // the GS's output circuit. It is the same regardless if the GS is outputting interlace // or progressive scan content. - Fixed100 framerate = 0; + Fixed100 framerate = GetVerticalFrequency() / 2; u32 scanlines = 0; bool isCustom = false; @@ -286,36 +311,28 @@ u32 UpdateVSyncRate() switch (gsVideoMode) { case GS_VideoMode::Uninitialized: // SYSCALL instruction hasn't executed yet, give some temporary values. - framerate = 60; scanlines = SCANLINES_TOTAL_NTSC; break; case GS_VideoMode::PAL: isCustom = (EmuConfig.GS.FrameratePAL != 50.0); - framerate = EmuConfig.GS.FrameratePAL / 2; scanlines = SCANLINES_TOTAL_PAL; if (!gsIsInterlaced) scanlines += 3; break; case GS_VideoMode::NTSC: isCustom = (EmuConfig.GS.FramerateNTSC != 59.94); - framerate = EmuConfig.GS.FramerateNTSC / 2; scanlines = SCANLINES_TOTAL_NTSC; if (!gsIsInterlaced) scanlines += 1; break; case GS_VideoMode::HDTV_480P: - framerate = 29.97; - scanlines = SCANLINES_TOTAL_NTSC; - break; - case GS_VideoMode::HDTV_1080P: case GS_VideoMode::HDTV_1080I: case GS_VideoMode::HDTV_576P: case GS_VideoMode::HDTV_720P: case GS_VideoMode::VESA: case GS_VideoMode::BIOS: - framerate = 30; scanlines = SCANLINES_TOTAL_NTSC; break; @@ -323,7 +340,6 @@ u32 UpdateVSyncRate() case GS_VideoMode::Unknown: // For Release builds, keep using the NTSC timing values when unknown video mode is detected. // Assert will be triggered for debug/dev builds. - framerate = FRAMERATE_NTSC; scanlines = SCANLINES_TOTAL_NTSC; Console.Error("PCSX2-Counters: Unknown video mode detected"); diff --git a/pcsx2/Counters.h b/pcsx2/Counters.h index bc19e92d4d..e1ff51af07 100644 --- a/pcsx2/Counters.h +++ b/pcsx2/Counters.h @@ -123,6 +123,7 @@ struct SyncCounter #define MODE_HBLANK 0x1 //Set for the remaining ~1/6 of 1 Scanline +extern Fixed100 GetVerticalFrequency(); extern Counter counters[4]; extern SyncCounter hsyncCounter; extern SyncCounter vsyncCounter; diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index 47204707cc..7a9659e5e5 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -18,7 +18,7 @@ #include "GSFrame.h" #include "AppAccelerators.h" #include "AppSaveStates.h" - +#include "Counters.h" #include "GS.h" #include "MSWstuff.h" @@ -591,8 +591,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt ) AppConfig::UiTemplateOptions& templates = g_Conf->Templates; double fps = wxGetApp().FpsManager.GetFramerate(); - // The "not PAL" case covers both NTSC and Progressive - float per = gsVideoMode == GS_VideoMode::PAL ? (fps * 100) / EmuConfig.GS.FrameratePAL.ToFloat() : (fps * 100) / EmuConfig.GS.FramerateNTSC.ToFloat(); + float percentage = (fps * 100) / GetVerticalFrequency().ToFloat(); char gsDest[128]; gsDest[0] = 0; // No need to set whole array to NULL. @@ -630,7 +629,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt ) wxString title = templates.TitleTemplate; title.Replace(L"${slot}", pxsFmt(L"%d", States_GetCurrentSlot())); title.Replace(L"${limiter}", limiterStr); - title.Replace(L"${speed}", pxsFmt(L"%3d%%", lround(per))); + title.Replace(L"${speed}", pxsFmt(L"%3d%%", lround(percentage))); title.Replace(L"${vfps}", pxsFmt(L"%.02f", fps)); title.Replace(L"${cpuusage}", cpuUsage); title.Replace(L"${omodef}", omodef);