diff --git a/Source/Project64/N64 System/Mips/Audio.cpp b/Source/Project64/N64 System/Mips/Audio.cpp index 111f43efa..ec2fb334d 100644 --- a/Source/Project64/N64 System/Mips/Audio.cpp +++ b/Source/Project64/N64 System/Mips/Audio.cpp @@ -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; } diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index a98f963b9..9f784df7b 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -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), diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index bb7596935..58f37db7f 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -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 ); diff --git a/Source/Project64/N64 System/Speed Limitor Class.cpp b/Source/Project64/N64 System/Speed Limitor Class.cpp index 77f14e08c..f55f9d86e 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.cpp +++ b/Source/Project64/N64 System/Speed Limitor Class.cpp @@ -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(); } \ No newline at end of file diff --git a/Source/Project64/N64 System/Speed Limitor Class.h b/Source/Project64/N64 System/Speed Limitor Class.h index 871ef247f..285a5e850 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.h +++ b/Source/Project64/N64 System/Speed Limitor Class.h @@ -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; }; diff --git a/Source/Project64/Settings/Game Settings.cpp b/Source/Project64/Settings/Game Settings.cpp index 53992199e..19a83dd5d 100644 --- a/Source/Project64/Settings/Game Settings.cpp +++ b/Source/Project64/Settings/Game Settings.cpp @@ -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; } -} \ No newline at end of file +} + +void CGameSettings::SpeedChanged (int SpeedLimit ) +{ + int FullSpeed = g_System->m_SystemType == SYSTEM_PAL ? 50 : 60; + m_bSyncingToAudio = SpeedLimit == FullSpeed ? m_bSyncToAudio : false; +} diff --git a/Source/Project64/Settings/Game Settings.h b/Source/Project64/Settings/Game Settings.h index 5a16915e1..939f3390a 100644 --- a/Source/Project64/Settings/Game Settings.h +++ b/Source/Project64/Settings/Game Settings.h @@ -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;