From bd3b69ff8e2f1cbaffa9ed65ba37ff230b90d6af Mon Sep 17 00:00:00 2001 From: wally4000 Date: Sat, 15 Mar 2025 20:24:05 +1100 Subject: [PATCH] Move Math -> PSPMath --- Options.cmake | 6 ------ Source/CMakeLists.txt | 1 - Source/Core/R4300.cpp | 3 ++- Source/HLEGraphics/BaseRenderer.cpp | 8 ++++++-- Source/HLEGraphics/CachedTexture.cpp | 2 +- Source/HLEGraphics/Microcode.cpp | 2 +- Source/Input/CTR/InputManagerCTR.cpp | 2 +- Source/Input/PSP/InputManagerPSP.cpp | 2 +- Source/Math/CMakeLists.txt | 8 -------- Source/OSHLE/patch.cpp | 2 +- Source/OSHLE/patch_gu_hle.inl | 16 ++++++++++++++- .../HLEGraphics/DisplayListDebugger.cpp | 1 - Source/{ => SysPSP}/Math/Math.h | 20 ------------------- Source/UI/AdjustDeadzoneScreen.cpp | 2 +- Source/UI/ColourPulser.cpp | 10 +++++++--- Source/UI/SplashScreen.cpp | 6 ++++-- Source/Utility/MathUtil.h | 1 - 17 files changed, 40 insertions(+), 52 deletions(-) delete mode 100644 Source/Math/CMakeLists.txt rename Source/{ => SysPSP}/Math/Math.h (86%) diff --git a/Options.cmake b/Options.cmake index e938f9dc..e6ba96fa 100644 --- a/Options.cmake +++ b/Options.cmake @@ -246,12 +246,6 @@ if(DAEDALUS_PROFILE_INTERFACE) option(DAEDALUS_GPROF "" ON) endif() -if(DAEDALUS_PROFILE_MATH) - message("DAEDALUS_PROFILE_MATH=ON") - add_compile_definitions(DAEDALUS_PROFILE_MATH) - option(DAEDALUS_GPROF "" ON) -endif() - if(DAEDALUS_PROFILE_OSHLE) message("DAEDALUS_PROFILE_OSHLE=ON") add_compile_definitions(DAEDALUS_PROFILE_OSHLE) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6320cee2..5ccfc986 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -168,7 +168,6 @@ else() option(DAEDALUS_PROFILE_HLEGRAPHICS "" OFF) option(DAEDALUS_PROFILE_INPUT "" OFF) option(DAEDALUS_PROFILE_INTERFACE "" OFF) - option(DAEDALUS_PROFILE_MATH "" OFF) option(DAEDALUS_PROFILE_OSHLE "" OFF) option(DAEDALUS_PROFILE_ROMFILE "" OFF) option(DAEDALUS_PROFILE_SYSTEM "" OFF) diff --git a/Source/Core/R4300.cpp b/Source/Core/R4300.cpp index 912d5821..d8ea348a 100644 --- a/Source/Core/R4300.cpp +++ b/Source/Core/R4300.cpp @@ -33,11 +33,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "DynaRec/TraceRecorder.h" -#include "Math/Math.h" // VFPU Math + #include "Ultra/ultra_R4300.h" #ifdef DAEDALUS_PSP #include +#include "SysPSP/Math/Math.h" // VFPU Math #define SIM_DOUBLES #else diff --git a/Source/HLEGraphics/BaseRenderer.cpp b/Source/HLEGraphics/BaseRenderer.cpp index df48ea1a..aa588190 100644 --- a/Source/HLEGraphics/BaseRenderer.cpp +++ b/Source/HLEGraphics/BaseRenderer.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEGraphics/TextureCache.h" #include "HLEGraphics/RDPStateManager.h" #include "HLEGraphics/DLDebug.h" -#include "Math/Math.h" // VFPU Math + #include "Utility/MathUtil.h" #include "Ultra/ultra_gbi.h" #include "Ultra/ultra_os.h" // System type @@ -40,8 +40,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +#include + +#ifdef DAEDALUS_PSP +#include "SysPSP/Math/Math.h" +#endif -#include #ifdef DAEDALUS_CTR struct ScePspFMatrix4 { diff --git a/Source/HLEGraphics/CachedTexture.cpp b/Source/HLEGraphics/CachedTexture.cpp index 1195bf86..c40ca5a8 100644 --- a/Source/HLEGraphics/CachedTexture.cpp +++ b/Source/HLEGraphics/CachedTexture.cpp @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/NativeTexture.h" #include "Graphics/PngUtil.h" #include "Graphics/TextureTransform.h" -#include "Math/Math.h" + #include "Utility/MathUtil.h" #include "Ultra/ultra_gbi.h" diff --git a/Source/HLEGraphics/Microcode.cpp b/Source/HLEGraphics/Microcode.cpp index aee1b623..387be9f1 100644 --- a/Source/HLEGraphics/Microcode.cpp +++ b/Source/HLEGraphics/Microcode.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/ROM.h" #include "Core/Memory.h" -#include "Math/Math.h" + #include "Debug/DBGConsole.h" #include "Ultra/ultra_gbi.h" diff --git a/Source/Input/CTR/InputManagerCTR.cpp b/Source/Input/CTR/InputManagerCTR.cpp index 3dc556a7..78970d61 100644 --- a/Source/Input/CTR/InputManagerCTR.cpp +++ b/Source/Input/CTR/InputManagerCTR.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" -#include "Math/Math.h" + #include "Utility/MathUtil.h" #include "Utility/IniFile.h" diff --git a/Source/Input/PSP/InputManagerPSP.cpp b/Source/Input/PSP/InputManagerPSP.cpp index e2c71bbf..06d4b62e 100644 --- a/Source/Input/PSP/InputManagerPSP.cpp +++ b/Source/Input/PSP/InputManagerPSP.cpp @@ -12,7 +12,7 @@ #include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Input/InputManager.h" -#include "Math/Math.h" // VFPU Math + #include "Utility/MathUtil.h" #include "Utility/IniFile.h" diff --git a/Source/Math/CMakeLists.txt b/Source/Math/CMakeLists.txt deleted file mode 100644 index 8cab632d..00000000 --- a/Source/Math/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -add_library(Math OBJECT Matrix4x4.cpp) - -if(DAEDALUS_PROFILE_MATH) -target_compile_options(Math PRIVATE -pg) -endif(DAEDALUS_PROFILE_MATH) - -list(APPEND daed_libs "Math") -set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/OSHLE/patch.cpp b/Source/OSHLE/patch.cpp index 6a376287..621ced55 100644 --- a/Source/OSHLE/patch.cpp +++ b/Source/OSHLE/patch.cpp @@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/Dump.h" #include "DynaRec/Fragment.h" #include "DynaRec/FragmentCache.h" -#include "Math/Math.h" // VFPU Math + #include "OSHLE/OS.h" #include "OSHLE/OSMesgQueue.h" #include "OSHLE/patch.h" diff --git a/Source/OSHLE/patch_gu_hle.inl b/Source/OSHLE/patch_gu_hle.inl index 58b87e5a..54655a06 100644 --- a/Source/OSHLE/patch_gu_hle.inl +++ b/Source/OSHLE/patch_gu_hle.inl @@ -1,5 +1,11 @@ #define TEST_DISABLE_GU_FUNCS DAEDALUS_PROFILE(__FUNCTION__); +#ifdef DAEDALUS_PSP +#include "SysPSP/Math/Math.h" +#endif + +#include + #ifndef DAEDALUS_PSP_USE_VFPU //Fixed point matrix static const u32 s_IdentMatrixL[16] = @@ -120,6 +126,14 @@ inline void vfpu_matrix_Ortho(u8 *m, float left, float right, float bottom, floa } #endif +#ifndef DAEDALUS_PSP +inline void sincosf(float x, float * s, float * c) +{ + *s = sinf(x); + *c = cosf(x); +} +#endif + u32 Patch_guMtxIdentF() { TEST_DISABLE_GU_FUNCS @@ -619,7 +633,7 @@ TEST_DISABLE_GU_FUNCS y._u32 = gGPR[REG_a3]._u32_0; //Y z._u32 = QuickRead32Bits(pStackBase, 0x10); //Z - sincosf(a._f32*(PI/180.0f), &s, &c); + sincosf(a._f32*(M_PI/180.0f), &s, &c); //According to the manual the vector should be normalized in this function (Seems to work fine without it but risky) // vfpu_norm_3Dvec(&x._f32, &y._f32, &z._f32); diff --git a/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp b/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp index 9b70ab60..83c8d23d 100644 --- a/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp +++ b/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp @@ -49,7 +49,6 @@ #include #include -#include "Math/Math.h" // VFPU Math #include "Utility/MathUtil.h" #include diff --git a/Source/Math/Math.h b/Source/SysPSP/Math/Math.h similarity index 86% rename from Source/Math/Math.h rename to Source/SysPSP/Math/Math.h index 56b9652e..11d1096f 100644 --- a/Source/Math/Math.h +++ b/Source/SysPSP/Math/Math.h @@ -4,8 +4,6 @@ #include #include -//ToDo: Use M_PI for x86 platform? -#define PI 3.141592653589793f #ifdef DAEDALUS_PSP #include @@ -146,24 +144,6 @@ Check above notes for cycles/comparison // #define sinf(x) std::sinf((x)) // #define cosf(x) std::cosf((x)) // #define sincosf(x,s,c) std::sincosf(x, s, c) -#else - - -inline void sincosf(float x, float * s, float * c) -{ - *s = sinf(x); - *c = cosf(x); -} - -inline float InvSqrt(float x) -{ - float xhalf = 0.5f * x; - int i = *(int*)&x; // store floating-point bits in integer - i = 0x5f3759df - (i >> 1); // initial guess for Newton's method - x = *(float*)&i; // convert new bits into float - x = x*(1.5f - xhalf*x*x); // One round of Newton's method - return x; -} #endif // DAEDALUS_PSP diff --git a/Source/UI/AdjustDeadzoneScreen.cpp b/Source/UI/AdjustDeadzoneScreen.cpp index f5e1eefa..cf596d89 100644 --- a/Source/UI/AdjustDeadzoneScreen.cpp +++ b/Source/UI/AdjustDeadzoneScreen.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UIScreen.h" #include "Input/InputManager.h" -#include "Math/Math.h" // VFPU Math + #include "Utility/MathUtil.h" #include "DrawTextUtilities.h" #include "Interface/Preferences.h" diff --git a/Source/UI/ColourPulser.cpp b/Source/UI/ColourPulser.cpp index 526a18d4..80e4c943 100644 --- a/Source/UI/ColourPulser.cpp +++ b/Source/UI/ColourPulser.cpp @@ -21,9 +21,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "Graphics/ColourValue.h" -#include "Math/Math.h" // VFPU Math -#include "ColourPulser.h" +#include "ColourPulser.h" +#include + +#ifdef DAEDALUS_PSP +#include "SysPSP/Math/Math.h" +#endif CColourPulser::CColourPulser( c32 dim_colour, c32 bright_colour, u32 cycle_period ) : mTimeCounter( 0 ) @@ -41,7 +45,7 @@ void CColourPulser::Update( u32 elapsed_ms ) f32 cycle_fraction = static_cast(mTimeCounter) / static_cast(mCyclePeriod); - f32 sin_val = cosf( cycle_fraction * 2.0f * PI ); // In range -1..+1 + f32 sin_val = cosf( cycle_fraction * 2.0f * M_PI ); // In range -1..+1 f32 factor = ( sin_val + 1.0f ) / 2.0f; // In range 0..1 mCurrentColour = mDimColour.Interpolate( mBrightColour, factor ); diff --git a/Source/UI/SplashScreen.cpp b/Source/UI/SplashScreen.cpp index dbea8d3a..c2f26c3e 100644 --- a/Source/UI/SplashScreen.cpp +++ b/Source/UI/SplashScreen.cpp @@ -23,15 +23,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/ColourValue.h" #include "Graphics/GraphicsContext.h" #include "Graphics/NativeTexture.h" -#include "Math/Math.h" // VFPU Math + #include "DrawTextUtilities.h" #include "Menu.h" #include "SplashScreen.h" #include "UIContext.h" #include "UIScreen.h" +#include #include "Interface/Preferences.h" + extern bool g32bitColorMode; class ISplashScreen : public CSplashScreen, public CUIScreen @@ -93,7 +95,7 @@ void ISplashScreen::Update( float elapsed_time , const glm::vec2 & stick[[maybe_ void ISplashScreen::Render() { - f32 alpha = 255.0f * sinf( mElapsedTime * PI / MAX_TIME ); + f32 alpha = 255.0f * sinf( mElapsedTime * M_PI / MAX_TIME ); u8 a = 0; if( alpha >= 255.0f ) { a = 255; diff --git a/Source/Utility/MathUtil.h b/Source/Utility/MathUtil.h index ba0d80d8..21985756 100644 --- a/Source/Utility/MathUtil.h +++ b/Source/Utility/MathUtil.h @@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef MATH_MATHUTIL_H_ #define MATH_MATHUTIL_H_ -#include "Math/Math.h" #include