summaryrefslogtreecommitdiff
path: root/src/egg/gfx
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 /src/egg/gfx
parentf66c22cf63529120697765e05b796d401c16555f (diff)
parentfb8a02193562bf57d35c4c70d168c6ae226084a6 (diff)
Merge branch '🥚' of https://github.com/robojumper/ss into pr/142
Diffstat (limited to 'src/egg/gfx')
-rw-r--r--src/egg/gfx/eggLightManager.cpp75
-rw-r--r--src/egg/gfx/eggLightObject.cpp7
2 files changed, 76 insertions, 6 deletions
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;
}
}