From 585e2614957930212251532506142711ff2b3edf Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sat, 18 Apr 2026 14:40:54 -0400 Subject: [PATCH 1/3] `EGG::CoreController::beginFrame` OK --- include/egg/math/eggVector.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/egg/math/eggVector.h b/include/egg/math/eggVector.h index 0d5fc1e6..d152e83b 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) { From c717bee43372fa859c00092e7c4543bc439dfcd7 Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sat, 18 Apr 2026 14:45:44 -0400 Subject: [PATCH 2/3] Standardize unused args in C --- src/revolution/NWC24/NWC24Ipc.c | 19 ++++++++++++------- src/revolution/NWC24/NWC24Schedule.c | 5 ++++- src/revolution/NWC24/NWC24Time.c | 4 +++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/revolution/NWC24/NWC24Ipc.c b/src/revolution/NWC24/NWC24Ipc.c index ac969093..68c123b0 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 ffdad5c6..b759b7f0 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 4d002dd2..d4d887c6 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; } From 568ed6839ce9b404517465bb70b11f0fbd7ffadc Mon Sep 17 00:00:00 2001 From: kiwi515 <49212064+kiwi515@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:28:47 -0400 Subject: [PATCH 3/3] work --- config/RSPE01_01/splits.txt | 11 +++++++---- config/RSPE01_01/symbols.txt | 4 ++-- configure.py | 4 ++++ include/egg/geom.h | 6 ++++++ include/egg/geom/eggPlane.h | 26 ++++++++++++++++++++++++++ include/nw4r/ef/ef_res_animcurve.h | 15 +++++++++++++++ include/nw4r/ef/ef_res_emitter.h | 3 +++ src/egg/geom/eggPlane.cpp | 18 ++++++++++++++++++ src/nw4r/ef/ef_res_animcurve_ac.cpp | 17 +++++++++++++++++ src/nw4r/ef/ef_res_emitter_ac.cpp | 11 +++++++++++ 10 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 include/egg/geom.h create mode 100644 include/egg/geom/eggPlane.h create mode 100644 src/egg/geom/eggPlane.cpp create mode 100644 src/nw4r/ef/ef_res_animcurve_ac.cpp create mode 100644 src/nw4r/ef/ef_res_emitter_ac.cpp diff --git a/config/RSPE01_01/splits.txt b/config/RSPE01_01/splits.txt index 89220a83..cf8095dc 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 bf74f555..6a6f969a 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 6a07ed11..25ef57e8 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 00000000..1889fc35 --- /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 00000000..2eb01f33 --- /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/nw4r/ef/ef_res_animcurve.h b/include/nw4r/ef/ef_res_animcurve.h index 8332a0c2..f2ccb3b7 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 86d8764f..53d3d1ab 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 00000000..36b9f815 --- /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 00000000..8a4255b7 --- /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 00000000..7c370720 --- /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