Overclocking: Added lag counter
This commit is contained in:
parent
e99eb5165a
commit
ac69be19a5
15 changed files with 153 additions and 34 deletions
|
@ -204,6 +204,8 @@ void Console::ResetComponents(bool softReset)
|
|||
_cpu->Reset(softReset);
|
||||
_controlManager->Reset(softReset);
|
||||
_memoryManager->Reset(softReset);
|
||||
|
||||
_lagCounter = 0;
|
||||
|
||||
SoundMixer::StopAudio(true);
|
||||
|
||||
|
@ -318,6 +320,10 @@ void Console::Run()
|
|||
if(targetTime < 0) {
|
||||
targetTime = 0;
|
||||
}
|
||||
|
||||
if(_controlManager->GetLagFlag()) {
|
||||
_lagCounter++;
|
||||
}
|
||||
|
||||
if(_stop) {
|
||||
_stop = false;
|
||||
|
@ -445,4 +451,14 @@ void Console::RequestReset()
|
|||
NesModel Console::GetNesModel()
|
||||
{
|
||||
return Instance->_model;
|
||||
}
|
||||
|
||||
uint32_t Console::GetLagCounter()
|
||||
{
|
||||
return Instance->_lagCounter;
|
||||
}
|
||||
|
||||
void Console::ResetLagCounter()
|
||||
{
|
||||
Instance->_lagCounter = 0;
|
||||
}
|
|
@ -35,6 +35,7 @@ class Console
|
|||
bool _reset = false;
|
||||
|
||||
atomic<bool> _resetRequested = false;
|
||||
atomic<uint32_t> _lagCounter;
|
||||
|
||||
bool _initialized = false;
|
||||
|
||||
|
@ -73,6 +74,9 @@ class Console
|
|||
static uint32_t GetPrgCrc32();
|
||||
static NesModel GetModel();
|
||||
|
||||
static uint32_t GetLagCounter();
|
||||
static void ResetLagCounter();
|
||||
|
||||
static bool IsRunning();
|
||||
|
||||
static shared_ptr<Console> GetInstance();
|
||||
|
|
|
@ -183,6 +183,10 @@ uint8_t ControlManager::GetPortValue(uint8_t port)
|
|||
|
||||
uint8_t ControlManager::ReadRAM(uint16_t addr)
|
||||
{
|
||||
//Used for lag counter
|
||||
//Any frame where the input is read does not count as lag
|
||||
_isLagging = false;
|
||||
|
||||
switch(addr) {
|
||||
case 0x4016: return GetPortValue(0);
|
||||
case 0x4017: return GetPortValue(1);
|
||||
|
@ -261,4 +265,11 @@ void ControlManager::SetMousePosition(double x, double y)
|
|||
MousePosition ControlManager::GetMousePosition()
|
||||
{
|
||||
return _mousePosition;
|
||||
}
|
||||
|
||||
bool ControlManager::GetLagFlag()
|
||||
{
|
||||
bool flag = _isLagging;
|
||||
_isLagging = true;
|
||||
return flag;
|
||||
}
|
|
@ -26,6 +26,7 @@ class ControlManager : public Snapshotable, public IMemoryHandler
|
|||
static IGameBroadcaster* _gameBroadcaster;
|
||||
static MousePosition _mousePosition;
|
||||
|
||||
bool _isLagging = false;
|
||||
bool _refreshState = false;
|
||||
|
||||
virtual shared_ptr<BaseControlDevice> GetZapper(uint8_t port);
|
||||
|
@ -43,6 +44,7 @@ class ControlManager : public Snapshotable, public IMemoryHandler
|
|||
ControlManager();
|
||||
|
||||
void UpdateControlDevices();
|
||||
bool GetLagFlag();
|
||||
|
||||
virtual void Reset(bool softReset);
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ enum EmulationFlags
|
|||
DisableGameDatabase = 0x20000,
|
||||
AutoConfigureInput = 0x40000,
|
||||
|
||||
ShowLagCounter = 0x80000,
|
||||
|
||||
InBackground = 0x40000000,
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ std::unordered_map<string, string> MessageManager::_enResources = {
|
|||
{ "EmulationMaximumSpeed", u8"Maximum speed" },
|
||||
{ "EmulationSpeedPercent", u8"%1%" },
|
||||
{ "GameCrash", u8"Game has crashed (%1)" },
|
||||
{ "Lag", u8"Lag" },
|
||||
{ "Mapper", u8"Mapper: %1, SubMapper: %2" },
|
||||
{ "MovieEnded", u8"Movie ended." },
|
||||
{ "MovieInvalid", u8"Invalid movie file." },
|
||||
|
@ -91,6 +92,7 @@ std::unordered_map<string, string> MessageManager::_frResources = {
|
|||
{ "EmulationMaximumSpeed", u8"Vitesse maximale" },
|
||||
{ "EmulationSpeedPercent", u8"%1%" },
|
||||
{ "GameCrash", u8"Le jeu a planté (%1)" },
|
||||
{ "Lag", u8"Lag" },
|
||||
{ "Mapper", u8"Mapper : %1, SubMapper : %2" },
|
||||
{ "MovieEnded", u8"Fin du film." },
|
||||
{ "MovieInvalid", u8"Fichier de film invalide." },
|
||||
|
@ -150,6 +152,7 @@ std::unordered_map<string, string> MessageManager::_jaResources = {
|
|||
{ "EmulationMaximumSpeed", u8"最高速度" },
|
||||
{ "EmulationSpeedPercent", u8"%1%" },
|
||||
{ "GameCrash", u8"ゲームは停止しました (%1)" },
|
||||
{ "Lag", u8"ラグ" },
|
||||
{ "Mapper", u8"Mapper: %1, SubMapper: %2" },
|
||||
{ "MovieEnded", u8"動画の再生が終了しました。" },
|
||||
{ "MovieInvalid", u8"動画データの読み込みに失敗しました。" },
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace Mesen.GUI.Config
|
|||
public UInt32 PpuExtraScanlinesBeforeNmi = 0;
|
||||
public UInt32 PpuExtraScanlinesAfterNmi = 0;
|
||||
|
||||
public bool ShowLagCounter = false;
|
||||
|
||||
public UInt32 EmulationSpeed = 100;
|
||||
|
||||
public EmulationInfo()
|
||||
|
@ -40,6 +42,7 @@ namespace Mesen.GUI.Config
|
|||
InteropEmu.SetFlag(EmulationFlags.Mmc3IrqAltBehavior, emulationInfo.UseAlternativeMmc3Irq);
|
||||
InteropEmu.SetFlag(EmulationFlags.AllowInvalidInput, emulationInfo.AllowInvalidInput);
|
||||
InteropEmu.SetFlag(EmulationFlags.RemoveSpriteLimit, emulationInfo.RemoveSpriteLimit);
|
||||
InteropEmu.SetFlag(EmulationFlags.ShowLagCounter, emulationInfo.ShowLagCounter);
|
||||
|
||||
InteropEmu.SetOverclockRate(emulationInfo.OverclockRate, emulationInfo.OverclockAdjustApu);
|
||||
InteropEmu.SetPpuNmiConfig(emulationInfo.PpuExtraScanlinesBeforeNmi, emulationInfo.PpuExtraScanlinesAfterNmi);
|
||||
|
|
|
@ -241,6 +241,9 @@
|
|||
|
||||
<Control ID="chkOverclockAdjustApu">Ne pas overclocker l'APU (Empêche le changement de tonalité causé par l'overclocking)</Control>
|
||||
|
||||
<Control ID="chkShowLagCounter">Afficher le compteur de lag</Control>
|
||||
<Control ID="btnResetLagCounter">Remettre le compteur à zéro</Control>
|
||||
|
||||
<Control ID="btnOK">OK</Control>
|
||||
<Control ID="btnCancel">Annuler</Control>
|
||||
</Form>
|
||||
|
|
|
@ -240,6 +240,9 @@
|
|||
<Control ID="lblEffectiveClockRatePal">クロックレート (PAL) : </Control>
|
||||
<Control ID="lblEffectiveClockRateDendy">クロックレート (Dendy) : </Control>
|
||||
|
||||
<Control ID="chkShowLagCounter">ラグカウンタを表示する</Control>
|
||||
<Control ID="btnResetLagCounter">カウンタをリセットする</Control>
|
||||
|
||||
<Control ID="btnOK">OK</Control>
|
||||
<Control ID="btnCancel">キャンセル</Control>
|
||||
</Form>
|
||||
|
|
61
GUI.NET/Forms/Config/frmEmulationConfig.Designer.cs
generated
61
GUI.NET/Forms/Config/frmEmulationConfig.Designer.cs
generated
|
@ -65,6 +65,9 @@
|
|||
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.lblEffectiveClockRate = new System.Windows.Forms.Label();
|
||||
this.lblEffectiveClockRateValue = new System.Windows.Forms.Label();
|
||||
this.flowLayoutPanel7 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.chkShowLagCounter = new System.Windows.Forms.CheckBox();
|
||||
this.btnResetLagCounter = new System.Windows.Forms.Button();
|
||||
this.tmrUpdateClockRate = new System.Windows.Forms.Timer(this.components);
|
||||
this.tabMain.SuspendLayout();
|
||||
this.tpgGeneral.SuspendLayout();
|
||||
|
@ -86,11 +89,12 @@
|
|||
((System.ComponentModel.ISupportInitialize)(this.nudExtraScanlinesAfterNmi)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudExtraScanlinesBeforeNmi)).BeginInit();
|
||||
this.flowLayoutPanel2.SuspendLayout();
|
||||
this.flowLayoutPanel7.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// baseConfigPanel
|
||||
//
|
||||
this.baseConfigPanel.Location = new System.Drawing.Point(0, 268);
|
||||
this.baseConfigPanel.Location = new System.Drawing.Point(0, 299);
|
||||
this.baseConfigPanel.Size = new System.Drawing.Size(487, 29);
|
||||
//
|
||||
// tabMain
|
||||
|
@ -102,7 +106,7 @@
|
|||
this.tabMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabMain.Name = "tabMain";
|
||||
this.tabMain.SelectedIndex = 0;
|
||||
this.tabMain.Size = new System.Drawing.Size(487, 268);
|
||||
this.tabMain.Size = new System.Drawing.Size(487, 299);
|
||||
this.tabMain.TabIndex = 2;
|
||||
//
|
||||
// tpgGeneral
|
||||
|
@ -111,7 +115,7 @@
|
|||
this.tpgGeneral.Location = new System.Drawing.Point(4, 22);
|
||||
this.tpgGeneral.Name = "tpgGeneral";
|
||||
this.tpgGeneral.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tpgGeneral.Size = new System.Drawing.Size(479, 242);
|
||||
this.tpgGeneral.Size = new System.Drawing.Size(479, 273);
|
||||
this.tpgGeneral.TabIndex = 0;
|
||||
this.tpgGeneral.Text = "General";
|
||||
this.tpgGeneral.UseVisualStyleBackColor = true;
|
||||
|
@ -129,7 +133,7 @@
|
|||
this.tableLayoutPanel4.RowCount = 2;
|
||||
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel4.Size = new System.Drawing.Size(473, 236);
|
||||
this.tableLayoutPanel4.Size = new System.Drawing.Size(473, 267);
|
||||
this.tableLayoutPanel4.TabIndex = 0;
|
||||
//
|
||||
// flowLayoutPanel6
|
||||
|
@ -182,7 +186,7 @@
|
|||
this.tpgAdvanced.Location = new System.Drawing.Point(4, 22);
|
||||
this.tpgAdvanced.Name = "tpgAdvanced";
|
||||
this.tpgAdvanced.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tpgAdvanced.Size = new System.Drawing.Size(479, 242);
|
||||
this.tpgAdvanced.Size = new System.Drawing.Size(479, 273);
|
||||
this.tpgAdvanced.TabIndex = 1;
|
||||
this.tpgAdvanced.Text = "Advanced";
|
||||
this.tpgAdvanced.UseVisualStyleBackColor = true;
|
||||
|
@ -204,7 +208,7 @@
|
|||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(473, 236);
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(473, 267);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// chkUseAlternativeMmc3Irq
|
||||
|
@ -243,7 +247,7 @@
|
|||
this.tpgOverclocking.Location = new System.Drawing.Point(4, 22);
|
||||
this.tpgOverclocking.Name = "tpgOverclocking";
|
||||
this.tpgOverclocking.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tpgOverclocking.Size = new System.Drawing.Size(479, 242);
|
||||
this.tpgOverclocking.Size = new System.Drawing.Size(479, 273);
|
||||
this.tpgOverclocking.TabIndex = 2;
|
||||
this.tpgOverclocking.Text = "Overclocking";
|
||||
this.tpgOverclocking.UseVisualStyleBackColor = true;
|
||||
|
@ -259,6 +263,7 @@
|
|||
this.tableLayoutPanel3.Controls.Add(this.grpOverclocking, 0, 1);
|
||||
this.tableLayoutPanel3.Controls.Add(this.grpPpuTiming, 0, 2);
|
||||
this.tableLayoutPanel3.Controls.Add(this.flowLayoutPanel2, 0, 3);
|
||||
this.tableLayoutPanel3.Controls.Add(this.flowLayoutPanel7, 0, 7);
|
||||
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 3);
|
||||
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
|
@ -271,7 +276,7 @@
|
|||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel3.Size = new System.Drawing.Size(473, 236);
|
||||
this.tableLayoutPanel3.Size = new System.Drawing.Size(473, 267);
|
||||
this.tableLayoutPanel3.TabIndex = 0;
|
||||
//
|
||||
// flowLayoutPanel4
|
||||
|
@ -559,6 +564,39 @@
|
|||
this.lblEffectiveClockRateValue.TabIndex = 1;
|
||||
this.lblEffectiveClockRateValue.Text = "100%";
|
||||
//
|
||||
// flowLayoutPanel7
|
||||
//
|
||||
this.flowLayoutPanel7.Controls.Add(this.chkShowLagCounter);
|
||||
this.flowLayoutPanel7.Controls.Add(this.btnResetLagCounter);
|
||||
this.flowLayoutPanel7.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.flowLayoutPanel7.Location = new System.Drawing.Point(0, 232);
|
||||
this.flowLayoutPanel7.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowLayoutPanel7.Name = "flowLayoutPanel7";
|
||||
this.flowLayoutPanel7.Size = new System.Drawing.Size(473, 35);
|
||||
this.flowLayoutPanel7.TabIndex = 12;
|
||||
//
|
||||
// chkShowLagCounter
|
||||
//
|
||||
this.chkShowLagCounter.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.chkShowLagCounter.AutoSize = true;
|
||||
this.chkShowLagCounter.Location = new System.Drawing.Point(3, 6);
|
||||
this.chkShowLagCounter.Name = "chkShowLagCounter";
|
||||
this.chkShowLagCounter.Size = new System.Drawing.Size(114, 17);
|
||||
this.chkShowLagCounter.TabIndex = 13;
|
||||
this.chkShowLagCounter.Text = "Show Lag Counter";
|
||||
this.chkShowLagCounter.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnResetLagCounter
|
||||
//
|
||||
this.btnResetLagCounter.AutoSize = true;
|
||||
this.btnResetLagCounter.Location = new System.Drawing.Point(123, 3);
|
||||
this.btnResetLagCounter.Name = "btnResetLagCounter";
|
||||
this.btnResetLagCounter.Size = new System.Drawing.Size(85, 23);
|
||||
this.btnResetLagCounter.TabIndex = 14;
|
||||
this.btnResetLagCounter.Text = "Reset Counter";
|
||||
this.btnResetLagCounter.UseVisualStyleBackColor = true;
|
||||
this.btnResetLagCounter.Click += new System.EventHandler(this.btnResetLagCounter_Click);
|
||||
//
|
||||
// tmrUpdateClockRate
|
||||
//
|
||||
this.tmrUpdateClockRate.Enabled = true;
|
||||
|
@ -568,7 +606,7 @@
|
|||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(487, 297);
|
||||
this.ClientSize = new System.Drawing.Size(487, 328);
|
||||
this.Controls.Add(this.tabMain);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
|
@ -608,6 +646,8 @@
|
|||
((System.ComponentModel.ISupportInitialize)(this.nudExtraScanlinesBeforeNmi)).EndInit();
|
||||
this.flowLayoutPanel2.ResumeLayout(false);
|
||||
this.flowLayoutPanel2.PerformLayout();
|
||||
this.flowLayoutPanel7.ResumeLayout(false);
|
||||
this.flowLayoutPanel7.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -651,5 +691,8 @@
|
|||
private System.Windows.Forms.Label lblEffectiveClockRateDendy;
|
||||
private System.Windows.Forms.Label lblEffectiveClockRateValueDendy;
|
||||
private System.Windows.Forms.Label lblEffectiveClockRateValuePal;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel7;
|
||||
private System.Windows.Forms.CheckBox chkShowLagCounter;
|
||||
private System.Windows.Forms.Button btnResetLagCounter;
|
||||
}
|
||||
}
|
|
@ -31,6 +31,8 @@ namespace Mesen.GUI.Forms.Config
|
|||
|
||||
AddBinding("PpuExtraScanlinesBeforeNmi", nudExtraScanlinesBeforeNmi);
|
||||
AddBinding("PpuExtraScanlinesAfterNmi", nudExtraScanlinesAfterNmi);
|
||||
|
||||
AddBinding("ShowLagCounter", chkShowLagCounter);
|
||||
}
|
||||
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
|
@ -61,5 +63,10 @@ namespace Mesen.GUI.Forms.Config
|
|||
nudOverclockRate.Value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnResetLagCounter_Click(object sender, EventArgs e)
|
||||
{
|
||||
InteropEmu.ResetLagCounter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ namespace Mesen.GUI
|
|||
[DllImport(DLLPath, EntryPoint = "GetRomInfo")] private static extern UInt32 GetRomInfoWrapper(ref InteropRomInfo romInfo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename = "", Int32 archiveFileIndex = -1);
|
||||
|
||||
[DllImport(DLLPath)] public static extern void Reset();
|
||||
[DllImport(DLLPath)] public static extern void ResetLagCounter();
|
||||
|
||||
[DllImport(DLLPath)] public static extern void StartServer(UInt16 port, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string hostPlayerName);
|
||||
[DllImport(DLLPath)] public static extern void StopServer();
|
||||
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsServerRunning();
|
||||
|
@ -623,6 +625,8 @@ namespace Mesen.GUI
|
|||
DisableGameDatabase = 0x20000,
|
||||
AutoConfigureInput = 0x40000,
|
||||
|
||||
ShowLagCounter = 0x80000,
|
||||
|
||||
InBackground = 0x40000000,
|
||||
}
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@ namespace InteropEmu {
|
|||
}
|
||||
|
||||
DllExport void __stdcall Reset() { Console::Reset(); }
|
||||
DllExport void __stdcall ResetLagCounter() { Console::ResetLagCounter(); }
|
||||
|
||||
DllExport void __stdcall StartServer(uint16_t port, char* hostPlayerName) { GameServer::StartServer(port, hostPlayerName); }
|
||||
DllExport void __stdcall StopServer() { GameServer::StopServer(); }
|
||||
|
|
|
@ -436,6 +436,40 @@ namespace NES
|
|||
DrawString("PAUSE", (float)_screenWidth / 2 - stringDimensions.m128_f32[0] / 2, (float)_screenHeight / 2 - stringDimensions.m128_f32[1] / 2 - 8, Colors::AntiqueWhite, 1.0f, _largeFont.get());
|
||||
}
|
||||
|
||||
void Renderer::ShowFpsCounter()
|
||||
{
|
||||
if(_fpsTimer.GetElapsedMS() > 1000) {
|
||||
//Update fps every sec
|
||||
uint32_t frameCount = VideoDecoder::GetInstance()->GetFrameCount();
|
||||
if(frameCount - _lastFrameCount < 0) {
|
||||
_currentFPS = 0;
|
||||
} else {
|
||||
_currentFPS = (int)(std::round((double)(frameCount - _lastFrameCount) / (_fpsTimer.GetElapsedMS() / 1000)));
|
||||
_currentRenderedFPS = (int)(std::round((double)(_renderedFrameCount - _lastRenderedFrameCount) / (_fpsTimer.GetElapsedMS() / 1000)));
|
||||
}
|
||||
_lastFrameCount = frameCount;
|
||||
_lastRenderedFrameCount = _renderedFrameCount;
|
||||
_fpsTimer.Reset();
|
||||
}
|
||||
|
||||
if(_currentFPS > 5000) {
|
||||
_currentFPS = 0;
|
||||
}
|
||||
if(_currentRenderedFPS > 5000) {
|
||||
_currentRenderedFPS = 0;
|
||||
}
|
||||
|
||||
string fpsString = string("FPS: ") + std::to_string(_currentFPS) + " / " + std::to_string(_currentRenderedFPS);
|
||||
DrawString(fpsString, (float)(_screenWidth - 120), 13, Colors::AntiqueWhite, 1.0f);
|
||||
}
|
||||
|
||||
void Renderer::ShowLagCounter()
|
||||
{
|
||||
float yPos = EmulationSettings::CheckFlag(EmulationFlags::ShowFPS) ? 37.0f : 13.0f;
|
||||
string lagCounter = MessageManager::Localize("Lag") + ": " + std::to_string(Console::GetLagCounter());
|
||||
DrawString(lagCounter, (float)(_screenWidth - 120), yPos, Colors::AntiqueWhite, 1.0f);
|
||||
}
|
||||
|
||||
void Renderer::Render()
|
||||
{
|
||||
bool paused = EmulationSettings::IsPaused();
|
||||
|
@ -458,31 +492,11 @@ namespace NES
|
|||
if(paused) {
|
||||
DrawPauseScreen();
|
||||
} else if(VideoDecoder::GetInstance()->IsRunning()) {
|
||||
//Draw FPS counter
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ShowFPS)) {
|
||||
if(_fpsTimer.GetElapsedMS() > 1000) {
|
||||
//Update fps every sec
|
||||
uint32_t frameCount = VideoDecoder::GetInstance()->GetFrameCount();
|
||||
if(frameCount - _lastFrameCount < 0) {
|
||||
_currentFPS = 0;
|
||||
} else {
|
||||
_currentFPS = (int)(std::round((double)(frameCount - _lastFrameCount) / (_fpsTimer.GetElapsedMS() / 1000)));
|
||||
_currentRenderedFPS = (int)(std::round((double)(_renderedFrameCount - _lastRenderedFrameCount) / (_fpsTimer.GetElapsedMS() / 1000)));
|
||||
}
|
||||
_lastFrameCount = frameCount;
|
||||
_lastRenderedFrameCount = _renderedFrameCount;
|
||||
_fpsTimer.Reset();
|
||||
}
|
||||
|
||||
if(_currentFPS > 5000) {
|
||||
_currentFPS = 0;
|
||||
}
|
||||
if(_currentRenderedFPS > 5000) {
|
||||
_currentRenderedFPS = 0;
|
||||
}
|
||||
|
||||
string fpsString = string("FPS: ") + std::to_string(_currentFPS) + " / " + std::to_string(_currentRenderedFPS);
|
||||
DrawString(fpsString, (float)(_screenWidth - 120), 13, Colors::AntiqueWhite, 1.0f);
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ShowFPS)) {
|
||||
ShowFpsCounter();
|
||||
}
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ShowLagCounter)) {
|
||||
ShowLagCounter();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,9 @@ namespace NES {
|
|||
void DrawToasts();
|
||||
void DrawToast(shared_ptr<ToastInfo> toast, int &lastHeight);
|
||||
void RemoveOldToasts();
|
||||
|
||||
void ShowFpsCounter();
|
||||
void ShowLagCounter();
|
||||
|
||||
public:
|
||||
Renderer(HWND hWnd);
|
||||
|
|
Loading…
Add table
Reference in a new issue