summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2014-03-02 13:40:10 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2014-03-02 13:40:10 -0600
commitc028513285277ea032fcd21320e6fe877a4b5055 (patch)
treec32595ecf317c49f45b29f604242381528605b43 /Source
parent70b3749d4bce9e4a73b90bc7723dd0e257de9ff9 (diff)
parent13a007abed9835e647dd194c22244ae8eba1ff8b (diff)
Merge pull request #121 from lioncash/remove-clamp
Remove another clamp function laying in the codebase and replace it with the one in MathUtil.h.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp
index 857e0ef7e8..aeda5a1242 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
+#include "Common/MathUtil.h"
#include "Core/PowerPC/Interpreter/Interpreter.h"
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
@@ -47,46 +48,43 @@ const float m_quantizeTable[] =
1.0 / (1 << 4), 1.0 / (1 << 3), 1.0 / (1 << 2), 1.0 / (1 << 1),
};
-template <class T>
-inline T CLAMP(T a, T bottom, T top) {
- if (a > top) return top;
- if (a < bottom) return bottom;
- return a;
-}
-
void Interpreter::Helper_Quantize(const u32 _Addr, const double _fValue, const EQuantizeType _quantizeType, const unsigned int _uScale)
{
switch (_quantizeType)
{
case QUANTIZE_FLOAT:
- Memory::Write_U32( ConvertToSingleFTZ( *(u64*)&_fValue ), _Addr );
+ Memory::Write_U32(ConvertToSingleFTZ(*(u64*)&_fValue), _Addr);
break;
// used for THP player
case QUANTIZE_U8:
{
- float fResult = CLAMP((float)_fValue * m_quantizeTable[_uScale], 0.0f, 255.0f);
+ float fResult = (float)_fValue * m_quantizeTable[_uScale];
+ MathUtil::Clamp(&fResult, 0.0f, 255.0f);
Memory::Write_U8((u8)fResult, _Addr);
}
break;
case QUANTIZE_U16:
{
- float fResult = CLAMP((float)_fValue * m_quantizeTable[_uScale], 0.0f, 65535.0f);
+ float fResult = (float)_fValue * m_quantizeTable[_uScale];
+ MathUtil::Clamp(&fResult, 0.0f, 65535.0f);
Memory::Write_U16((u16)fResult, _Addr);
}
break;
case QUANTIZE_S8:
{
- float fResult = CLAMP((float)_fValue * m_quantizeTable[_uScale], -128.0f, 127.0f);
+ float fResult = (float)_fValue * m_quantizeTable[_uScale];
+ MathUtil::Clamp(&fResult, -128.0f, 127.0f);
Memory::Write_U8((u8)(s8)fResult, _Addr);
}
break;
case QUANTIZE_S16:
{
- float fResult = CLAMP((float)_fValue * m_quantizeTable[_uScale], -32768.0f, 32767.0f);
+ float fResult = (float)_fValue * m_quantizeTable[_uScale];
+ MathUtil::Clamp(&fResult, -32768.0f, 32767.0f);
Memory::Write_U16((u16)(s16)fResult, _Addr);
}
break;