Move Math -> PSPMath

This commit is contained in:
wally4000 2025-03-15 20:24:05 +11:00
parent bef1427395
commit bd3b69ff8e
17 changed files with 40 additions and 52 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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 <pspfpu.h>
#include "SysPSP/Math/Math.h" // VFPU Math
#define SIM_DOUBLES
#else

View file

@ -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 <glm/ext.hpp>
#include <vector>
#include <random>
#ifdef DAEDALUS_PSP
#include "SysPSP/Math/Math.h"
#endif
#include <random>
#ifdef DAEDALUS_CTR
struct ScePspFMatrix4
{

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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)

View file

@ -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"

View file

@ -1,5 +1,11 @@
#define TEST_DISABLE_GU_FUNCS DAEDALUS_PROFILE(__FUNCTION__);
#ifdef DAEDALUS_PSP
#include "SysPSP/Math/Math.h"
#endif
#include <cmath>
#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);

View file

@ -49,7 +49,6 @@
#include <vector>
#include <algorithm>
#include "Math/Math.h" // VFPU Math
#include "Utility/MathUtil.h"
#include <pspctrl.h>

View file

@ -4,8 +4,6 @@
#include <math.h>
#include <utility>
//ToDo: Use M_PI for x86 platform?
#define PI 3.141592653589793f
#ifdef DAEDALUS_PSP
#include <pspfpu.h>
@ -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

View file

@ -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"

View file

@ -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 <cmath>
#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<f32>(mTimeCounter) / static_cast<f32>(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 );

View file

@ -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 <cmath>
#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;

View file

@ -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 <algorithm>