From f0ea5144eac27f700700c797c8795a1c0703409f Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 9 Oct 2022 01:16:21 -0400 Subject: [PATCH] clang-format source files Former-commit-id: 39700ad77913f5681378e59616c74856e6f49d70 --- include/MetroidPrime/Weapons/CGunWeapon.hpp | 1 - src/Collision/CMRay.cpp | 4 +- src/Collision/COBBox.cpp | 13 +- src/Dolphin/dtk.c | 4 +- src/Kyoto/Basics/COsContextDolphin.cpp | 2 +- src/Kyoto/Basics/CStopwatch.cpp | 19 +- src/Kyoto/Basics/RAssertDolphin.cpp | 10 +- src/Kyoto/Graphics/CLight.cpp | 6 +- src/Kyoto/IObj.cpp | 2 +- src/Kyoto/Math/CPlane.cpp | 7 +- src/Kyoto/Math/CUnitVector3f.cpp | 3 +- src/Kyoto/Math/CVector3i.cpp | 3 +- src/Kyoto/Math/RMathUtils.cpp | 9 +- src/Kyoto/Text/CTextParser.cpp | 56 +++--- .../CArchMsgParmControllerStatus.cpp | 6 +- src/MetroidPrime/CArchMsgParmInt32.cpp | 4 +- .../CArchMsgParmInt32Int32VoidPtr.cpp | 4 +- src/MetroidPrime/CArchMsgParmReal32.cpp | 4 +- src/MetroidPrime/CArchMsgParmUserInput.cpp | 7 +- src/MetroidPrime/CAxisAngle.cpp | 22 +-- src/MetroidPrime/CDamageVulnerability.cpp | 15 +- src/MetroidPrime/CMemoryDrawEnum.cpp | 1 - src/MetroidPrime/CObjectList.cpp | 28 +-- src/MetroidPrime/CPhysicsActor.cpp | 3 +- src/MetroidPrime/Cameras/CCameraFilter.cpp | 4 +- src/MetroidPrime/Cameras/CCameraHint.cpp | 13 +- src/MetroidPrime/Player/CPlayerGun.cpp | 31 ++-- src/MetroidPrime/ScriptObjects/CFire.cpp | 9 +- .../Weapons/GunController/CGSFreeLook.cpp | 2 +- .../Weapons/GunController/CGunController.cpp | 4 +- .../Weapons/GunController/CGunMotion.cpp | 4 +- src/Runtime/NMWException.h | 5 +- src/Runtime/__mem.c | 2 - src/Runtime/e_exp.c | 164 ++++++++++-------- src/musyx/snd_math.c | 4 +- 35 files changed, 211 insertions(+), 264 deletions(-) diff --git a/include/MetroidPrime/Weapons/CGunWeapon.hpp b/include/MetroidPrime/Weapons/CGunWeapon.hpp index 17bbc2c0..7194aa91 100644 --- a/include/MetroidPrime/Weapons/CGunWeapon.hpp +++ b/include/MetroidPrime/Weapons/CGunWeapon.hpp @@ -1,4 +1,3 @@ -// #pragma once #ifndef _CGUNWEAPON #define _CGUNWEAPON diff --git a/src/Collision/CMRay.cpp b/src/Collision/CMRay.cpp index 3eb97a7e..9ec21180 100644 --- a/src/Collision/CMRay.cpp +++ b/src/Collision/CMRay.cpp @@ -7,8 +7,7 @@ CMRay::CMRay(const CVector3f& start, const CVector3f& end, float length, float i , mDelta(mEnd - mStart) , mLength(length) , mInvLength(invLength) -, mDir(mInvLength * mDelta) { -} +, mDir(mInvLength * mDelta) {} CMRay::CMRay(const CVector3f& start, const CVector3f& dir, float length) : mStart(start) @@ -18,7 +17,6 @@ CMRay::CMRay(const CVector3f& start, const CVector3f& dir, float length) , mInvLength(1.f / length) , mDir(dir) {} - CMRay CMRay::GetInvUnscaledTransformRay(const CTransform4f& xf) const { CTransform4f invXf = xf.GetQuickInverse(); return CMRay(invXf * mStart, invXf * mEnd, mLength, mInvLength); diff --git a/src/Collision/COBBox.cpp b/src/Collision/COBBox.cpp index 8e444da7..bec6bf25 100644 --- a/src/Collision/COBBox.cpp +++ b/src/Collision/COBBox.cpp @@ -7,24 +7,19 @@ COBBox::COBBox(const CTransform4f& xf, const CVector3f& extents) COBBox::COBBox(CInputStream& in) : mTransform(in), mExtents(in) {} -CAABox COBBox::CalculateAABox(const CTransform4f& xf) const { -} +CAABox COBBox::CalculateAABox(const CTransform4f& xf) const {} COBBox COBBox::FromAABox(const CAABox& box, const CTransform4f& xf) { CVector3f center = box.GetCenterPoint(); CVector3f extents = box.GetMaxPoint() - center; CTransform4f final = xf * CTransform4f::Translate(center); - return COBBox(final, extents); + return COBBox(final, extents); } -bool COBBox::LineIntersectsBox(const CMRay& ray, float& penetration) const { - -} +bool COBBox::LineIntersectsBox(const CMRay& ray, float& penetration) const {} bool COBBox::AABoxIntersectsBox(const CAABox& box) const { return OBBIntersectsBox(FromAABox(box, CTransform4f::Identity())); } -bool COBBox::OBBIntersectsBox(const COBBox& box) const { - return false; -} +bool COBBox::OBBIntersectsBox(const COBBox& box) const { return false; } diff --git a/src/Dolphin/dtk.c b/src/Dolphin/dtk.c index d8f9e78d..b59a850d 100644 --- a/src/Dolphin/dtk.c +++ b/src/Dolphin/dtk.c @@ -345,9 +345,7 @@ void DTKNextTrack() { } } -u32 DTKGetState() { - return __DTKState; -} +u32 DTKGetState() { return __DTKState; } void DTKSetVolume(u8 left, u8 right) { __DTKVolumeL = left; diff --git a/src/Kyoto/Basics/COsContextDolphin.cpp b/src/Kyoto/Basics/COsContextDolphin.cpp index bd98cf08..8e8de126 100644 --- a/src/Kyoto/Basics/COsContextDolphin.cpp +++ b/src/Kyoto/Basics/COsContextDolphin.cpp @@ -78,7 +78,7 @@ int COsContext::OpenWindow(const char* title, int x, int y, int w, int h, bool f if (mProgressiveMode) { x30_renderMode.viTVmode = VI_TVMODE_NTSC_PROG; x30_renderMode.xFBmode = VI_XFBMODE_SF; - u8 progressiveFilterPattern[7] = {4, 4, 16, 16, 16, 4, 4 }; + u8 progressiveFilterPattern[7] = {4, 4, 16, 16, 16, 4, 4}; memcpy(x30_renderMode.vfilter, progressiveFilterPattern, 7); } VIConfigure(&x30_renderMode); diff --git a/src/Kyoto/Basics/CStopwatch.cpp b/src/Kyoto/Basics/CStopwatch.cpp index 61d640e1..0ca0a898 100644 --- a/src/Kyoto/Basics/CStopwatch.cpp +++ b/src/Kyoto/Basics/CStopwatch.cpp @@ -4,20 +4,17 @@ CStopwatch::CSWData CStopwatch::mData; CStopwatch CStopwatch::mGlobalTimer; - bool CStopwatch::InitGlobalTimer() { - mGlobalTimer.Reset(); - return true; + mGlobalTimer.Reset(); + return true; } void CStopwatch::Wait(float wait) { - if (fabs(wait) < 0.0010000000474974512) { - mData.Wait(0.f); - } else { - mData.Wait(wait); - } + if (fabs(wait) < 0.0010000000474974512) { + mData.Wait(0.f); + } else { + mData.Wait(wait); + } } -CStopwatch& CStopwatch::GetGlobalTimerObj() { - return mGlobalTimer; -} +CStopwatch& CStopwatch::GetGlobalTimerObj() { return mGlobalTimer; } diff --git a/src/Kyoto/Basics/RAssertDolphin.cpp b/src/Kyoto/Basics/RAssertDolphin.cpp index a07c37aa..92d44a5d 100644 --- a/src/Kyoto/Basics/RAssertDolphin.cpp +++ b/src/Kyoto/Basics/RAssertDolphin.cpp @@ -121,8 +121,8 @@ void ErrorHandler(OSError code, OSContext* context, int arg1, int arg2) { } void SetErrorHandlers() { - OSSetErrorHandler(2, (OSErrorHandler*) ErrorHandler); - OSSetErrorHandler(3, (OSErrorHandler*) ErrorHandler); - OSSetErrorHandler(5, (OSErrorHandler*) ErrorHandler); - OSSetErrorHandler(15, (OSErrorHandler*) ErrorHandler); -} \ No newline at end of file + OSSetErrorHandler(2, (OSErrorHandler*)ErrorHandler); + OSSetErrorHandler(3, (OSErrorHandler*)ErrorHandler); + OSSetErrorHandler(5, (OSErrorHandler*)ErrorHandler); + OSSetErrorHandler(15, (OSErrorHandler*)ErrorHandler); +} diff --git a/src/Kyoto/Graphics/CLight.cpp b/src/Kyoto/Graphics/CLight.cpp index 274f117e..ead14aca 100644 --- a/src/Kyoto/Graphics/CLight.cpp +++ b/src/Kyoto/Graphics/CLight.cpp @@ -106,7 +106,7 @@ float CLight::GetRadius() const { } float CLight::CalculateLightRadius() const { - if (x28_distL < gkEpsilon32 && x2c_distQ < gkEpsilon32) { + if (x28_distL < gkEpsilon32 && x2c_distQ < gkEpsilon32) { return FLT_MAX; } @@ -134,7 +134,9 @@ float CLight::GetIntensity() const { if (x1c_type == kLT_Custom) { coef = x30_angleC; } - x48_cachedIntensity = coef * rstl::max_val(x18_color.GetRed(), rstl::max_val(x18_color.GetGreen(), x18_color.GetBlue())); + x48_cachedIntensity = + coef * + rstl::max_val(x18_color.GetRed(), rstl::max_val(x18_color.GetGreen(), x18_color.GetBlue())); } return x48_cachedIntensity; } diff --git a/src/Kyoto/IObj.cpp b/src/Kyoto/IObj.cpp index 60b242aa..19d88010 100644 --- a/src/Kyoto/IObj.cpp +++ b/src/Kyoto/IObj.cpp @@ -8,7 +8,7 @@ const char* SObjectTag::Type2Text(FourCC type) { text[0] = toupper((type >> 24) & 0xFF); text[1] = toupper((type >> 16) & 0xFF); text[2] = toupper((type >> 8) & 0xFF); - text[3] = toupper(type & 0xFF); + text[3] = toupper(type & 0xFF); text[4] = '\0'; for (int i = 0; i < 4; ++i) { diff --git a/src/Kyoto/Math/CPlane.cpp b/src/Kyoto/Math/CPlane.cpp index 4ec2abf2..77f3b6ce 100644 --- a/src/Kyoto/Math/CPlane.cpp +++ b/src/Kyoto/Math/CPlane.cpp @@ -2,11 +2,10 @@ #include "Kyoto/Math/CMath.hpp" CPlane::CPlane(const CVector3f& a, const CVector3f& b, const CVector3f& c) -: x0_normal(CVector3f::Cross(b - a, c - a)) -, xc_constant(CVector3f::Dot(x0_normal, a)) { -} +: x0_normal(CVector3f::Cross(b - a, c - a)), xc_constant(CVector3f::Dot(x0_normal, a)) {} float CPlane::ClipLineSegment(const CVector3f& start, const CVector3f& end) const { - float dist = -(CVector3f::Dot(start, GetNormal()) - GetConstant()) / CVector3f::Dot(end - start, GetNormal()); + float dist = -(CVector3f::Dot(start, GetNormal()) - GetConstant()) / + CVector3f::Dot(end - start, GetNormal()); return dist <= 0.f ? 0.f : (dist >= 1.f ? 1.f : dist); } diff --git a/src/Kyoto/Math/CUnitVector3f.cpp b/src/Kyoto/Math/CUnitVector3f.cpp index 9a6cc38f..9d54189d 100644 --- a/src/Kyoto/Math/CUnitVector3f.cpp +++ b/src/Kyoto/Math/CUnitVector3f.cpp @@ -1,5 +1,4 @@ #include "Kyoto/Math/CUnitVector3f.hpp" CUnitVector3f::CUnitVector3f(const CVector3f& vec) -: CVector3f(vec.IsNonZero() ? vec.AsNormalized() : CVector3f::Zero()) { -} +: CVector3f(vec.IsNonZero() ? vec.AsNormalized() : CVector3f::Zero()) {} diff --git a/src/Kyoto/Math/CVector3i.cpp b/src/Kyoto/Math/CVector3i.cpp index 1aeb984b..87732fc1 100644 --- a/src/Kyoto/Math/CVector3i.cpp +++ b/src/Kyoto/Math/CVector3i.cpp @@ -1,4 +1,3 @@ #include "Kyoto/Math/CVector3i.hpp" -CVector3i::CVector3i(int x, int y, int z) -: mX(x), mY(y), mZ(z) {} +CVector3i::CVector3i(int x, int y, int z) : mX(x), mY(y), mZ(z) {} diff --git a/src/Kyoto/Math/RMathUtils.cpp b/src/Kyoto/Math/RMathUtils.cpp index e37bcdf4..5d785c83 100644 --- a/src/Kyoto/Math/RMathUtils.cpp +++ b/src/Kyoto/Math/RMathUtils.cpp @@ -1,10 +1,5 @@ #include "Kyoto/Math/CMath.hpp" +float CMath::SqrtF(float x) { return 0.f; } -float CMath::SqrtF(float x) { - return 0.f; -} - -double CMath::SqrtD(double x) { - return 0.0; -} +double CMath::SqrtD(double x) { return 0.0; } diff --git a/src/Kyoto/Text/CTextParser.cpp b/src/Kyoto/Text/CTextParser.cpp index ffeae001..917a8124 100644 --- a/src/Kyoto/Text/CTextParser.cpp +++ b/src/Kyoto/Text/CTextParser.cpp @@ -1,33 +1,23 @@ #include -#include #include +#include -CTextParser::CTextParser(IObjectStore& store) -: mObjectStore(store) {} +CTextParser::CTextParser(IObjectStore& store) : mObjectStore(store) {} -void CTextParser::ParseText(CTextExecuteBuffer& buffer, const wchar_t* str, int len) { -} +void CTextParser::ParseText(CTextExecuteBuffer& buffer, const wchar_t* str, int len) {} -uint CTextParser::GetAssetIdFromString(const rstl::string& str) { +uint CTextParser::GetAssetIdFromString(const rstl::string& str) {} -} +uint CTextParser::GetFont(const wchar_t* str, int len) { return -1; } -uint CTextParser::GetFont(const wchar_t* str, int len) { - return -1; -} - -uint CTextParser::GetImage(const wchar_t* str, int len) { - return -1; -} +uint CTextParser::GetImage(const wchar_t* str, int len) { return -1; } uint CTextParser::HandleUserTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len) { - return 0; + return 0; } -void CTextParser::ParseTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len) { - -} +void CTextParser::ParseTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len) {} bool CTextParser::BeginsWith(const wchar_t* str1, int len, const wchar_t* str2) { int i = 0; @@ -36,19 +26,19 @@ bool CTextParser::BeginsWith(const wchar_t* str1, int len, const wchar_t* str2) return false; } } - + return str2[i] == L'\x0'; } bool CTextParser::Equals(const wchar_t* str1, int len, const wchar_t* str2) { - int i = 0; - for (;str2[i] != L'\x0' && i < len; ++i) { - if (str1[i] != str2[i]) { - return false; - } + int i = 0; + for (; str2[i] != L'\x0' && i < len; ++i) { + if (str1[i] != str2[i]) { + return false; } + } - return str2[i] == L'\x0'; + return str2[i] == L'\x0'; } uint CTextParser::ParseInt(const wchar_t* str, int len, bool signVal) { @@ -84,16 +74,16 @@ uint CTextParser::FromHex(wchar_t ch) { } uint CTextParser::GetColorValue(const wchar_t* str) { - uint a = (FromHex(str[0]) << 4); - uint b = FromHex(str[1]); - return b + a; + uint a = (FromHex(str[0]) << 4); + uint b = FromHex(str[1]); + return b + a; } CTextColor CTextParser::ParseColor(const wchar_t* str, int len) { - uint r = GetColorValue(str + 1); - uint g = GetColorValue(str + 3); - uint b = GetColorValue(str + 5); - uint a = len == 9 ? GetColorValue(str + 7) : 255; + uint r = GetColorValue(str + 1); + uint g = GetColorValue(str + 3); + uint b = GetColorValue(str + 5); + uint a = len == 9 ? GetColorValue(str + 7) : 255; - return CTextColor(r, g, b, a); + return CTextColor(r, g, b, a); } diff --git a/src/MetroidPrime/CArchMsgParmControllerStatus.cpp b/src/MetroidPrime/CArchMsgParmControllerStatus.cpp index 97fb1c5a..7cfa3fb7 100644 --- a/src/MetroidPrime/CArchMsgParmControllerStatus.cpp +++ b/src/MetroidPrime/CArchMsgParmControllerStatus.cpp @@ -1,11 +1,7 @@ #include "MetroidPrime/CArchMsgParmControllerStatus.hpp" #include "Kyoto/Alloc/CMemory.hpp" - CArchMsgParmControllerStatus::CArchMsgParmControllerStatus(short channel, bool connected) -: mChannel(channel) -, mConnected(connected) { -} - +: mChannel(channel), mConnected(connected) {} CArchMsgParmControllerStatus::~CArchMsgParmControllerStatus() {} diff --git a/src/MetroidPrime/CArchMsgParmInt32.cpp b/src/MetroidPrime/CArchMsgParmInt32.cpp index e3ac6303..0e64b042 100644 --- a/src/MetroidPrime/CArchMsgParmInt32.cpp +++ b/src/MetroidPrime/CArchMsgParmInt32.cpp @@ -1,8 +1,6 @@ #include "MetroidPrime/CArchMsgParmInt32.hpp" #include "Kyoto/Alloc/CMemory.hpp" -CArchMsgParmInt32::CArchMsgParmInt32(int val) -: mVal(val) {} - +CArchMsgParmInt32::CArchMsgParmInt32(int val) : mVal(val) {} CArchMsgParmInt32::~CArchMsgParmInt32() {} diff --git a/src/MetroidPrime/CArchMsgParmInt32Int32VoidPtr.cpp b/src/MetroidPrime/CArchMsgParmInt32Int32VoidPtr.cpp index f26c5e64..5124d72e 100644 --- a/src/MetroidPrime/CArchMsgParmInt32Int32VoidPtr.cpp +++ b/src/MetroidPrime/CArchMsgParmInt32Int32VoidPtr.cpp @@ -3,8 +3,6 @@ #include "Kyoto/Alloc/CMemory.hpp" CArchMsgParmInt32Int32VoidPtr::CArchMsgParmInt32Int32VoidPtr(int val1, int val2, const void* ptr) -: mInt1(val1) -, mInt2(val2) -, mPtr(ptr) {} +: mInt1(val1), mInt2(val2), mPtr(ptr) {} CArchMsgParmInt32Int32VoidPtr::~CArchMsgParmInt32Int32VoidPtr() {} diff --git a/src/MetroidPrime/CArchMsgParmReal32.cpp b/src/MetroidPrime/CArchMsgParmReal32.cpp index ea8dace5..aa0d80b6 100644 --- a/src/MetroidPrime/CArchMsgParmReal32.cpp +++ b/src/MetroidPrime/CArchMsgParmReal32.cpp @@ -1,8 +1,6 @@ #include "MetroidPrime/CArchMsgParmReal32.hpp" #include "Kyoto/Alloc/CMemory.hpp" -CArchMsgParmReal32::CArchMsgParmReal32(float val) -: mVal(val) {} - +CArchMsgParmReal32::CArchMsgParmReal32(float val) : mVal(val) {} CArchMsgParmReal32::~CArchMsgParmReal32() {} diff --git a/src/MetroidPrime/CArchMsgParmUserInput.cpp b/src/MetroidPrime/CArchMsgParmUserInput.cpp index 09a82c9c..d5e77f9e 100644 --- a/src/MetroidPrime/CArchMsgParmUserInput.cpp +++ b/src/MetroidPrime/CArchMsgParmUserInput.cpp @@ -2,11 +2,8 @@ #include "Kyoto/Alloc/CMemory.hpp" -CArchMsgParmUserInput::CArchMsgParmUserInput(const CFinalInput& input) -: mInput(input) {} +CArchMsgParmUserInput::CArchMsgParmUserInput(const CFinalInput& input) : mInput(input) {} CArchMsgParmUserInput::~CArchMsgParmUserInput() {} -const CFinalInput& CArchMsgParmUserInput::GetUserInput() const { - return mInput; -} +const CFinalInput& CArchMsgParmUserInput::GetUserInput() const { return mInput; } diff --git a/src/MetroidPrime/CAxisAngle.cpp b/src/MetroidPrime/CAxisAngle.cpp index 9b939819..f7689e48 100644 --- a/src/MetroidPrime/CAxisAngle.cpp +++ b/src/MetroidPrime/CAxisAngle.cpp @@ -5,33 +5,25 @@ const CAxisAngle CAxisAngle::sIdentity; CAxisAngle::CAxisAngle(const CVector3f& vec) : mVector(vec) {} CAxisAngle::CAxisAngle(const CUnitVector3f& vec, float angle) : mVector(vec * angle) {} -void CAxisAngle::FromVector(const CVector3f& axis) { - mVector = axis; -} +void CAxisAngle::FromVector(const CVector3f& axis) { mVector = axis; } -const CAxisAngle& CAxisAngle::Identity() { - return sIdentity; -} +const CAxisAngle& CAxisAngle::Identity() { return sIdentity; } -const CVector3f& CAxisAngle::GetVector() const { - return mVector; -} +const CVector3f& CAxisAngle::GetVector() const { return mVector; } -float CAxisAngle::GetAngle() const { - return mVector.Magnitude(); -} +float CAxisAngle::GetAngle() const { return mVector.Magnitude(); } const CAxisAngle& CAxisAngle::operator*=(const float& rhs) { - mVector *= rhs; + mVector *= rhs; return *this; } const CAxisAngle& CAxisAngle::operator+=(const CAxisAngle& rhs) { - mVector += rhs.mVector; + mVector += rhs.mVector; return *this; } -CAxisAngle operator*(const CAxisAngle& lhs,const float& rhs) { +CAxisAngle operator*(const CAxisAngle& lhs, const float& rhs) { CAxisAngle angle; angle.mVector = lhs.mVector * rhs; return angle; diff --git a/src/MetroidPrime/CDamageVulnerability.cpp b/src/MetroidPrime/CDamageVulnerability.cpp index 42489bb2..adf2441f 100644 --- a/src/MetroidPrime/CDamageVulnerability.cpp +++ b/src/MetroidPrime/CDamageVulnerability.cpp @@ -149,13 +149,14 @@ bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, int ignoreDirect } static inline bool check_hits(EVulnerability vuln, int direct) { - if (!direct) { - return is_not_deflect(vuln); - } - if (vuln == kVN_Deflect || ((u32)vuln - kVN_DirectWeak <= kVN_Normal) || vuln == kVN_DirectImmune) { - return false; - } - return true; + if (!direct) { + return is_not_deflect(vuln); + } + if (vuln == kVN_Deflect || ((u32)vuln - kVN_DirectWeak <= kVN_Normal) || + vuln == kVN_DirectImmune) { + return false; + } + return true; } bool CDamageVulnerability::WeaponHits(const CWeaponMode& mode, int checkDirect) const { diff --git a/src/MetroidPrime/CMemoryDrawEnum.cpp b/src/MetroidPrime/CMemoryDrawEnum.cpp index 23727790..f590071f 100644 --- a/src/MetroidPrime/CMemoryDrawEnum.cpp +++ b/src/MetroidPrime/CMemoryDrawEnum.cpp @@ -1,7 +1,6 @@ //#include #include - /* ODR strikes again! */ IAllocator::SMetrics::SMetrics(const SMetrics& other) : x0_heapSize(other.x0_heapSize) diff --git a/src/MetroidPrime/CObjectList.cpp b/src/MetroidPrime/CObjectList.cpp index cc834377..8bb9ede9 100644 --- a/src/MetroidPrime/CObjectList.cpp +++ b/src/MetroidPrime/CObjectList.cpp @@ -30,30 +30,16 @@ void CObjectList::AddObject(CEntity& ent) { void CObjectList::RemoveObject(TUniqueId uid) {} -CEntity* CObjectList::GetObjectById() { - return nullptr; -} +CEntity* CObjectList::GetObjectById() { return nullptr; } -const CEntity* CObjectList::GetObjectById() const { - return nullptr; -} +const CEntity* CObjectList::GetObjectById() const { return nullptr; } -CEntity* CObjectList::GetValidObjectById(TUniqueId uid) { - return nullptr; -} +CEntity* CObjectList::GetValidObjectById(TUniqueId uid) { return nullptr; } -const CEntity* CObjectList::GetValidObjectById(TUniqueId uid) const { - return nullptr; -} +const CEntity* CObjectList::GetValidObjectById(TUniqueId uid) const { return nullptr; } -CEntity* CObjectList::operator[](int idx) { - return nullptr; -} +CEntity* CObjectList::operator[](int idx) { return nullptr; } -const CEntity* CObjectList::operator[](int idx) const { - return nullptr; -} +const CEntity* CObjectList::operator[](int idx) const { return nullptr; } -const CEntity* CObjectList::GetValidObjectByIndex(int idx) const { - return nullptr; -} +const CEntity* CObjectList::GetValidObjectByIndex(int idx) const { return nullptr; } diff --git a/src/MetroidPrime/CPhysicsActor.cpp b/src/MetroidPrime/CPhysicsActor.cpp index c9056004..c23adca1 100644 --- a/src/MetroidPrime/CPhysicsActor.cpp +++ b/src/MetroidPrime/CPhysicsActor.cpp @@ -196,10 +196,9 @@ void CPhysicsActor::MoveToInOneFrameWR(const CVector3f& trans, float d) { x18c_moveImpulse += (trans - GetTranslation()) * GetMass() * (1.f / d); } - CVector3f CPhysicsActor::GetMoveToORImpulseWR(const CVector3f& trans, float d) const { CVector3f impulse = x34_transform.Rotate(trans); - return (GetMass() * impulse) * (1.f / d); + return (GetMass() * impulse) * (1.f / d); } CAxisAngle CPhysicsActor::GetRotateToORAngularMomentumWR(const CQuaternion& q, float d) const {} diff --git a/src/MetroidPrime/Cameras/CCameraFilter.cpp b/src/MetroidPrime/Cameras/CCameraFilter.cpp index d13c74e9..4befceec 100644 --- a/src/MetroidPrime/Cameras/CCameraFilter.cpp +++ b/src/MetroidPrime/Cameras/CCameraFilter.cpp @@ -9,7 +9,9 @@ void CCameraFilterPass::DrawWideScreen(const CColor& color, const CTexture* tex, f32 lod) { const rstl::pair< CVector2f, CVector2f > vp = gpRender->SetViewportOrtho(true, -4096.f, 4096.f); f32 left = vp.first.GetX(); - f32 dVar5 = -((vp.second.GetX() - vp.first.GetX()) * 0.0625f * 9.f - (vp.second.GetY() - vp.first.GetY())) * 0.5f; + f32 dVar5 = -((vp.second.GetX() - vp.first.GetX()) * 0.0625f * 9.f - + (vp.second.GetY() - vp.first.GetY())) * + 0.5f; f32 bottom = vp.first.GetY(); f32 right = vp.second.GetX(); f32 top = vp.second.GetY(); diff --git a/src/MetroidPrime/Cameras/CCameraHint.cpp b/src/MetroidPrime/Cameras/CCameraHint.cpp index 3eca7b97..1a1aaeec 100644 --- a/src/MetroidPrime/Cameras/CCameraHint.cpp +++ b/src/MetroidPrime/Cameras/CCameraHint.cpp @@ -1,12 +1,13 @@ #include "MetroidPrime/Cameras/CCameraHint.hpp" #include "Kyoto/Alloc/CMemory.hpp" -CCameraHint::CCameraHint(uint overrideFlags, CBallCamera::EBallCameraBehaviour behaviour, float minDist, - float maxDist, float backwardsDist, const CVector3f& lookAtOffset, - const CVector3f& chaseLookAtOffset, const CVector3f& ballToCam, float fov, - float attitudeRange, float azimuthRange, float anglePerSecond, float clampVelRange, - float clampRotRange, float elevation, float interpolateTime, float clampVelTime, - float controlInterpDur) +CCameraHint::CCameraHint(uint overrideFlags, CBallCamera::EBallCameraBehaviour behaviour, + float minDist, float maxDist, float backwardsDist, + const CVector3f& lookAtOffset, const CVector3f& chaseLookAtOffset, + const CVector3f& ballToCam, float fov, float attitudeRange, + float azimuthRange, float anglePerSecond, float clampVelRange, + float clampRotRange, float elevation, float interpolateTime, + float clampVelTime, float controlInterpDur) : mOverrideFlags(overrideFlags) , mBehaviour(behaviour) , mMinDist(minDist) diff --git a/src/MetroidPrime/Player/CPlayerGun.cpp b/src/MetroidPrime/Player/CPlayerGun.cpp index 06c88114..2c40aa00 100644 --- a/src/MetroidPrime/Player/CPlayerGun.cpp +++ b/src/MetroidPrime/Player/CPlayerGun.cpp @@ -9,6 +9,7 @@ #include "MetroidPrime/Cameras/CCameraManager.hpp" #include "MetroidPrime/Player/CGrappleArm.hpp" #include "MetroidPrime/Player/CPlayer.hpp" +#include "MetroidPrime/SFX/Weapons.h" #include "MetroidPrime/Tweaks/CTweakGunRes.hpp" #include "MetroidPrime/Tweaks/CTweakPlayerGun.hpp" #include "MetroidPrime/Weapons/CAuxWeapon.hpp" @@ -20,7 +21,6 @@ #include "MetroidPrime/Weapons/CWaveBeam.hpp" #include "MetroidPrime/Weapons/GunController/CGunMotion.hpp" #include "MetroidPrime/Weapons/WeaponTypes.hpp" -#include "MetroidPrime/SFX/Weapons.h" #include "Kyoto/Audio/CSfxManager.hpp" #include "Kyoto/Graphics/CModelFlags.hpp" @@ -713,8 +713,9 @@ void CPlayerGun::UpdateWeaponFire(float dt, CPlayerState& playerState, CStateMan x835_29_powerBombReady = false; if (!x835_31_actorAttached) { x835_28_bombReady = true; - if (x53a_powerBomb != kInvalidUniqueId && !mgr.CanCreateProjectile(x538_playerId, kWT_PowerBomb, 1)) { - const CPowerBomb* pb = static_cast(mgr.GetObjectById(x53a_powerBomb)); + if (x53a_powerBomb != kInvalidUniqueId && + !mgr.CanCreateProjectile(x538_playerId, kWT_PowerBomb, 1)) { + const CPowerBomb* pb = static_cast< const CPowerBomb* >(mgr.GetObjectById(x53a_powerBomb)); if (pb && pb->GetCurTime() <= 4.25f) { x835_28_bombReady = false; } else { @@ -752,7 +753,8 @@ void CPlayerGun::UpdateWeaponFire(float dt, CPlayerState& playerState, CStateMan FireSecondary(dt, mgr); } else { if (!CSfxManager::IsPlaying(x2e4_invalidSfx)) { - x2e4_invalidSfx = NWeaponTypes::play_sfx(SFXwpn_invalid_action, x834_27_underwater, false, 0x4a); + x2e4_invalidSfx = + NWeaponTypes::play_sfx(SFXwpn_invalid_action, x834_27_underwater, false, 0x4a); } else { x2e4_invalidSfx.Clear(); } @@ -827,14 +829,15 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C x833_24_notFidgeting = !(player.GetSurfaceRestraint() != CPlayer::kSR_Water && mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::kPV_Scan && - (x2f4_fireButtonStates & 0x3) == 0 && x32c_chargePhase == kCP_NotCharging && !x832_29_lockedOn && - (x2f8_stateFlags & 0x8) != 0x8 && x364_gunStrikeCoolTimer <= 0.f && + (x2f4_fireButtonStates & 0x3) == 0 && x32c_chargePhase == kCP_NotCharging && + !x832_29_lockedOn && (x2f8_stateFlags & 0x8) != 0x8 && x364_gunStrikeCoolTimer <= 0.f && player.GetPlayerMovementState() == NPlayer::kMS_OnGround && !player.IsInFreeLook() && !player.GetFreeLookStickState() && player.GetOrbitState() == CPlayer::kOS_NoOrbit && fabs(player.GetAngularVelocityOR().GetAngle()) <= 0.1f && camBobT <= 0.01f && !mgr.GetCameraManager()->IsInCinematicCamera() && player.GetGunHolsterState() == CPlayer::kGH_Drawn && - player.GetGrappleState() == CPlayer::kGS_None && !x834_30_inBigStrike && !x835_25_inPhazonBeam); + player.GetGrappleState() == CPlayer::kGS_None && !x834_30_inBigStrike && + !x835_25_inPhazonBeam); if (x833_24_notFidgeting) { if (!x834_30_inBigStrike) { bool doWander = camBobT > 0.01f && (x2f4_fireButtonStates & 0x3) == 0; @@ -858,12 +861,14 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C x394_damageTimer = 0.f; x834_31_gunMotionInFidgetBasePosition = true; x73c_gunMotion->BasePosition(true); - } else if (!x73c_gunMotion->GetModelData().GetAnimationData()->IsAnimTimeRemaining(0.001f, rstl::string_l("Whole Body"))) { + } else if (!x73c_gunMotion->GetModelData().GetAnimationData()->IsAnimTimeRemaining( + 0.001f, rstl::string_l("Whole Body"))) { x834_30_inBigStrike = false; x834_31_gunMotionInFidgetBasePosition = false; } } else { - switch (x3a4_fidget.Update(x2ec_lastFireButtonStates, camBobT > 0.01f, inStrikeCooldown, dt, mgr)) { + switch (x3a4_fidget.Update(x2ec_lastFireButtonStates, camBobT > 0.01f, inStrikeCooldown, dt, + mgr)) { case CFidget::kS_NoFidget: if (x324_idleState != kIS_Idle) { x73c_gunMotion->PlayPasAnim(SamusGun::kAS_Idle, mgr, 0.f, false); @@ -891,7 +896,8 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C x834_26_animPlaying = x834_25_gunMotionFidgeting ? x73c_gunMotion->IsAnimPlaying() - : x72c_currentBeam->GetSolidModelData().GetAnimationData()->IsAnimTimeRemaining(0.001f, rstl::string_l("Whole Body")); + : x72c_currentBeam->GetSolidModelData().GetAnimationData()->IsAnimTimeRemaining( + 0.001f, rstl::string_l("Whole Body")); if (!x834_26_animPlaying) { x3a4_fidget.ResetMinor(); ReturnToRestPose(); @@ -906,7 +912,6 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C } } - void CPlayerGun::CMotionState::Update(bool, float, CTransform4f&, CStateManager&) {} void CPlayerGun::DamageRumble(const CVector3f&, const CStateManager&) {} @@ -959,9 +964,7 @@ void CPlayerGun::AsyncLoadFidget(CStateManager&) {} void CPlayerGun::UnLoadFidget() {} -bool CPlayerGun::IsFidgetLoaded() { - return false; -} +bool CPlayerGun::IsFidgetLoaded() { return false; } void CPlayerGun::SetFidgetAnimBits(int, bool) {} diff --git a/src/MetroidPrime/ScriptObjects/CFire.cpp b/src/MetroidPrime/ScriptObjects/CFire.cpp index 1a0a574f..87f51a49 100644 --- a/src/MetroidPrime/ScriptObjects/CFire.cpp +++ b/src/MetroidPrime/ScriptObjects/CFire.cpp @@ -1,9 +1,7 @@ #include "MetroidPrime/ScriptObjects/CFire.hpp" #include "MetroidPrime/CActorParameters.hpp" -static inline CMaterialList MakeMaterialList() { - return CMaterialList(kMT_Projectile); -} +static inline CMaterialList MakeMaterialList() { return CMaterialList(kMT_Projectile); } CFire::CFire(TToken< CGenDescription > effect, TUniqueId uid, TAreaId area, bool active, TUniqueId owner, const CTransform4f& xf, const CDamageInfo& dInfo, const CAABox& aabox, @@ -33,7 +31,4 @@ CFire::CFire(TToken< CGenDescription > effect, TUniqueId uid, TAreaId area, bool xe8_->SetTranslation(xf.GetTranslation()); } - -CFire::~CFire() { - -} +CFire::~CFire() {} diff --git a/src/MetroidPrime/Weapons/GunController/CGSFreeLook.cpp b/src/MetroidPrime/Weapons/GunController/CGSFreeLook.cpp index 5e4bb045..02b3464e 100644 --- a/src/MetroidPrime/Weapons/GunController/CGSFreeLook.cpp +++ b/src/MetroidPrime/Weapons/GunController/CGSFreeLook.cpp @@ -40,7 +40,7 @@ int CGSFreeLook::SetAnim(CAnimData& data, int gunId, int setId, int loopState, C if (!x14_idle) useLoopState = loopState; x14_idle = false; - + const CPASDatabase& pas = data.GetCharacterInfo().GetPASDatabase(); rstl::pair< float, int > anim = pas.FindBestAnimation( CPASAnimParmData(pas::kAS_Step, CPASAnimParm::FromInt32(gunId), diff --git a/src/MetroidPrime/Weapons/GunController/CGunController.cpp b/src/MetroidPrime/Weapons/GunController/CGunController.cpp index 04e6c302..44044f85 100644 --- a/src/MetroidPrime/Weapons/GunController/CGunController.cpp +++ b/src/MetroidPrime/Weapons/GunController/CGunController.cpp @@ -17,9 +17,7 @@ void CGunController::EnterStruck(CStateManager&, float) {} void CGunController::LoadFidgetAnimAsync(CStateManager&, int, int, int) {} -int CGunController::Update(float, CStateManager&) { - return 0; -} +int CGunController::Update(float, CStateManager&) { return 0; } void CGunController::EnterIdle(CStateManager&) {} diff --git a/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp b/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp index f270661b..e8d58c25 100644 --- a/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp +++ b/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp @@ -80,9 +80,7 @@ void CGunMotion::ReturnToDefault(CStateManager& mgr) { x4c_gunController.ReturnToDefault(mgr, 0.f); } -int CGunMotion::GetFreeLookSetId() const { - return x4c_gunController.GetFreeLookSetId(); -} +int CGunMotion::GetFreeLookSetId() const { return x4c_gunController.GetFreeLookSetId(); } void CGunMotion::BasePosition(bool bigStrikeReset) { CAnimData& animData = *x0_modelData.AnimationData(); diff --git a/src/Runtime/NMWException.h b/src/Runtime/NMWException.h index c8291d21..3dae2e22 100644 --- a/src/Runtime/NMWException.h +++ b/src/Runtime/NMWException.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _NMWEXCEPTION +#define _NMWEXCEPTION #ifdef __cplusplus extern "C" { @@ -18,3 +19,5 @@ void __destroy_global_chain(void); #ifdef __cplusplus } #endif + +#endif // _NMWEXCEPTION diff --git a/src/Runtime/__mem.c b/src/Runtime/__mem.c index aa647a78..a5ef6c12 100644 --- a/src/Runtime/__mem.c +++ b/src/Runtime/__mem.c @@ -1,6 +1,5 @@ #include "string.h" - void* memcpy(void* dst, const void* src, size_t n) { const char* p; char* q; @@ -18,7 +17,6 @@ void* memcpy(void* dst, const void* src, size_t n) { return (dst); } - #define cps ((unsigned char*)src) #define cpd ((unsigned char*)dst) #define lps ((unsigned long*)src) diff --git a/src/Runtime/e_exp.c b/src/Runtime/e_exp.c index 96b6c41d..9a52d138 100644 --- a/src/Runtime/e_exp.c +++ b/src/Runtime/e_exp.c @@ -4,7 +4,7 @@ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. * * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice + * software is freely granted, provided that this notice * is preserved. * ==================================================== */ @@ -16,36 +16,36 @@ * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. * Given x, find r and integer k such that * - * x = k*ln2 + r, |r| <= 0.5*ln2. + * x = k*ln2 + r, |r| <= 0.5*ln2. * - * Here r will be represented as r = hi-lo for better + * Here r will be represented as r = hi-lo for better * accuracy. * * 2. Approximation of ieee_exp(r) by a special rational function on * the interval [0,0.34658]: * Write * R(r**2) = r*(ieee_exp(r)+1)/(ieee_exp(r)-1) = 2 + r*r/6 - r**4/360 + ... - * We use a special Remes algorithm on [0,0.34658] to generate - * a polynomial of degree 5 to approximate R. The maximum error + * We use a special Remes algorithm on [0,0.34658] to generate + * a polynomial of degree 5 to approximate R. The maximum error * of this polynomial approximation is bounded by 2**-59. In * other words, * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5 * (where z=r*r, and the values of P1 to P5 are listed below) * and * | 5 | -59 - * | 2.0+P1*z+...+P5*z - R(z) | <= 2 + * | 2.0+P1*z+...+P5*z - R(z) | <= 2 * | | * The computation of ieee_exp(r) thus becomes * 2*r * exp(r) = 1 + ------- * R - r - * r*R1(r) + * r*R1(r) * = 1 + r + ----------- (for better accuracy) * 2 - R1(r) * where * 2 4 10 * R1(r) = r - (P1*r + P2*r + ... + P5*r ). - * + * * 3. Scale back to obtain ieee_exp(x): * From step 1, we have * ieee_exp(x) = 2^k * ieee_exp(r) @@ -60,13 +60,13 @@ * 1 ulp (unit in the last place). * * Misc. info. - * For IEEE double + * For IEEE double * if x > 7.09782712893383973096e+02 then ieee_exp(x) overflow * if x < -7.45133219101941108420e+02 then ieee_exp(x) underflow * * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the * compiler will convert from decimal to binary accurately enough * to produce the hexadecimal values shown. */ @@ -76,71 +76,87 @@ static const double #else static double #endif -one = 1.0, -halF[2] = {0.5,-0.5,}, -huge = 1.0e+300, -twom1000= 9.33263618503218878990e-302, /* 2**-1000=0x01700000,0*/ -o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ -u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */ -ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ - -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */ -ln2LO[2] ={ 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ - -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */ -invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ -P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ -P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ -P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ -P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ -P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ + one = 1.0, + halF[2] = + { + 0.5, + -0.5, +}, + huge = 1.0e+300, twom1000 = 9.33263618503218878990e-302, /* 2**-1000=0x01700000,0*/ + o_threshold = 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ + u_threshold = -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */ + ln2HI[2] = + { + 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ + -6.93147180369123816490e-01, +}, /* 0xbfe62e42, 0xfee00000 */ + ln2LO[2] = + { + 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ + -1.90821492927058770002e-10, +}, /* 0xbdea39ef, 0x35793c76 */ + invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ + P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ + P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ + P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ + P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ + P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ #ifdef __STDC__ - double __ieee754_exp(double x) /* default IEEE double exp */ +double __ieee754_exp(double x) /* default IEEE double exp */ #else - double __ieee754_exp(x) /* default IEEE double exp */ - double x; +double __ieee754_exp(x) /* default IEEE double exp */ +double x; #endif { - double y,hi,lo,c,t; - int k,xsb; - unsigned hx; - hx = __HI(x); /* high word of x */ - xsb = (hx>>31)&1; /* sign bit of x */ - hx &= 0x7fffffff; /* high word of |x| */ - /* filter out non-finite argument */ - if(hx >= 0x40862E42) { /* if |x|>=709.78... */ - if(hx>=0x7ff00000) { - if(((hx&0xfffff)|__LO(x))!=0) - return x+x; /* NaN */ - else return (xsb==0)? x:0.0; /* ieee_exp(+-inf)={inf,0} */ - } - if(x > o_threshold) return huge*huge; /* overflow */ - if(x < u_threshold) return twom1000*twom1000; /* underflow */ - } - /* argument reduction */ - if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ - if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ - hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb; - } else { - k = (int)(invln2*x+halF[xsb]); - t = k; - hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ - lo = t*ln2LO[0]; - } - x = hi - lo; - } - else if(hx < 0x3e300000) { /* when |x|<2**-28 */ - if(huge+x>one) return one+x;/* trigger inexact */ - } - else k = 0; - /* x is now in primary range */ - t = x*x; - c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); - if(k==0) return one-((x*c)/(c-2.0)-x); - else y = one-((lo-(x*c)/(2.0-c))-hi); - if(k >= -1021) { - __HI(y) += (k<<20); /* add k to y's exponent */ - return y; - } else { - __HI(y) += ((k+1000)<<20);/* add k to y's exponent */ - return y*twom1000; - } + double y, hi, lo, c, t; + int k, xsb; + unsigned hx; + hx = __HI(x); /* high word of x */ + xsb = (hx >> 31) & 1; /* sign bit of x */ + hx &= 0x7fffffff; /* high word of |x| */ + /* filter out non-finite argument */ + if (hx >= 0x40862E42) { /* if |x|>=709.78... */ + if (hx >= 0x7ff00000) { + if (((hx & 0xfffff) | __LO(x)) != 0) + return x + x; /* NaN */ + else + return (xsb == 0) ? x : 0.0; /* ieee_exp(+-inf)={inf,0} */ + } + if (x > o_threshold) + return huge * huge; /* overflow */ + if (x < u_threshold) + return twom1000 * twom1000; /* underflow */ + } + /* argument reduction */ + if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ + if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ + hi = x - ln2HI[xsb]; + lo = ln2LO[xsb]; + k = 1 - xsb - xsb; + } else { + k = (int)(invln2 * x + halF[xsb]); + t = k; + hi = x - t * ln2HI[0]; /* t*ln2HI is exact here */ + lo = t * ln2LO[0]; + } + x = hi - lo; + } else if (hx < 0x3e300000) { /* when |x|<2**-28 */ + if (huge + x > one) + return one + x; /* trigger inexact */ + } else + k = 0; + /* x is now in primary range */ + t = x * x; + c = x - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5)))); + if (k == 0) + return one - ((x * c) / (c - 2.0) - x); + else + y = one - ((lo - (x * c) / (2.0 - c)) - hi); + if (k >= -1021) { + __HI(y) += (k << 20); /* add k to y's exponent */ + return y; + } else { + __HI(y) += ((k + 1000) << 20); /* add k to y's exponent */ + return y * twom1000; + } } diff --git a/src/musyx/snd_math.c b/src/musyx/snd_math.c index bbdf022c..f31c94d3 100644 --- a/src/musyx/snd_math.c +++ b/src/musyx/snd_math.c @@ -21,6 +21,4 @@ void salCrossProduct(SND_FVECTOR* out, const SND_FVECTOR* a, const SND_FVECTOR* out->z = (a->x * b->y) - (a->y * b->x); } -void salInvertMatrix(SND_FMATRIX* out, const SND_FMATRIX* in) { - out->t[0] = 1.f; -} +void salInvertMatrix(SND_FMATRIX* out, const SND_FMATRIX* in) { out->t[0] = 1.f; }