summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah-thomas774 <elijahthomas774@gmail.com>2025-03-22 20:47:19 -0400
committerelijah-thomas774 <elijahthomas774@gmail.com>2025-03-22 20:47:19 -0400
commitda9155aa5fdbabcf0d6dcf41fdf690b8b201fb78 (patch)
tree4151c7e66117c5c798df2684f30abc78c2d0cd61
parentf66c22cf63529120697765e05b796d401c16555f (diff)
parentfb8a02193562bf57d35c4c70d168c6ae226084a6 (diff)
Merge branch '🥚' of https://github.com/robojumper/ss into pr/142
-rw-r--r--config/SOUE01/splits.txt3
-rw-r--r--config/SOUE01/symbols.txt2
-rw-r--r--include/egg/gfx/eggLight.h38
-rw-r--r--include/egg/gfx/eggLightManager.h73
-rw-r--r--include/egg/gfx/eggLightObject.h12
-rw-r--r--include/m/m3d/m3d.h4
-rw-r--r--src/egg/gfx/eggLightManager.cpp75
-rw-r--r--src/egg/gfx/eggLightObject.cpp7
-rw-r--r--src/m/m3d/m3d.cpp3
-rw-r--r--src/toBeSorted/arc_callback_handler.cpp1
10 files changed, 170 insertions, 48 deletions
diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt
index a2cd5733..e0db061e 100644
--- a/config/SOUE01/splits.txt
+++ b/config/SOUE01/splits.txt
@@ -2256,6 +2256,9 @@ egg/gfx/eggIScnProc.cpp:
egg/gfx/eggLightManager.cpp:
.text start:0x804A7F80 end:0x804A9808
+ .data start:0x8056F068 end:0x8056F098
+ .sdata start:0x80574F28 end:0x80574F30
+ .sdata2 start:0x8057F678 end:0x8057F690
egg/gfx/eggLightObject.cpp:
.text start:0x804A9810 end:0x804AB24C
diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt
index 887e80fb..93a856f0 100644
--- a/config/SOUE01/symbols.txt
+++ b/config/SOUE01/symbols.txt
@@ -37369,7 +37369,7 @@ __vt__Q23EGG10FogManager = .data:0x8056F010; // type:object size:0x1C
__vt__Q23EGG7Frustum = .data:0x8056F030; // type:object size:0x14
EGG__GfxEnginer__Configuration__vtable = .data:0x8056F048; // type:object size:0x10
__vt__Q23EGG8IScnProc = .data:0x8056F058; // type:object size:0x10
-EGG__LightManager__vtable = .data:0x8056F068; // type:object size:0x30
+__vt__Q23EGG12LightManager = .data:0x8056F068; // type:object size:0x2C
__vt__Q23EGG11LightObject = .data:0x8056F098; // type:object size:0x20
__vt__Q23EGG12LightTexture = .data:0x8056F0B8; // type:object size:0x38
__vt__Q23EGG19LightTextureManager = .data:0x8056F0F0; // type:object size:0x1C
diff --git a/include/egg/gfx/eggLight.h b/include/egg/gfx/eggLight.h
deleted file mode 100644
index 67692962..00000000
--- a/include/egg/gfx/eggLight.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef EGG_LIGHT_H
-#define EGG_LIGHT_H
-
-#include "egg/prim/eggBinary.h"
-#include "nw4r/types_nw4r.h"
-
-namespace EGG {
-
-class LightTextureManager;
-
-// TODO: Fill out more
-class LightManager : public IBinary<LightManager> {
-public:
- struct BinData {};
- // vt at 0x00
- LightManager(u32, u32, u8);
- virtual ~LightManager();
- virtual void SetBinaryInner(const Bin &) override;
- virtual void GetBinaryInner(Bin *) const override;
- virtual size_t GetBinarySize() const override;
- virtual void SetBinaryInner(const Bin &, const Bin &, f32) override;
- virtual void Reset();
- virtual void Calc(nw4r::g3d::ScnRoot *);
- virtual void CalcView(const nw4r::math::MTX34 &, u8, nw4r::g3d::ScnRoot *);
- virtual void DoneDraw();
-
- LightTextureManager *GetTextureMgr() const {
- return mTextureMgr;
- }
-
- u8 TODO_0x04[0x14 - 0x04];
- LightTextureManager *mTextureMgr;
- u8 TODO_0x18[0x28 - 0x18];
-};
-
-} // namespace EGG
-
-#endif
diff --git a/include/egg/gfx/eggLightManager.h b/include/egg/gfx/eggLightManager.h
new file mode 100644
index 00000000..d1ed1cb8
--- /dev/null
+++ b/include/egg/gfx/eggLightManager.h
@@ -0,0 +1,73 @@
+#ifndef EGG_LIGHT_MANAGER_H
+#define EGG_LIGHT_MANAGER_H
+
+#include "egg/egg_types.h"
+#include "egg/gfx/eggLightObject.h"
+#include "egg/prim/eggBinary.h"
+#include "nw4r/types_nw4r.h"
+#include "rvl/GX/GXLight.h"
+#include "rvl/GX/GXTypes.h"
+
+namespace EGG {
+
+// TODO: Fill out more
+class LightManager : public IBinary<LightManager> {
+ struct LightData {
+ /* 0x00 */ LightObject mLightObject;
+ };
+
+ // ???
+ union Counts {
+ struct {
+ /* 0x00 */ u8 mNumEggLightObjects;
+ /* 0x01 */ u8 mNumUnks;
+ };
+ };
+
+ struct Unk1 {
+ /* 0x00 */ GXColor mColor;
+ /* 0x04 */ const char *mStr;
+ /* 0x08 */ u8 field_0x08;
+ };
+
+public:
+ struct BinData {};
+ // vt at 0x00
+ LightManager(u32, u32, u8);
+ virtual ~LightManager();
+ virtual void SetBinaryInner(const Bin &) override;
+ virtual void GetBinaryInner(Bin *) const override;
+ virtual size_t GetBinarySize() const override;
+ virtual void SetBinaryInner(const Bin &, const Bin &, f32) override;
+ virtual void Reset();
+ virtual void Calc(nw4r::g3d::ScnRoot *);
+ virtual void CalcView(const nw4r::math::MTX34 &, u8, nw4r::g3d::ScnRoot *);
+ virtual void DoneDraw();
+
+ void BecomeInvalidLight(int);
+
+ LightTextureManager *GetTextureMgr() const {
+ return mpTextureMgr;
+ }
+
+ LightObject *GetLightObject(int i) {
+ return &mpLightData[i].mLightObject;
+ }
+
+ /* 0x04 */ Counts mCounts0x04;
+ /* 0x06 */ Counts mCounts0x06;
+ /* 0x08 */ LightData *mpLightData;
+ /* 0x0C */ Unk1 *mpUnk1;
+ /* 0x10 */ GXLightObj *mpLightObjs;
+ /* 0x14 */ LightTextureManager *mpTextureMgr;
+ /* 0x18 */ GXColor mColor;
+ /* 0x1C */ u8 field_0x1C;
+ /* 0x1D */ u8 field_0x1D;
+ /* 0x1E */ u16 mFlags;
+ /* 0x20 */ u32 field_0x20;
+ /* 0x24 */ s16 field_0x24;
+};
+
+} // namespace EGG
+
+#endif
diff --git a/include/egg/gfx/eggLightObject.h b/include/egg/gfx/eggLightObject.h
index d9ff2455..ac7f8ceb 100644
--- a/include/egg/gfx/eggLightObject.h
+++ b/include/egg/gfx/eggLightObject.h
@@ -58,6 +58,18 @@ public:
return mDist;
}
+ void SetIndex(u16 index) {
+ mIndex = index;
+ }
+
+ void ClearField0xA0() {
+ field_0xA0 = 0;
+ }
+
+ void ClearFlag4() {
+ mFlags = mFlags & 0xFFFE;
+ }
+
private:
/* 0x04 */ u16 mIndex;
/* 0x06 */ u16 field_0x06;
diff --git a/include/m/m3d/m3d.h b/include/m/m3d/m3d.h
index e1503ecf..db977ea8 100644
--- a/include/m/m3d/m3d.h
+++ b/include/m/m3d/m3d.h
@@ -1,9 +1,7 @@
#ifndef M3D_H
#define M3D_H
-#include "egg/core/eggHeap.h"
-#include "egg/gfx/eggFogManager.h"
-#include "egg/gfx/eggLight.h"
+#include "egg/egg_types.h"
#include "m/m_allocator.h"
#include "nw4r/g3d/g3d_scnroot.h"
diff --git a/src/egg/gfx/eggLightManager.cpp b/src/egg/gfx/eggLightManager.cpp
index c842a6ec..ba8666b5 100644
--- a/src/egg/gfx/eggLightManager.cpp
+++ b/src/egg/gfx/eggLightManager.cpp
@@ -1,3 +1,74 @@
-#include "egg/gfx/eggLight.h"
+#include "egg/gfx/eggLightManager.h"
-namespace EGG {} // namespace EGG
+#include "common.h"
+#include "egg/egg_types.h"
+#include "egg/gfx/eggDrawGX.h"
+#include "egg/gfx/eggLightObject.h"
+#include "egg/gfx/eggLightTextureMgr.h"
+#include "rvl/GX/GXLight.h"
+
+namespace EGG {
+
+LightManager::LightManager(u32 p1, u32 p2, u8 p3) {
+ Counts c;
+ c.mNumEggLightObjects = p1;
+ c.mNumUnks = p2;
+
+ mCounts0x04 = c;
+ mCounts0x06 = c;
+ mpLightData = nullptr;
+ mpUnk1 = nullptr;
+ mpTextureMgr = nullptr;
+
+ field_0x1C = p3;
+ mFlags = 0x40;
+ field_0x20 = 0;
+ field_0x24 = -1;
+
+ mpTextureMgr = new LightTextureManager(this);
+ u16 numGxObjs = mCounts0x04.mNumEggLightObjects < 8 ? mCounts0x04.mNumEggLightObjects : 8;
+ mpLightObjs = new GXLightObj[field_0x1C * numGxObjs]();
+ mpLightData = new LightData[mCounts0x04.mNumEggLightObjects]();
+ mpUnk1 = new Unk1[mCounts0x04.mNumUnks]();
+
+ for (int i = 0; i < mCounts0x04.mNumEggLightObjects; i++) {
+ GetLightObject(i)->SetIndex(i);
+ GetLightObject(i)->ClearField0xA0();
+ BecomeInvalidLight(i);
+ }
+
+ for (u16 i = 0; i < (u32)mCounts0x04.mNumUnks; i++) {
+ mpUnk1[i].field_0x08 = 0;
+ }
+
+ Reset();
+}
+
+LightManager::~LightManager() {
+ delete mpTextureMgr;
+ delete[] mpLightObjs;
+ delete[] mpLightData;
+ delete[] mpUnk1;
+}
+
+static const char *resetPattern = "--";
+
+void LightManager::Reset() {
+ for (int i = 0; i < mCounts0x04.mNumEggLightObjects; i++) {
+ LightObject *obj = GetLightObject(i);
+ obj->Reset();
+ if (i > 0) {
+ obj->ClearFlag4();
+ }
+ }
+
+ for (u16 i = 0; i < (u32)mCounts0x04.mNumUnks; i++) {
+ mpUnk1[i].mColor = (GXColor){0x64, 0x64, 0x64, 0xFF};
+ mpUnk1[i].mStr = resetPattern;
+ }
+ mColor = DrawGX::BLACK;
+ field_0x1D = 0;
+ mFlags = mFlags & 0xFFE0;
+}
+
+} // namespace EGG
diff --git a/src/egg/gfx/eggLightObject.cpp b/src/egg/gfx/eggLightObject.cpp
index 1c5703c7..f24a2159 100644
--- a/src/egg/gfx/eggLightObject.cpp
+++ b/src/egg/gfx/eggLightObject.cpp
@@ -286,9 +286,9 @@ void LightObject::CopyFromG3D(
}
} else {
// TODO
- mFlags = mFlags & 0xFFFE;
+ ClearFlag4();
if (optObj != nullptr) {
- optObj->mFlags = optObj->mFlags & 0xFFFE;
+ optObj->ClearFlag4();
}
}
}
@@ -367,8 +367,7 @@ bool LightObject::ApplyAnmResultB(const nw4r::g3d::LightAnmResult &res) {
mShininess = res.shininess;
return true;
} else {
- // TODO
- mFlags = mFlags & 0xFFFE;
+ ClearFlag4();
return false;
}
}
diff --git a/src/m/m3d/m3d.cpp b/src/m/m3d/m3d.cpp
index f6fa0f9f..f701c3c3 100644
--- a/src/m/m3d/m3d.cpp
+++ b/src/m/m3d/m3d.cpp
@@ -1,7 +1,9 @@
#include "m/m3d/m3d.h"
#include "egg/gfx/eggDrawGX.h"
+#include "egg/gfx/eggFogManager.h"
#include "egg/gfx/eggGfxEngine.h"
+#include "egg/gfx/eggLightManager.h"
#include "egg/gfx/eggLightTexture.h"
#include "egg/gfx/eggLightTextureMgr.h"
#include "egg/gfx/eggScreen.h"
@@ -13,6 +15,7 @@
#include "nw4r/g3d/g3d_state.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
+
#include "rvl/GX.h" // IWYU pragma: export
namespace m3d {
diff --git a/src/toBeSorted/arc_callback_handler.cpp b/src/toBeSorted/arc_callback_handler.cpp
index eb51d80d..f2016729 100644
--- a/src/toBeSorted/arc_callback_handler.cpp
+++ b/src/toBeSorted/arc_callback_handler.cpp
@@ -2,6 +2,7 @@
#include "d/col/bg/d_bg_w_kcol.h"
#include "d/d_rawarchive.h"
#include "egg/gfx/eggLightTextureMgr.h"
+#include "egg/gfx/eggLightManager.h"
#include "m/m3d/m3d.h"
#include "nw4r/g3d.h" // IWYU pragma: export
#include "toBeSorted/arc_managers/current_stage_arc_manager.h"