From 0f30e3b289731d8e665a064dcea8b787c77abda3 Mon Sep 17 00:00:00 2001 From: EpochFlame Date: Tue, 12 Sep 2023 23:14:19 -0400 Subject: [PATCH] resolve #50 left float and double in MSL headers/files where it makes sense to use them rather than typedefs --- docs/recommended_todo.md | 8 +++----- include/Dolphin/math.h | 16 ++++++++-------- include/PSM/Director.h | 2 +- include/PSM/Se.h | 14 +++++++------- .../MSL_C/MSL_Common/ansi_fp.h | 12 ++++++------ .../MSL_C/MSL_Common/math_api.h | 6 +++--- include/Sys/OBBTree.h | 2 +- include/sysMath.h | 2 +- src/Dolphin/MSL_C/PPC_EABI/math_ppc.c | 12 ++++++------ src/Dolphin/gx/GXBump.c | 2 +- src/Dolphin/mtx/mtx.c | 4 ++-- src/JSystem/JAudio/dsp/dspproc.c | 2 +- 12 files changed, 40 insertions(+), 42 deletions(-) diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md index f661a3e2d..e101ee91a 100644 --- a/docs/recommended_todo.md +++ b/docs/recommended_todo.md @@ -40,7 +40,7 @@ | JStudio/object-id.cpp | 2697 | JParticle/JPAChildShape.cpp | 3414 | | JGadget/binary.cpp | 3595 | JAudio/JAS/JASInstSense.cpp | 3632 | | JStudio_JAudio/control.cpp | 3648 | JAudio/JAS/JASCmdStack.cpp | 3709 | -| JAudio/dsp/dspproc.c | 3983 | JStudio_JParticle/control.cpp | 4098 | +| JAudio/dsp/dspproc.c | 3981 | JStudio_JParticle/control.cpp | 4098 | | J3DU/J3DUMtxCache.cpp | 4160 | JStudio_JStage/object.cpp | 4322 | | JAudio/JAS/JASSeqCtrl.cpp | 4524 | JParticle/JPAResourceManager.cpp | 4849 | | JGadget/linklist.cpp | 5250 | JAudio/JAU/JAUData.cpp | 5463 | @@ -183,9 +183,8 @@ | File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | | JSTObjectSpecialActor.cpp | 2289 | illustratedBookMessage.cpp | 2964 | -| captionMessage.cpp | 3528 | THPRead.c | 3743 | -| messageObj.cpp | 4504 | aramMgr.cpp | 4920 | -| gameflow.cpp | 5333 | THPVideoDecode.c | 6107 | +| captionMessage.cpp | 3528 | messageObj.cpp | 4504 | +| aramMgr.cpp | 4920 | gameflow.cpp | 5333 | | messageMgr.cpp | 6825 | section.cpp | 7072 | | moviePlayerPauseAndDraw.cpp | 8587 | screenScene.cpp | 9274 | | JSTObjectParticleActor.cpp | 11032 | loadResource.cpp | 11781 | @@ -193,7 +192,6 @@ | JSTObjectCamera.cpp | 12894 | P2DScreen.cpp | 12998 | | modelEffect.cpp | 13173 | JSTObjectGameActor.cpp | 16832 | | light.cpp | 17447 | wipe.cpp | 17624 | -| screenObj.cpp | 17806 | ###
utilityU
| File | Size (bytes) | File | Size (bytes) | diff --git a/include/Dolphin/math.h b/include/Dolphin/math.h index ab0ab6638..d26d0d28d 100644 --- a/include/Dolphin/math.h +++ b/include/Dolphin/math.h @@ -63,16 +63,16 @@ f64 ceil(f64); static inline f32 dolsqrtf(f32 x) { - static const double _half = .5; - static const double _three = 3.0; - volatile float y; + static const f64 _half = .5; + static const f64 _three = 3.0; + volatile f32 y; if (x > 0.0f) { - double guess = __frsqrte((double)x); // returns an approximation to - guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits - guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits - guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits - y = (float)(x * guess); + f64 guess = __frsqrte((f64)x); // returns an approximation to + guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits + guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits + guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits + y = (f32)(x * guess); return y; } return x; diff --git a/include/PSM/Director.h b/include/PSM/Director.h index c7dda6728..e0aa627c2 100644 --- a/include/PSM/Director.h +++ b/include/PSM/Director.h @@ -154,7 +154,7 @@ struct PikAttackDirector : public TrackOnDirectorBase { }; struct TrackOnDirector_Scaled : public TrackOnDirectorBase { - inline TrackOnDirector_Scaled(const char* name, int p2, float p3, float p4, long p5, long p6, unsigned long p7) + inline TrackOnDirector_Scaled(const char* name, int p2, f32 p3, f32 p4, s32 p5, s32 p6, u32 p7) : TrackOnDirectorBase(p2, name, p5, p6) , _54(p3) , _58(p4) diff --git a/include/PSM/Se.h b/include/PSM/Se.h index eb34c6cb2..592c267dd 100644 --- a/include/PSM/Se.h +++ b/include/PSM/Se.h @@ -59,7 +59,7 @@ struct PersEnvManager { }; struct EnvSeObjBuilder : public PSGame::Builder_EvnSe_Perspective { - EnvSeObjBuilder(JGeometry::TBox3); + EnvSeObjBuilder(JGeometry::TBox3); virtual ~EnvSeObjBuilder(); // _08 virtual void onBuild(PSSystem::EnvSeBase*); // _0C @@ -91,7 +91,7 @@ struct SeSound : public JAISe { static SeSound* makeSeSound(); void specializePerspCalc(const PSGame::SoundTable::SePerspInfo&); void calcVolumeSpecialized(f32); - f32 calcVolume(f32, unsigned char, unsigned char); + f32 calcVolume(f32, u8, u8); void calcPan(const Vec&, f32); void calcDolby(const Vec&, f32); @@ -101,11 +101,11 @@ struct SeSound : public JAISe { u8 _49C; // _49C f32 _4A0; // _4A0 - static float cDol_0Rad; - static float cDol_HalfRad; - static float cDol_FullRad; - static float cPan_MaxAmp; - static float cCenterRad; + static f32 cDol_0Rad; + static f32 cDol_HalfRad; + static f32 cDol_FullRad; + static f32 cPan_MaxAmp; + static f32 cCenterRad; }; } // namespace PSM diff --git a/include/PowerPC_EABI_Support/MSL_C/MSL_Common/ansi_fp.h b/include/PowerPC_EABI_Support/MSL_C/MSL_Common/ansi_fp.h index 95fc4409b..b7061cf4f 100644 --- a/include/PowerPC_EABI_Support/MSL_C/MSL_Common/ansi_fp.h +++ b/include/PowerPC_EABI_Support/MSL_C/MSL_Common/ansi_fp.h @@ -23,18 +23,18 @@ typedef struct decimal { typedef struct decform { char style; char unk1; - short digits; + s16 digits; } decform; void __ull2dec(decimal*, u64); void __timesdec(decimal*, const decimal*, const decimal*); -void __str2dec(decimal*, const char*, short); -void __two_exp(decimal*, long); +void __str2dec(decimal*, const char*, s16); +void __two_exp(decimal*, s32); BOOL __equals_dec(const decimal*, const decimal*); BOOL __less_dec(const decimal*, const decimal*); void __minus_dec(decimal*, const decimal*, const decimal*); -void __num2dec_internal(decimal*, double); -void __num2dec(const decform*, double, decimal*); -double __dec2num(const decimal*); +void __num2dec_internal(decimal*, f64); +void __num2dec(const decform*, f64, decimal*); +f64 __dec2num(const decimal*); #endif diff --git a/include/PowerPC_EABI_Support/MSL_C/MSL_Common/math_api.h b/include/PowerPC_EABI_Support/MSL_C/MSL_Common/math_api.h index 4d104e44a..2f0a43e22 100644 --- a/include/PowerPC_EABI_Support/MSL_C/MSL_Common/math_api.h +++ b/include/PowerPC_EABI_Support/MSL_C/MSL_Common/math_api.h @@ -8,9 +8,9 @@ extern "C" { #endif // ifdef __cplusplus -// int __fpclassifyf(float); -// int __signbitd(double); -// int __fpclassifyd(double); +// int __fpclassifyf(f32); +// int __signbitd(f64); +// int __fpclassifyd(f64); inline int __fpclassifyf(f32 x) { diff --git a/include/Sys/OBBTree.h b/include/Sys/OBBTree.h index e7e92b8b0..d05fd7b16 100644 --- a/include/Sys/OBBTree.h +++ b/include/Sys/OBBTree.h @@ -37,7 +37,7 @@ struct OBBTree : public TriDivider { void findRayIntersection(RayIntersectInfo&, Matrixf&, Matrixf&); void traceMove_new(Matrixf&, Matrixf&, Game::MoveInfo&, f32); void traceMove_new_global(Game::MoveInfo&, f32); - void traceMove_original(Matrixf&, Matrixf&, Game::MoveInfo&, float); + void traceMove_original(Matrixf&, Matrixf&, Game::MoveInfo&, f32); void draw(Graphics&); void write(Stream&); diff --git a/include/sysMath.h b/include/sysMath.h index 6fcdcbcc4..eca9ed232 100644 --- a/include/sysMath.h +++ b/include/sysMath.h @@ -34,7 +34,7 @@ inline f32 qdist3(f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2) return dist; } -inline f32 log(f32& a, double b) +inline f32 log(f32& a, f64 b) { f32 divisor = log10(b); f32 dividend = log10(a); diff --git a/src/Dolphin/MSL_C/PPC_EABI/math_ppc.c b/src/Dolphin/MSL_C/PPC_EABI/math_ppc.c index 0353dcba0..e8b5e43fc 100644 --- a/src/Dolphin/MSL_C/PPC_EABI/math_ppc.c +++ b/src/Dolphin/MSL_C/PPC_EABI/math_ppc.c @@ -26,7 +26,7 @@ void __fpclassifyd(void) * Address: ........ * Size: 000020 */ -double scalbn(double x, int y) +f64 scalbn(f64 x, int y) { // UNUSED FUNCTION } @@ -576,21 +576,21 @@ void atan2f(void) * Address: 800CFC98 * Size: 000024 */ -__declspec(weak) float cosf(float __x) { return cos((double)__x); } +__declspec(weak) f32 cosf(f32 __x) { return cos((f64)__x); } /* * --INFO-- * Address: 800CFC74 * Size: 000024 */ -__declspec(weak) float sinf(float __x) { return sin((double)__x); } +__declspec(weak) f32 sinf(f32 __x) { return sin((f64)__x); } /* * --INFO-- * Address: 800CFC50 * Size: 000024 */ -__declspec(weak) float tanf(float __x) { return tan((double)__x); } +__declspec(weak) f32 tanf(f32 __x) { return tan((f64)__x); } /* * --INFO-- @@ -757,7 +757,7 @@ void _inv_sqrtf(void) * Address: ........ * Size: 000008 */ -double fabs(double x) +f64 fabs(f64 x) { // UNUSED FUNCTION } @@ -767,7 +767,7 @@ double fabs(double x) * Address: ........ * Size: 000130 */ -void modff(float f1, float* fp) +void modff(f32 f1, f32* fp) { // UNUSED FUNCTION } diff --git a/src/Dolphin/gx/GXBump.c b/src/Dolphin/gx/GXBump.c index 050edfcec..3e320fbc7 100644 --- a/src/Dolphin/gx/GXBump.c +++ b/src/Dolphin/gx/GXBump.c @@ -39,7 +39,7 @@ void GXSetIndTexMtx(GXIndTexMtxID id, const Mtx23 mtx, s8 scale_exp) { u32 val; u32 field; - float mtx2[6]; + f32 mtx2[6]; // scale_exp range is -17..46 // we need it in range 0..63 diff --git a/src/Dolphin/mtx/mtx.c b/src/Dolphin/mtx/mtx.c index 504f3e84f..6d7b31132 100644 --- a/src/Dolphin/mtx/mtx.c +++ b/src/Dolphin/mtx/mtx.c @@ -870,7 +870,7 @@ void C_MTXLightFrustum(void) * Address: 800EAA84 * Size: 0000CC */ -void C_MTXLightPerspective(Mtx m, f32 fovY, f32 aspect, float scaleS, float scaleT, float transS, float transT) +void C_MTXLightPerspective(Mtx m, f32 fovY, f32 aspect, f32 scaleS, f32 scaleT, f32 transS, f32 transT) { f32 angle; f32 cot; @@ -901,7 +901,7 @@ void C_MTXLightPerspective(Mtx m, f32 fovY, f32 aspect, float scaleS, float scal * Address: 800EAB50 * Size: 000088 */ -void C_MTXLightOrtho(Mtx m, f32 t, f32 b, f32 l, f32 r, float scaleS, float scaleT, float transS, float transT) +void C_MTXLightOrtho(Mtx m, f32 t, f32 b, f32 l, f32 r, f32 scaleS, f32 scaleT, f32 transS, f32 transT) { f32 tmp; diff --git a/src/JSystem/JAudio/dsp/dspproc.c b/src/JSystem/JAudio/dsp/dspproc.c index 7d1ab0045..dacf1a443 100644 --- a/src/JSystem/JAudio/dsp/dspproc.c +++ b/src/JSystem/JAudio/dsp/dspproc.c @@ -171,7 +171,7 @@ void DsetupTable(u32 p1, u32 p2, u32 p3, u32 p4, u32 p5) * Address: 800AA860 * Size: 000024 */ -void DsetMixerLevel(float mixerLevel) { DSP_MIXERLEVEL = 4096.0f * mixerLevel; } +void DsetMixerLevel(f32 mixerLevel) { DSP_MIXERLEVEL = 4096.0f * mixerLevel; } /* * --INFO--