From e7f66900facf9c3969dda46da7ab4842062111e1 Mon Sep 17 00:00:00 2001 From: Akash Date: Mon, 1 Aug 2016 20:22:18 +0530 Subject: [PATCH 1/2] Counters: Add a new function GetVerticalFrequency() No functional changes done, the current commit helps us to pass vertical frequency values of individual video modes to GUI code for accurate percentage calculation on titlebar. (which is done on the succeeding commit) --- pcsx2/Counters.cpp | 36 ++++++++++++++++++++++++++---------- pcsx2/Counters.h | 1 + 2 files changed, 27 insertions(+), 10 deletions(-) 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; From 005f63d45586e8f786940eeda743a60cd85373ca Mon Sep 17 00:00:00 2001 From: Akash Date: Mon, 1 Aug 2016 20:29:49 +0530 Subject: [PATCH 2/2] PCSX2-WX: Improve percentage calculation on GSFrame Calculate the percentage value using the vertical frequency fetched from counters. --- pcsx2/gui/FrameForGS.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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);