Merge pull request #1491 from ssakash/VFrequency

PCSX2-WX: Add proper vertical frequency values on GS Frame
This commit is contained in:
avih 2016-08-08 18:44:49 +03:00 committed by GitHub
commit f35c5f1c91
3 changed files with 30 additions and 14 deletions

View File

@ -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() u32 UpdateVSyncRate()
{ {
// Notice: (and I probably repeat this elsewhere, but it's worth repeating) // 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 // the GS's output circuit. It is the same regardless if the GS is outputting interlace
// or progressive scan content. // or progressive scan content.
Fixed100 framerate = 0; Fixed100 framerate = GetVerticalFrequency() / 2;
u32 scanlines = 0; u32 scanlines = 0;
bool isCustom = false; bool isCustom = false;
@ -286,36 +311,28 @@ u32 UpdateVSyncRate()
switch (gsVideoMode) switch (gsVideoMode)
{ {
case GS_VideoMode::Uninitialized: // SYSCALL instruction hasn't executed yet, give some temporary values. case GS_VideoMode::Uninitialized: // SYSCALL instruction hasn't executed yet, give some temporary values.
framerate = 60;
scanlines = SCANLINES_TOTAL_NTSC; scanlines = SCANLINES_TOTAL_NTSC;
break; break;
case GS_VideoMode::PAL: case GS_VideoMode::PAL:
isCustom = (EmuConfig.GS.FrameratePAL != 50.0); isCustom = (EmuConfig.GS.FrameratePAL != 50.0);
framerate = EmuConfig.GS.FrameratePAL / 2;
scanlines = SCANLINES_TOTAL_PAL; scanlines = SCANLINES_TOTAL_PAL;
if (!gsIsInterlaced) scanlines += 3; if (!gsIsInterlaced) scanlines += 3;
break; break;
case GS_VideoMode::NTSC: case GS_VideoMode::NTSC:
isCustom = (EmuConfig.GS.FramerateNTSC != 59.94); isCustom = (EmuConfig.GS.FramerateNTSC != 59.94);
framerate = EmuConfig.GS.FramerateNTSC / 2;
scanlines = SCANLINES_TOTAL_NTSC; scanlines = SCANLINES_TOTAL_NTSC;
if (!gsIsInterlaced) scanlines += 1; if (!gsIsInterlaced) scanlines += 1;
break; break;
case GS_VideoMode::HDTV_480P: case GS_VideoMode::HDTV_480P:
framerate = 29.97;
scanlines = SCANLINES_TOTAL_NTSC;
break;
case GS_VideoMode::HDTV_1080P: case GS_VideoMode::HDTV_1080P:
case GS_VideoMode::HDTV_1080I: case GS_VideoMode::HDTV_1080I:
case GS_VideoMode::HDTV_576P: case GS_VideoMode::HDTV_576P:
case GS_VideoMode::HDTV_720P: case GS_VideoMode::HDTV_720P:
case GS_VideoMode::VESA: case GS_VideoMode::VESA:
case GS_VideoMode::BIOS: case GS_VideoMode::BIOS:
framerate = 30;
scanlines = SCANLINES_TOTAL_NTSC; scanlines = SCANLINES_TOTAL_NTSC;
break; break;
@ -323,7 +340,6 @@ u32 UpdateVSyncRate()
case GS_VideoMode::Unknown: case GS_VideoMode::Unknown:
// For Release builds, keep using the NTSC timing values when unknown video mode is detected. // For Release builds, keep using the NTSC timing values when unknown video mode is detected.
// Assert will be triggered for debug/dev builds. // Assert will be triggered for debug/dev builds.
framerate = FRAMERATE_NTSC;
scanlines = SCANLINES_TOTAL_NTSC; scanlines = SCANLINES_TOTAL_NTSC;
Console.Error("PCSX2-Counters: Unknown video mode detected"); Console.Error("PCSX2-Counters: Unknown video mode detected");

View File

@ -123,6 +123,7 @@ struct SyncCounter
#define MODE_HBLANK 0x1 //Set for the remaining ~1/6 of 1 Scanline #define MODE_HBLANK 0x1 //Set for the remaining ~1/6 of 1 Scanline
extern Fixed100 GetVerticalFrequency();
extern Counter counters[4]; extern Counter counters[4];
extern SyncCounter hsyncCounter; extern SyncCounter hsyncCounter;
extern SyncCounter vsyncCounter; extern SyncCounter vsyncCounter;

View File

@ -18,7 +18,7 @@
#include "GSFrame.h" #include "GSFrame.h"
#include "AppAccelerators.h" #include "AppAccelerators.h"
#include "AppSaveStates.h" #include "AppSaveStates.h"
#include "Counters.h"
#include "GS.h" #include "GS.h"
#include "MSWstuff.h" #include "MSWstuff.h"
@ -591,8 +591,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
AppConfig::UiTemplateOptions& templates = g_Conf->Templates; AppConfig::UiTemplateOptions& templates = g_Conf->Templates;
double fps = wxGetApp().FpsManager.GetFramerate(); double fps = wxGetApp().FpsManager.GetFramerate();
// The "not PAL" case covers both NTSC and Progressive float percentage = (fps * 100) / GetVerticalFrequency().ToFloat();
float per = gsVideoMode == GS_VideoMode::PAL ? (fps * 100) / EmuConfig.GS.FrameratePAL.ToFloat() : (fps * 100) / EmuConfig.GS.FramerateNTSC.ToFloat();
char gsDest[128]; char gsDest[128];
gsDest[0] = 0; // No need to set whole array to NULL. gsDest[0] = 0; // No need to set whole array to NULL.
@ -630,7 +629,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
wxString title = templates.TitleTemplate; wxString title = templates.TitleTemplate;
title.Replace(L"${slot}", pxsFmt(L"%d", States_GetCurrentSlot())); title.Replace(L"${slot}", pxsFmt(L"%d", States_GetCurrentSlot()));
title.Replace(L"${limiter}", limiterStr); 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"${vfps}", pxsFmt(L"%.02f", fps));
title.Replace(L"${cpuusage}", cpuUsage); title.Replace(L"${cpuusage}", cpuUsage);
title.Replace(L"${omodef}", omodef); title.Replace(L"${omodef}", omodef);