Speed Limitor: Clean up code and change interval levels
This commit is contained in:
parent
b7a9a7a9e6
commit
59b2e96062
|
@ -130,10 +130,6 @@ void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
|
|||
m_BytesPerSecond = 194532;
|
||||
m_BytesPerSecond = 128024;
|
||||
|
||||
if (System == SYSTEM_PAL) {
|
||||
m_FramesPerSecond = 50;
|
||||
} else {
|
||||
m_FramesPerSecond = 60;
|
||||
}
|
||||
m_FramesPerSecond = System == SYSTEM_PAL ? 50 : 60;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
|
|||
m_MMU_VM(this,SavesReadOnly),
|
||||
m_TLB(this),
|
||||
m_FPS(g_Notify),
|
||||
m_Limitor(g_Notify),
|
||||
m_Plugins(Plugins),
|
||||
m_Cheats(NULL),
|
||||
m_SyncCPU(NULL),
|
||||
|
|
|
@ -55,8 +55,8 @@ public:
|
|||
void StartEmulation ( bool NewThread );
|
||||
void SyncToAudio ( void );
|
||||
bool IsDialogMsg ( MSG * msg );
|
||||
void IncreaseSpeed ( void ) { m_Limitor.IncreaeSpeed(10); }
|
||||
void DecreaeSpeed ( void ) { m_Limitor.DecreaeSpeed(10); }
|
||||
void IncreaseSpeed ( void ) { m_Limitor.IncreaeSpeed(); }
|
||||
void DecreaeSpeed ( void ) { m_Limitor.DecreaeSpeed(); }
|
||||
void Reset ( bool bInitReg, bool ClearMenory );
|
||||
void GameReset ( void );
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#include "stdafx.h"
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
CSpeedLimitor::CSpeedLimitor(CNotification * const g_Notify ) :
|
||||
g_Notify(g_Notify)
|
||||
CSpeedLimitor::CSpeedLimitor(void)
|
||||
{
|
||||
m_Frames = 0;
|
||||
m_LastTime = 0;
|
||||
|
@ -74,18 +73,38 @@ bool CSpeedLimitor::Timer_Process (DWORD * FrameRate ) {
|
|||
}
|
||||
}
|
||||
|
||||
void CSpeedLimitor::IncreaeSpeed ( int Percent )
|
||||
void CSpeedLimitor::IncreaeSpeed ( void )
|
||||
{
|
||||
m_Speed += (DWORD)(m_BaseSpeed * ((float)Percent / 100));
|
||||
if (m_Speed >= 60)
|
||||
{
|
||||
m_Speed += 10;
|
||||
}
|
||||
else if (m_Speed >= 15)
|
||||
{
|
||||
m_Speed += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Speed += 1;
|
||||
}
|
||||
SpeedChanged(m_Speed);
|
||||
FixSpeedRatio();
|
||||
}
|
||||
|
||||
void CSpeedLimitor::DecreaeSpeed ( int Percent )
|
||||
void CSpeedLimitor::DecreaeSpeed ( void )
|
||||
{
|
||||
ULONG Unit = (ULONG)(m_BaseSpeed * ((float)Percent / 100));
|
||||
if (m_Speed > Unit)
|
||||
if (m_Speed > 60)
|
||||
{
|
||||
m_Speed -= Unit;
|
||||
FixSpeedRatio();
|
||||
m_Speed -= 10;
|
||||
}
|
||||
else if (m_Speed > 15)
|
||||
{
|
||||
m_Speed -= 5;
|
||||
}
|
||||
else if (m_Speed > 1)
|
||||
{
|
||||
m_Speed -= 1;
|
||||
}
|
||||
SpeedChanged(m_Speed);
|
||||
FixSpeedRatio();
|
||||
}
|
|
@ -10,19 +10,24 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
class CSpeedLimitor {
|
||||
CNotification * const g_Notify;
|
||||
DWORD m_Speed, m_BaseSpeed, m_Frames, m_LastTime;
|
||||
double m_Ratio;
|
||||
|
||||
void FixSpeedRatio ( void );
|
||||
|
||||
class CSpeedLimitor :
|
||||
private CGameSettings
|
||||
{
|
||||
public:
|
||||
CSpeedLimitor ( CNotification * const g_Notify );
|
||||
CSpeedLimitor ( void );
|
||||
~CSpeedLimitor ( void );
|
||||
|
||||
void SetHertz ( const DWORD Hertz );
|
||||
bool Timer_Process ( DWORD * const FrameRate );
|
||||
void IncreaeSpeed ( int Percent );
|
||||
void DecreaeSpeed ( int Percent );
|
||||
void IncreaeSpeed ( void );
|
||||
void DecreaeSpeed ( void );
|
||||
|
||||
private:
|
||||
CSpeedLimitor(const CSpeedLimitor&); // Disable copy constructor
|
||||
CSpeedLimitor& operator=(const CSpeedLimitor&); // Disable assignment
|
||||
|
||||
void FixSpeedRatio ( void );
|
||||
|
||||
DWORD m_Speed, m_BaseSpeed, m_Frames, m_LastTime;
|
||||
double m_Ratio;
|
||||
};
|
||||
|
|
|
@ -22,10 +22,11 @@ DWORD CGameSettings::m_AiCountPerBytes = 500;
|
|||
bool CGameSettings::m_DelayDP = false;
|
||||
bool CGameSettings::m_DelaySI = false;
|
||||
DWORD CGameSettings::m_RdramSize = 0;
|
||||
bool CGameSettings::m_bFixedAudio;
|
||||
bool CGameSettings::m_bSyncToAudio;
|
||||
bool CGameSettings::m_bFastSP;
|
||||
bool CGameSettings::m_b32Bit;
|
||||
bool CGameSettings::m_bFixedAudio = true;
|
||||
bool CGameSettings::m_bSyncingToAudio = true;
|
||||
bool CGameSettings::m_bSyncToAudio = true;
|
||||
bool CGameSettings::m_bFastSP = true;
|
||||
bool CGameSettings::m_b32Bit = true;
|
||||
bool CGameSettings::m_RspAudioSignal;
|
||||
bool CGameSettings::m_bRomInMemory;
|
||||
bool CGameSettings::m_RegCaching;
|
||||
|
@ -59,8 +60,15 @@ void CGameSettings::RefreshGameSettings()
|
|||
m_bLinkBlocks = g_Settings->LoadBool(Game_BlockLinking);
|
||||
m_LookUpMode = g_Settings->LoadDword(Game_FuncLookupMode);
|
||||
|
||||
m_bSyncingToAudio = m_bSyncToAudio;
|
||||
if (m_CountPerOp == 0)
|
||||
{
|
||||
m_CountPerOp = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameSettings::SpeedChanged (int SpeedLimit )
|
||||
{
|
||||
int FullSpeed = g_System->m_SystemType == SYSTEM_PAL ? 50 : 60;
|
||||
m_bSyncingToAudio = SpeedLimit == FullSpeed ? m_bSyncToAudio : false;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
inline static bool bDelaySI ( void ) { return m_DelaySI; }
|
||||
inline static DWORD RdramSize ( void ) { return m_RdramSize; }
|
||||
inline static bool bFixedAudio ( void ) { return m_bFixedAudio; }
|
||||
inline static bool bSyncToAudio ( void ) { return m_bSyncToAudio; }
|
||||
inline static bool bSyncToAudio ( void ) { return m_bSyncingToAudio; }
|
||||
inline static bool bFastSP ( void ) { return m_bFastSP; }
|
||||
inline static bool b32BitCore ( void ) { return m_b32Bit; }
|
||||
inline static bool RspAudioSignal ( void ) { return m_RspAudioSignal; }
|
||||
|
@ -39,6 +39,9 @@ public:
|
|||
static inline bool bSMM_PIDMA ( void ) { return m_bSMM_PIDMA; }
|
||||
static inline bool bSMM_TLB ( void ) { return m_bSMM_TLB; }
|
||||
|
||||
protected:
|
||||
static void SpeedChanged (int SpeedLimit );
|
||||
|
||||
private:
|
||||
//Settings that can be changed on the fly
|
||||
static bool m_bRomInMemory;
|
||||
|
@ -53,6 +56,7 @@ private:
|
|||
static bool m_DelaySI;
|
||||
static DWORD m_RdramSize;
|
||||
static bool m_bFixedAudio;
|
||||
static bool m_bSyncingToAudio;
|
||||
static bool m_bSyncToAudio;
|
||||
static bool m_bFastSP;
|
||||
static bool m_b32Bit;
|
||||
|
|
Loading…
Reference in New Issue