summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
4 files changed, 80 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;
}
}
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"