Removed duplicate code between increase and decrease speed in SpeedLimiterClass by merging into one AlterSpeed
This commit is contained in:
parent
40d1a4ed75
commit
4c8e148ed1
|
@ -67,8 +67,7 @@ public:
|
|||
void StartEmulation(bool NewThread);
|
||||
void EndEmulation();
|
||||
void SyncToAudio();
|
||||
void IncreaseSpeed() { m_Limiter.IncreaseSpeed(); }
|
||||
void DecreaseSpeed() { m_Limiter.DecreaseSpeed(); }
|
||||
void AlterSpeed(const CSpeedLimiter::ESpeedChange SpeedChange) { m_Limiter.AlterSpeed(SpeedChange); }
|
||||
void Reset(bool bInitReg, bool ClearMenory);
|
||||
void GameReset();
|
||||
void PluginReset();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
* *
|
||||
* Project64 - A Nintendo 64 emulator. *
|
||||
* Project64 - A Nintendo 64 emulator. *
|
||||
* http://www.pj64-emu.com/ *
|
||||
* Copyright (C) 2012 Project64. All rights reserved. *
|
||||
* *
|
||||
|
@ -8,14 +8,23 @@
|
|||
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "SpeedLimiterClass.h"
|
||||
#include "Project64-Core/N64System/SpeedLimiterClass.h"
|
||||
|
||||
#include <Common/Util.h>
|
||||
|
||||
// ---------------------------------------------------
|
||||
|
||||
const uint32_t CSpeedLimiter::m_HighSpeed = 60;
|
||||
const uint32_t CSpeedLimiter::m_MediumSpeed = 15;
|
||||
|
||||
// ---------------------------------------------------
|
||||
|
||||
CSpeedLimiter::CSpeedLimiter() :
|
||||
m_Frames(0),
|
||||
m_Speed(60),
|
||||
m_BaseSpeed(60)
|
||||
m_Speed(m_HighSpeed),
|
||||
m_BaseSpeed(m_HighSpeed)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -73,38 +82,24 @@ bool CSpeedLimiter::Timer_Process(uint32_t * FrameRate)
|
|||
return false;
|
||||
}
|
||||
|
||||
void CSpeedLimiter::IncreaseSpeed()
|
||||
void CSpeedLimiter::AlterSpeed( const ESpeedChange SpeedChange )
|
||||
{
|
||||
if (m_Speed >= 60)
|
||||
{
|
||||
m_Speed += 10;
|
||||
}
|
||||
else if (m_Speed >= 15)
|
||||
{
|
||||
m_Speed += 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Speed += 1;
|
||||
}
|
||||
SpeedChanged(m_Speed);
|
||||
FixSpeedRatio();
|
||||
}
|
||||
int32_t SpeedFactor = 1;
|
||||
if (SpeedChange == DECREASE_SPEED) { SpeedFactor = -1; }
|
||||
|
||||
void CSpeedLimiter::DecreaseSpeed()
|
||||
{
|
||||
if (m_Speed > 60)
|
||||
{
|
||||
m_Speed -= 10;
|
||||
}
|
||||
else if (m_Speed > 15)
|
||||
{
|
||||
m_Speed -= 5;
|
||||
}
|
||||
else if (m_Speed > 1)
|
||||
{
|
||||
m_Speed -= 1;
|
||||
}
|
||||
SpeedChanged(m_Speed);
|
||||
FixSpeedRatio();
|
||||
if (m_Speed >= m_HighSpeed)
|
||||
{
|
||||
m_Speed += 10 * SpeedFactor;
|
||||
}
|
||||
else if (m_Speed >= m_MediumSpeed)
|
||||
{
|
||||
m_Speed += 5 * SpeedFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Speed += 1 * SpeedFactor;
|
||||
}
|
||||
|
||||
SpeedChanged(m_Speed);
|
||||
FixSpeedRatio();
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
* *
|
||||
* Project64 - A Nintendo 64 emulator. *
|
||||
* Project64 - A Nintendo 64 emulator. *
|
||||
* http://www.pj64-emu.com/ *
|
||||
* Copyright (C) 2012 Project64. All rights reserved. *
|
||||
* *
|
||||
|
@ -11,19 +11,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <Project64-core/Settings/GameSettings.h>
|
||||
|
||||
#include <Common/HighResTimeStamp.h>
|
||||
|
||||
class CSpeedLimiter :
|
||||
private CGameSettings
|
||||
{
|
||||
public:
|
||||
enum ESpeedChange { INCREASE_SPEED, DECREASE_SPEED };
|
||||
|
||||
CSpeedLimiter();
|
||||
~CSpeedLimiter();
|
||||
|
||||
void SetHertz(const uint32_t Hertz);
|
||||
bool Timer_Process(uint32_t* const FrameRate);
|
||||
void IncreaseSpeed();
|
||||
void DecreaseSpeed();
|
||||
|
||||
void AlterSpeed(const ESpeedChange SpeedChange);
|
||||
|
||||
private:
|
||||
CSpeedLimiter(const CSpeedLimiter&); // Disable copy constructor
|
||||
|
@ -31,7 +34,10 @@ private:
|
|||
|
||||
void FixSpeedRatio();
|
||||
|
||||
uint32_t m_Speed, m_BaseSpeed, m_Frames;
|
||||
HighResTimeStamp m_LastTime;
|
||||
uint32_t m_MicroSecondsPerFrame;
|
||||
HighResTimeStamp m_LastTime;
|
||||
|
||||
uint32_t m_Speed, m_BaseSpeed, m_Frames, m_MicroSecondsPerFrame;
|
||||
|
||||
static const uint32_t m_HighSpeed;
|
||||
static const uint32_t m_MediumSpeed;
|
||||
};
|
||||
|
|
|
@ -385,10 +385,10 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
|
|||
}
|
||||
break;
|
||||
case ID_OPTIONS_INCREASE_SPEED:
|
||||
g_BaseSystem->IncreaseSpeed();
|
||||
g_BaseSystem->AlterSpeed(CSpeedLimiter::INCREASE_SPEED);
|
||||
break;
|
||||
case ID_OPTIONS_DECREASE_SPEED:
|
||||
g_BaseSystem->DecreaseSpeed();
|
||||
g_BaseSystem->AlterSpeed(CSpeedLimiter::DECREASE_SPEED);
|
||||
break;
|
||||
case ID_OPTIONS_FULLSCREEN:
|
||||
g_BaseSystem->ExternalEvent(SysEvent_ChangingFullScreen);
|
||||
|
|
Loading…
Reference in New Issue