[Project64] Get Display FPS working on non windows system
This commit is contained in:
parent
7eccf17c90
commit
4733420dfa
|
@ -26,7 +26,7 @@ CDateTime & CDateTime::SetToNow(void)
|
|||
return *this;
|
||||
}
|
||||
|
||||
std::string CDateTime::Format (const char * format)
|
||||
std::string CDateTime::Format(const char * format)
|
||||
{
|
||||
char buffer[100];
|
||||
time_t TimeValue = m_time / 1000l;
|
||||
|
@ -34,13 +34,18 @@ std::string CDateTime::Format (const char * format)
|
|||
return std::string(buffer);
|
||||
}
|
||||
|
||||
double CDateTime::DiffernceMilliseconds (const CDateTime & compare)
|
||||
double CDateTime::DiffernceMilliseconds(const CDateTime & compare)
|
||||
{
|
||||
double diff = (double)(m_time - compare.m_time);
|
||||
return diff / 1000.0;
|
||||
}
|
||||
|
||||
uint64_t CDateTime::Value ( void )
|
||||
uint64_t CDateTime::Value(void)
|
||||
{
|
||||
return m_time;
|
||||
}
|
||||
|
||||
void CDateTime::SetValue(uint64_t value)
|
||||
{
|
||||
m_time = value;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ public:
|
|||
CDateTime & SetToNow (void);
|
||||
std::string Format (const char * format);
|
||||
double DiffernceMilliseconds (const CDateTime & compare);
|
||||
uint64_t Value ( void );
|
||||
uint64_t Value(void);
|
||||
void SetValue(uint64_t value);
|
||||
|
||||
private:
|
||||
uint64_t m_time;
|
||||
|
|
|
@ -383,6 +383,7 @@ enum LanguageStringID
|
|||
STR_FR_VIS = 700,
|
||||
STR_FR_DLS = 701,
|
||||
STR_FR_PERCENT = 702,
|
||||
STR_FR_DLS_VIS = 703,
|
||||
|
||||
// Increase speed
|
||||
STR_INSREASE_SPEED = 710,
|
||||
|
|
|
@ -351,6 +351,7 @@ void CLanguage::LoadDefaultStrings(void)
|
|||
DEF_STR(STR_FR_VIS, "Vertical interrupts per second");
|
||||
DEF_STR(STR_FR_DLS, "Display lists per second");
|
||||
DEF_STR(STR_FR_PERCENT, "Percentage of full speed");
|
||||
DEF_STR(STR_FR_DLS_VIS, "VI/s & DL/s");
|
||||
|
||||
// Increase speed
|
||||
DEF_STR(STR_INSREASE_SPEED, "Increase Game Speed");
|
||||
|
@ -522,7 +523,7 @@ bool CLanguage::LoadCurrentStrings(void)
|
|||
m_LanguageLoaded = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
LanguageList LangList = GetLangList();
|
||||
stdstr Filename;
|
||||
|
||||
|
|
|
@ -15,10 +15,13 @@
|
|||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
CFramePerSecond::CFramePerSecond()
|
||||
CFramePerSecond::CFramePerSecond() :
|
||||
m_CurrentViFrame(0),
|
||||
m_CurrentDlistFrame(0),
|
||||
m_iFrameRateType(g_Settings->LoadDword(UserInterface_FrameDisplayType)),
|
||||
m_ScreenHertz(g_Settings->LoadDword(GameRunning_ScreenHertz)),
|
||||
m_ViFrameRate(0)
|
||||
{
|
||||
m_iFrameRateType = g_Settings->LoadDword(UserInterface_FrameDisplayType);
|
||||
m_ScreenHertz = g_Settings->LoadDword(GameRunning_ScreenHertz);
|
||||
g_Settings->RegisterChangeCB(UserInterface_FrameDisplayType, this, (CSettings::SettingChangedFunc)FrameRateTypeChanged);
|
||||
g_Settings->RegisterChangeCB(GameRunning_ScreenHertz, this, (CSettings::SettingChangedFunc)ScreenHertzChanged);
|
||||
|
||||
|
@ -26,12 +29,6 @@ CFramePerSecond::CFramePerSecond()
|
|||
{
|
||||
m_ScreenHertz = 60;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER Freq;
|
||||
QueryPerformanceFrequency(&Freq);
|
||||
m_Frequency = Freq.QuadPart;
|
||||
#endif
|
||||
Reset(true);
|
||||
}
|
||||
|
||||
|
@ -43,18 +40,18 @@ CFramePerSecond::~CFramePerSecond()
|
|||
|
||||
void CFramePerSecond::Reset(bool ClearDisplay)
|
||||
{
|
||||
m_CurrentFrame = 0;
|
||||
m_LastFrame = 0;
|
||||
m_CurrentDlistFrame = 0;
|
||||
m_CurrentViFrame = 0;
|
||||
m_LastViFrame.SetValue(0);
|
||||
|
||||
for (int count = 0; count < NoOfFrames; count++)
|
||||
{
|
||||
m_Frames[count] = 0;
|
||||
m_ViFrames[count] = 0;
|
||||
m_FramesDlist[count] = 0;
|
||||
}
|
||||
if (ClearDisplay)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
g_Notify->DisplayMessage2("");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,80 +63,72 @@ void CFramePerSecond::Reset(bool ClearDisplay)
|
|||
|
||||
void CFramePerSecond::UpdateViCounter(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (m_iFrameRateType != FR_VIs && m_iFrameRateType != FR_PERCENT)
|
||||
if (m_iFrameRateType != FR_VIs &&
|
||||
m_iFrameRateType != FR_VIs_DLs &&
|
||||
m_iFrameRateType != FR_PERCENT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((m_CurrentFrame & 7) == 0)
|
||||
if ((m_CurrentViFrame & 7) == 0)
|
||||
{
|
||||
LARGE_INTEGER Time;
|
||||
QueryPerformanceCounter(&Time);
|
||||
m_Frames[(m_CurrentFrame >> 3) % NoOfFrames] = Time.QuadPart - m_LastFrame;
|
||||
m_LastFrame = Time.QuadPart;
|
||||
CDateTime Time;
|
||||
Time.SetToNow();
|
||||
m_ViFrames[(m_CurrentViFrame >> 3) % NoOfFrames] = Time.Value() - m_LastViFrame.Value();
|
||||
m_LastViFrame = Time;
|
||||
DisplayViCounter(0);
|
||||
}
|
||||
m_CurrentFrame += 1;
|
||||
#endif
|
||||
m_CurrentViFrame += 1;
|
||||
}
|
||||
|
||||
void CFramePerSecond::UpdateDisplay(void)
|
||||
{
|
||||
std::string DisplayString;
|
||||
if (m_iFrameRateType == FR_VIs || m_iFrameRateType == FR_VIs_DLs)
|
||||
{
|
||||
DisplayString = stdstr_f(m_ViFrameRate >= 0 ? "VI/s: %.2f" : "VI/s: -.--", m_ViFrameRate);
|
||||
}
|
||||
if (m_iFrameRateType == FR_PERCENT && m_ViFrameRate > 0)
|
||||
{
|
||||
float Percent = ((float)m_ViFrameRate) / m_ScreenHertz;
|
||||
DisplayString = stdstr_f("%.1f %%", Percent * 100).c_str();
|
||||
}
|
||||
if (m_iFrameRateType == FR_DLs || m_iFrameRateType == FR_VIs_DLs)
|
||||
{
|
||||
if (DisplayString.length() > 0) { DisplayString += " "; }
|
||||
DisplayString += stdstr_f(m_DlistFrameRate >= 0 ? "DL/s: %.1f" : "DL/s: -.--", m_DlistFrameRate);
|
||||
}
|
||||
g_Notify->DisplayMessage2(DisplayString.c_str());
|
||||
}
|
||||
|
||||
void CFramePerSecond::DisplayViCounter(uint32_t FrameRate)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (m_iFrameRateType == FR_VIs)
|
||||
if (m_iFrameRateType != FR_VIs && m_iFrameRateType != FR_VIs_DLs && m_iFrameRateType != FR_PERCENT)
|
||||
{
|
||||
if (FrameRate != 0)
|
||||
return;
|
||||
}
|
||||
if (FrameRate != 0)
|
||||
{
|
||||
m_ViFrameRate = (float)FrameRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_CurrentViFrame > (NoOfFrames << 3))
|
||||
{
|
||||
g_Notify->DisplayMessage2(stdstr_f("VI/s: %d.00", FrameRate).c_str());
|
||||
uint64_t Total;
|
||||
|
||||
Total = 0;
|
||||
for (int count = 0; count < NoOfFrames; count++)
|
||||
{
|
||||
Total += m_ViFrames[count];
|
||||
}
|
||||
m_ViFrameRate = ((NoOfFrames << 3) / ((float)Total / 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_CurrentFrame > (NoOfFrames << 3))
|
||||
{
|
||||
int64_t Total;
|
||||
|
||||
Total = 0;
|
||||
for (int count = 0; count < NoOfFrames; count++)
|
||||
{
|
||||
Total += m_Frames[count];
|
||||
}
|
||||
g_Notify->DisplayMessage2(stdstr_f("VI/s: %.2f", m_Frequency / ((double)Total / (NoOfFrames << 3))).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->DisplayMessage2("VI/s: -.--");
|
||||
}
|
||||
m_ViFrameRate = -1.0;
|
||||
}
|
||||
}
|
||||
if (m_iFrameRateType == FR_PERCENT)
|
||||
{
|
||||
float Percent;
|
||||
if (FrameRate != 0)
|
||||
{
|
||||
Percent = ((float)FrameRate) / m_ScreenHertz;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_CurrentFrame > (NoOfFrames << 3))
|
||||
{
|
||||
int64_t Total;
|
||||
|
||||
Total = 0;
|
||||
for (int count = 0; count < NoOfFrames; count++)
|
||||
{
|
||||
Total += m_Frames[count];
|
||||
}
|
||||
Percent = ((float)(m_Frequency / ((double)Total / (NoOfFrames << 3)))) / m_ScreenHertz;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->DisplayMessage2("");
|
||||
return;
|
||||
}
|
||||
}
|
||||
g_Notify->DisplayMessage2(stdstr_f("%.1f %%", Percent * 100).c_str());
|
||||
}
|
||||
#endif
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
void CFramePerSecond::FrameRateTypeChanged(CFramePerSecond * _this)
|
||||
|
@ -156,50 +145,32 @@ void CFramePerSecond::ScreenHertzChanged(CFramePerSecond * _this)
|
|||
|
||||
void CFramePerSecond::UpdateDlCounter(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (m_iFrameRateType != FR_DLs)
|
||||
if (m_iFrameRateType != FR_DLs && m_iFrameRateType != FR_VIs_DLs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((m_CurrentFrame & 3) == 0) {
|
||||
LARGE_INTEGER Time;
|
||||
QueryPerformanceCounter(&Time);
|
||||
m_Frames[(m_CurrentFrame >> 2) % NoOfFrames] = Time.QuadPart - m_LastFrame;
|
||||
m_LastFrame = Time.QuadPart;
|
||||
DisplayDlCounter(0);
|
||||
}
|
||||
m_CurrentFrame += 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CFramePerSecond::DisplayDlCounter(uint32_t FrameRate)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (m_iFrameRateType != FR_DLs)
|
||||
if ((m_CurrentDlistFrame & 3) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (FrameRate != 0)
|
||||
{
|
||||
g_Notify->DisplayMessage2(stdstr_f("DL/s: %d.00", FrameRate).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_CurrentFrame > (NoOfFrames << 2))
|
||||
CDateTime Time;
|
||||
Time.SetToNow();
|
||||
m_FramesDlist[(m_CurrentDlistFrame >> 2) % NoOfFrames] = Time.Value() - m_LastDlistFrame.Value();
|
||||
m_LastDlistFrame = Time;
|
||||
if (m_CurrentDlistFrame > (NoOfFrames << 2))
|
||||
{
|
||||
int64_t Total;
|
||||
|
||||
Total = 0;
|
||||
for (int count = 0; count < NoOfFrames; count++)
|
||||
{
|
||||
Total += m_Frames[count];
|
||||
Total += m_FramesDlist[count];
|
||||
}
|
||||
g_Notify->DisplayMessage2(stdstr_f("DL/s: %.1f", m_Frequency / ((double)Total / (NoOfFrames << 2))).c_str());
|
||||
m_DlistFrameRate = ((NoOfFrames << 2) / ((float)Total / 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->DisplayMessage2("DL/s: -.--");
|
||||
m_DlistFrameRate = -1.0;
|
||||
}
|
||||
UpdateDisplay();
|
||||
}
|
||||
#endif
|
||||
m_CurrentDlistFrame += 1;
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
#include <Common/DateTimeClass.h>
|
||||
|
||||
class CFramePerSecond
|
||||
{
|
||||
|
@ -20,7 +21,6 @@ public:
|
|||
|
||||
void UpdateDlCounter(void);
|
||||
void UpdateViCounter(void);
|
||||
void DisplayDlCounter(uint32_t FrameRate);
|
||||
void DisplayViCounter(uint32_t FrameRate);
|
||||
|
||||
private:
|
||||
|
@ -29,11 +29,20 @@ private:
|
|||
|
||||
static void FrameRateTypeChanged(CFramePerSecond * _this);
|
||||
static void ScreenHertzChanged(CFramePerSecond * _this);
|
||||
void UpdateDisplay(void);
|
||||
|
||||
int32_t m_iFrameRateType, m_ScreenHertz;
|
||||
|
||||
enum { NoOfFrames = 7 };
|
||||
|
||||
int64_t m_Frequency, m_Frames[NoOfFrames], m_LastFrame;
|
||||
int32_t m_CurrentFrame;
|
||||
CDateTime m_LastViFrame;
|
||||
int64_t m_ViFrames[NoOfFrames];
|
||||
int32_t m_CurrentViFrame;
|
||||
float m_ViFrameRate;
|
||||
|
||||
//Dlist
|
||||
CDateTime m_LastDlistFrame;
|
||||
int64_t m_FramesDlist[NoOfFrames];
|
||||
int32_t m_CurrentDlistFrame;
|
||||
float m_DlistFrameRate;
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ enum CPU_TYPE
|
|||
|
||||
enum FRAMERATE_TYPE
|
||||
{
|
||||
FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2,
|
||||
FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2, FR_VIs_DLs = 3,
|
||||
};
|
||||
|
||||
enum SAVE_CHIP_TYPE
|
||||
|
|
|
@ -44,6 +44,7 @@ CAdvancedOptionsPage::CAdvancedOptionsPage(HWND hParent, const RECT & rcDispay)
|
|||
ComboBox->AddItemW(wGS(STR_FR_VIS).c_str(), FR_VIs);
|
||||
ComboBox->AddItemW(wGS(STR_FR_DLS).c_str(), FR_DLs);
|
||||
ComboBox->AddItemW(wGS(STR_FR_PERCENT).c_str(), FR_PERCENT);
|
||||
ComboBox->AddItemW(wGS(STR_FR_DLS_VIS).c_str(), FR_VIs_DLs);
|
||||
}
|
||||
|
||||
m_IplDir.Attach(GetDlgItem(IDC_IPL_DIR));
|
||||
|
|
Loading…
Reference in New Issue