diff --git a/config/RSPE01_01/splits.txt b/config/RSPE01_01/splits.txt index 89220a835..cf8095dcc 100644 --- a/config/RSPE01_01/splits.txt +++ b/config/RSPE01_01/splits.txt @@ -251,8 +251,11 @@ nw4r/ef/drawstrategy/ef_drawsmoothstripestrategy.cpp: .sbss start:0x804BEA58 end:0x804BEA60 .sdata2 start:0x804BFE68 end:0x804BFEA8 -nw4r/nw4r_8002F700.o: - .text start:0x8002F700 end:0x8002F75C +nw4r/ef/ef_res_emitter_ac.cpp: + .text start:0x8002F700 end:0x8002F730 + +nw4r/ef/ef_res_animcurve_ac.cpp: + .text start:0x8002F730 end:0x8002F75C nw4r/math/math_arithmetic.cpp: .text start:0x8002F75C end:0x8002F898 @@ -1189,7 +1192,7 @@ egg/gfx/eggDrawHelper.cpp: .bss start:0x8040AA50 end:0x8040AA60 .sbss start:0x804BEC88 end:0x804BEC90 -egg/gfx/egg_800A1DB0.o: +egg/gfx/eggProjection.cpp: .text start:0x800A1DB0 end:0x800A1DE4 egg/prim/eggAssert.cpp: @@ -1198,7 +1201,7 @@ egg/prim/eggAssert.cpp: .text start:0x800A1DE4 end:0x800A204C .rodata start:0x8037A1E0 end:0x8037A230 -egg/egg_800A204C.o: +egg/geom/eggPlane.cpp: extab start:0x80006508 end:0x80006510 extabindex start:0x80006C5C end:0x80006C68 .text start:0x800A204C end:0x800A2118 diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index bf74f555b..6a6f969a1 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -927,8 +927,8 @@ CalcAhead_Particle_Stripe__Q34nw4r2ef24DrawSmoothStripeStrategyFPQ34nw4r4math4VE CalcAhead_ParticleBoth_Stripe__Q34nw4r2ef24DrawSmoothStripeStrategyFPQ34nw4r4math4VEC3PQ44nw4r2ef24DrawSmoothStripeStrategy18AheadContextStripePQ34nw4r2ef8Particle = .text:0x8002EE64; // type:function size:0x2DC scope:global CalcAhead_ParticleBoth_Ring__Q34nw4r2ef24DrawSmoothStripeStrategyFPQ34nw4r4math4VEC3PQ44nw4r2ef24DrawSmoothStripeStrategy18AheadContextStripePQ34nw4r2ef8Particle = .text:0x8002F140; // type:function size:0x32C scope:global CalcAhead_ParticleBoth_Origin__Q34nw4r2ef24DrawSmoothStripeStrategyFPQ34nw4r4math4VEC3PQ44nw4r2ef24DrawSmoothStripeStrategy18AheadContextStripePQ34nw4r2ef8Particle = .text:0x8002F46C; // type:function size:0x294 scope:global -fn_8002F700 = .text:0x8002F700; // type:function size:0x30 -fn_8002F730 = .text:0x8002F730; // type:function size:0x2C +GetPtclTrack__Q34nw4r2ef10ResEmitterFUs = .text:0x8002F700; // type:function size:0x30 +SetStop__Q34nw4r2ef12ResAnimCurveFb = .text:0x8002F730; // type:function size:0x2C FExp__Q34nw4r4math6detailFf = .text:0x8002F75C; // type:function size:0x8C scope:global FLog__Q34nw4r4math6detailFf = .text:0x8002F7E8; // type:function size:0x8C scope:global FrSqrt__Q24nw4r4mathFf = .text:0x8002F874; // type:function size:0x24 scope:global diff --git a/configure.py b/configure.py index 6a07ed115..25ef57e83 100755 --- a/configure.py +++ b/configure.py @@ -497,6 +497,8 @@ def MatchingFor(*versions): Object(Matching, "nw4r/ef/drawstrategy/ef_drawpointstrategy.cpp"), Object(NonMatching, "nw4r/ef/drawstrategy/ef_drawstripestrategy.cpp"), Object(NonMatching, "nw4r/ef/drawstrategy/ef_drawsmoothstripestrategy.cpp"), + Object(Matching, "nw4r/ef/ef_res_emitter_ac.cpp"), + Object(Matching, "nw4r/ef/ef_res_animcurve_ac.cpp"), ] }, { @@ -731,7 +733,9 @@ def MatchingFor(*versions): Object(Matching, "egg/gfxe/eggGXUtility.cpp"), Object(Matching, "egg/gfxe/eggIDrawGX.cpp"), Object(NonMatching, "egg/gfx/eggDrawHelper.cpp"), + Object(NonMatching, "egg/gfx/eggProjection.cpp"), Object(Matching, "egg/prim/eggAssert.cpp", extra_cflags=["-Cpp_exceptions on"]), + Object(NonMatching, "egg/geom/eggPlane.cpp", extra_cflags=["-Cpp_exceptions on"]), Object(Matching, "egg/math/eggMath.cpp", extra_cflags=["-Cpp_exceptions on"]), Object(Matching, "egg/math/eggMatrix.cpp", extra_cflags=["-Cpp_exceptions on"]), Object(Matching, "egg/math/eggQuat.cpp", extra_cflags=["-Cpp_exceptions on"]), diff --git a/include/egg/geom.h b/include/egg/geom.h new file mode 100644 index 000000000..1889fc357 --- /dev/null +++ b/include/egg/geom.h @@ -0,0 +1,6 @@ +#ifndef EGG_PUBLIC_GEOM_H +#define EGG_PUBLIC_GEOM_H + +#include + +#endif diff --git a/include/egg/geom/eggPlane.h b/include/egg/geom/eggPlane.h new file mode 100644 index 000000000..2eb01f33e --- /dev/null +++ b/include/egg/geom/eggPlane.h @@ -0,0 +1,26 @@ +#ifndef EGG_GEOM_PLANE_H +#define EGG_GEOM_PLANE_H +#include + +#include + +namespace EGG { + +class Plane3f { +public: + Plane3f() {} + Plane3f(const Vector3f& rNormal) : normal(rNormal), depth(0.0f) {} + Plane3f(const Vector3f& rNormal, f32 depth) + : normal(rNormal), depth(depth) {} + ~Plane3f() {} + + Vector3f project(const Vector3f& rVec); + +private: + Vector3f normal; // at 0x0 + f32 depth; // at 0x10 +}; + +} // namespace EGG + +#endif diff --git a/include/egg/math/eggVector.h b/include/egg/math/eggVector.h index 0d5fc1e60..d152e83b0 100644 --- a/include/egg/math/eggVector.h +++ b/include/egg/math/eggVector.h @@ -155,10 +155,10 @@ class Vector3f : public nw4r::math::VEC3 { } f32& operator()(int i) { - return reinterpret_cast(&x)[i]; + return (&x)[i]; } const f32 operator()(int i) const { - return reinterpret_cast(&x)[i]; + return (&x)[i]; } void set(f32 fx, f32 fy, f32 fz) { diff --git a/include/nw4r/ef/ef_res_animcurve.h b/include/nw4r/ef/ef_res_animcurve.h index 8332a0c29..f2ccb3b79 100644 --- a/include/nw4r/ef/ef_res_animcurve.h +++ b/include/nw4r/ef/ef_res_animcurve.h @@ -147,6 +147,21 @@ struct AnimCurveNameTable { class ResAnimCurve { private: u8* mAnimCurveData; // at 0x0 + +public: + explicit ResAnimCurve(u8* pData = NULL) : mAnimCurveData(pData) {} + ResAnimCurve(const ResAnimCurve& rOther) + : mAnimCurveData(rOther.mAnimCurveData) {} + + bool IsValid() const { + return mAnimCurveData != NULL; + } + + AnimCurveHeader* ptr() { + return reinterpret_cast(mAnimCurveData); + } + + void SetStop(bool stop); }; } // namespace ef diff --git a/include/nw4r/ef/ef_res_emitter.h b/include/nw4r/ef/ef_res_emitter.h index 86d8764f9..53d3d1ab8 100644 --- a/include/nw4r/ef/ef_res_emitter.h +++ b/include/nw4r/ef/ef_res_emitter.h @@ -2,6 +2,7 @@ #define NW4R_EF_RES_EMITTER_H #include +#include #include #include #include @@ -397,6 +398,8 @@ class ResEmitter { EmitterResource* ptr() { return mData; } + + ResAnimCurve GetPtclTrack(u16 idx); }; } // namespace ef diff --git a/src/egg/geom/eggPlane.cpp b/src/egg/geom/eggPlane.cpp new file mode 100644 index 000000000..36b9f815e --- /dev/null +++ b/src/egg/geom/eggPlane.cpp @@ -0,0 +1,18 @@ +#include + +namespace EGG { + +DECOMP_FORCEACTIVE(eggPlane_cpp, Vector3f::multScalar); + +Vector3f Plane3f::project(const Vector3f& rVec) { + f32 s = normal.dot(rVec) - depth; + Vector3f work(rVec); + + // TODO(kiwi) how is multScalar being called? + Vector3f n(normal * s); + work -= n; + + return work; +} + +} // namespace EGG diff --git a/src/nw4r/ef/ef_res_animcurve_ac.cpp b/src/nw4r/ef/ef_res_animcurve_ac.cpp new file mode 100644 index 000000000..8a4255b74 --- /dev/null +++ b/src/nw4r/ef/ef_res_animcurve_ac.cpp @@ -0,0 +1,17 @@ +#include + +namespace nw4r { +namespace ef { + +void ResAnimCurve::SetStop(bool stop) { + AnimCurveHeader* pHeader = ptr(); + + if (stop) { + pHeader->processFlag |= AnimCurveHeader::PROC_FLAG_STOP; + } else { + pHeader->processFlag &= ~AnimCurveHeader::PROC_FLAG_STOP; + } +} + +} // namespace ef +} // namespace nw4r diff --git a/src/nw4r/ef/ef_res_emitter_ac.cpp b/src/nw4r/ef/ef_res_emitter_ac.cpp new file mode 100644 index 000000000..7c3707205 --- /dev/null +++ b/src/nw4r/ef/ef_res_emitter_ac.cpp @@ -0,0 +1,11 @@ +#include + +namespace nw4r { +namespace ef { + +ResAnimCurve ResEmitter::GetPtclTrack(u16 idx) { + return ResAnimCurve(ptr()->GetPtclTrack(idx)); +} + +} // namespace ef +} // namespace nw4r diff --git a/src/revolution/NWC24/NWC24Ipc.c b/src/revolution/NWC24/NWC24Ipc.c index ac9690936..68c123b01 100644 --- a/src/revolution/NWC24/NWC24Ipc.c +++ b/src/revolution/NWC24/NWC24Ipc.c @@ -6,8 +6,10 @@ static BOOL NWC24iIsRequestPending = FALSE; // Forward declarations static s32 CallbackAsyncIpc(s32 result, void* pArg); -NWC24Err NWC24iOpenResourceManager(const char* /* pUser */, const char* pName, +NWC24Err NWC24iOpenResourceManager(const char* pUser, const char* pName, s32* pFd, IPCOpenMode mode) { +#pragma unused(pUser) + s32 result; if (pFd == NULL) { @@ -32,23 +34,26 @@ NWC24Err NWC24iOpenResourceManager(const char* /* pUser */, const char* pName, return NWC24_OK; } -NWC24Err NWC24iCloseResourceManager(const char* /* pUser */, s32 fd) { +NWC24Err NWC24iCloseResourceManager(const char* pUser, s32 fd) { +#pragma unused(pUser) + return IOS_Close(fd) < 0 ? NWC24_ERR_INTERNAL_IPC : NWC24_OK; } -NWC24Err NWC24iIoctlResourceManager(const char* /* pUser */, s32 fd, s32 type, +NWC24Err NWC24iIoctlResourceManager(const char* pUser, s32 fd, s32 type, void* pIn, s32 inSize, void* pOut, s32 outSize) { +#pragma unused(pUser) return IOS_Ioctl(fd, type, pIn, inSize, pOut, outSize) < 0 ? NWC24_ERR_INTERNAL_IPC : NWC24_OK; } -NWC24Err NWC24iIoctlResourceManagerAsync(const char* /* pUser */, s32 fd, - s32 type, void* pIn, s32 inSize, - void* pOut, s32 outSize, - void* pCallbackArg) { +NWC24Err NWC24iIoctlResourceManagerAsync(const char* pUser, s32 fd, s32 type, + void* pIn, s32 inSize, void* pOut, + s32 outSize, void* pCallbackArg) { +#pragma unused(pUser) if (IOS_IoctlAsync(fd, type, pIn, inSize, pOut, outSize, CallbackAsyncIpc, pCallbackArg) < 0) { diff --git a/src/revolution/NWC24/NWC24Schedule.c b/src/revolution/NWC24/NWC24Schedule.c index ffdad5c60..b759b7f06 100644 --- a/src/revolution/NWC24/NWC24Schedule.c +++ b/src/revolution/NWC24/NWC24Schedule.c @@ -337,7 +337,10 @@ static void UnlockCounters(void) { OSUnlockMutex(&nwc24ScdCounterMutex); } -static NWC24Err CheckCallingStatus(const char* /* pUser */, BOOL /* block */) { +static NWC24Err CheckCallingStatus(const char* pUser, BOOL block) { +#pragma unused(pUser) +#pragma unused(block) + if (OSGetCurrentThread() == NULL) { return NWC24_ERR_FATAL; } diff --git a/src/revolution/NWC24/NWC24Time.c b/src/revolution/NWC24/NWC24Time.c index 4d002dd2f..d4d887c6e 100644 --- a/src/revolution/NWC24/NWC24Time.c +++ b/src/revolution/NWC24/NWC24Time.c @@ -183,7 +183,9 @@ static NWC24Err GetRTC(u32* pRTC) { return NWC24_OK; } -static NWC24Err CheckCallingStatus(const char* /* pUser */) { +static NWC24Err CheckCallingStatus(const char* pUser) { +#pragma unused(pUser) + if (OSGetCurrentThread() == NULL) { return NWC24_ERR_FATAL; }