From 127f9ba8fa6e2d00339385adec19a98317f599dd Mon Sep 17 00:00:00 2001
From: HeartPiece <107153442+HeartPiece44@users.noreply.github.com>
Date: Mon, 5 Sep 2022 10:13:40 +1000
Subject: [PATCH] Link ebiP2TitleFog.cpp (#43)
* Link ebiP2TitleFog.cpp
* Format
---
README.MD | 1 +
asm/plugProjectEbisawaU/ebiP2TitleFog.s | 147 ------------------
include/Color4.h | 10 ++
include/ebi/title/TTitleFogMgr.h | 41 +++++
obj_files.mk | 2 +-
src/plugProjectEbisawaU/ebiP2TitleFog.cpp | 118 +++-----------
tools/progress.csv | 2 +
.../ebi/title/TTitleFogMgr.h | 28 ----
8 files changed, 74 insertions(+), 275 deletions(-)
delete mode 100644 asm/plugProjectEbisawaU/ebiP2TitleFog.s
create mode 100644 include/ebi/title/TTitleFogMgr.h
delete mode 100644 unsorted_include_todo/ebi/title/TTitleFogMgr.h
diff --git a/README.MD b/README.MD
index d86e65f73..d9d9e35bb 100644
--- a/README.MD
+++ b/README.MD
@@ -133,6 +133,7 @@ pikmin2.usa.dol: `sha1: 90d328bf8f190c90472e8c19e7e53c6ad0fe0d1a`
- plugProjectEbisawaU
- plugProjectEbisawaU/ebi3DGraph.cpp
- plugProjectEbisawaU/ebiP2TitleCamera.cpp
+ - plugProjectEbisawaU/ebiP2TitleFog.cpp
- plugProjectEbisawaU/ebiScreenFramework.cpp
- plugProjectEbisawaU/efx2dBase.cpp
- plugProjectMorimuraU
diff --git a/asm/plugProjectEbisawaU/ebiP2TitleFog.s b/asm/plugProjectEbisawaU/ebiP2TitleFog.s
deleted file mode 100644
index f4bec74e4..000000000
--- a/asm/plugProjectEbisawaU/ebiP2TitleFog.s
+++ /dev/null
@@ -1,147 +0,0 @@
-.include "macros.inc"
-.section .ctors, "wa" # 0x80472F00 - 0x804732C0
-lbl_constructor:
- .4byte __sinit_ebiP2TitleFog_cpp
-
-.section .data, "wa" # 0x8049E220 - 0x804EFC20
-.balign 8
-govNAN___Q24Game5P2JST:
- .float 0.0
- .float 0.0
- .float 0.0
-
-.section .sbss # 0x80514D80 - 0x80516360
-.balign 8
-gu32NAN___Q24Game5P2JST:
- .skip 4
-gfNAN___Q24Game5P2JST:
- .skip 4
-
-.section .sdata2, "a" # 0x80516360 - 0x80520E40
-.balign 8
-lbl_8051FE30:
- .float 0.0
-
-.section .text, "ax" # 0x800056C0 - 0x80472F00
-.global setGX__Q33ebi5title12TTitleFogMgrFR6Camera
-setGX__Q33ebi5title12TTitleFogMgrFR6Camera:
-/* 803EB1A4 003E80E4 94 21 FF A0 */ stwu r1, -0x60(r1)
-/* 803EB1A8 003E80E8 7C 08 02 A6 */ mflr r0
-/* 803EB1AC 003E80EC 90 01 00 64 */ stw r0, 0x64(r1)
-/* 803EB1B0 003E80F0 DB E1 00 50 */ stfd f31, 0x50(r1)
-/* 803EB1B4 003E80F4 F3 E1 00 58 */ psq_st f31, 88(r1), 0, qr0
-/* 803EB1B8 003E80F8 DB C1 00 40 */ stfd f30, 0x40(r1)
-/* 803EB1BC 003E80FC F3 C1 00 48 */ psq_st f30, 72(r1), 0, qr0
-/* 803EB1C0 003E8100 DB A1 00 30 */ stfd f29, 0x30(r1)
-/* 803EB1C4 003E8104 F3 A1 00 38 */ psq_st f29, 56(r1), 0, qr0
-/* 803EB1C8 003E8108 93 E1 00 2C */ stw r31, 0x2c(r1)
-/* 803EB1CC 003E810C 88 03 00 4C */ lbz r0, 0x4c(r3)
-/* 803EB1D0 003E8110 7C 9F 23 78 */ mr r31, r4
-/* 803EB1D4 003E8114 28 00 00 00 */ cmplwi r0, 0
-/* 803EB1D8 003E8118 41 82 00 94 */ beq lbl_803EB26C
-/* 803EB1DC 003E811C 80 C3 00 B8 */ lwz r6, 0xb8(r3)
-/* 803EB1E0 003E8120 80 A3 00 E0 */ lwz r5, 0xe0(r3)
-/* 803EB1E4 003E8124 80 83 01 08 */ lwz r4, 0x108(r3)
-/* 803EB1E8 003E8128 80 03 01 30 */ lwz r0, 0x130(r3)
-/* 803EB1EC 003E812C 98 C1 00 08 */ stb r6, 8(r1)
-/* 803EB1F0 003E8130 C3 C3 00 68 */ lfs f30, 0x68(r3)
-/* 803EB1F4 003E8134 C3 A3 00 90 */ lfs f29, 0x90(r3)
-/* 803EB1F8 003E8138 7F E3 FB 78 */ mr r3, r31
-/* 803EB1FC 003E813C 98 A1 00 09 */ stb r5, 9(r1)
-/* 803EB200 003E8140 98 81 00 0A */ stb r4, 0xa(r1)
-/* 803EB204 003E8144 98 01 00 0B */ stb r0, 0xb(r1)
-/* 803EB208 003E8148 80 01 00 08 */ lwz r0, 8(r1)
-/* 803EB20C 003E814C 90 01 00 10 */ stw r0, 0x10(r1)
-/* 803EB210 003E8150 48 02 FB 19 */ bl getFar__6CameraFv
-/* 803EB214 003E8154 FF E0 08 90 */ fmr f31, f1
-/* 803EB218 003E8158 7F E3 FB 78 */ mr r3, r31
-/* 803EB21C 003E815C 48 02 FA F1 */ bl getNear__6CameraFv
-/* 803EB220 003E8160 FC 60 08 90 */ fmr f3, f1
-/* 803EB224 003E8164 38 81 00 10 */ addi r4, r1, 0x10
-/* 803EB228 003E8168 FC 20 F0 90 */ fmr f1, f30
-/* 803EB22C 003E816C 38 60 00 02 */ li r3, 2
-/* 803EB230 003E8170 FC 40 E8 90 */ fmr f2, f29
-/* 803EB234 003E8174 FC 80 F8 90 */ fmr f4, f31
-/* 803EB238 003E8178 4B CF D9 A9 */ bl GXSetFog
-/* 803EB23C 003E817C 48 03 7F E9 */ bl getRenderModeObj__6SystemFv
-/* 803EB240 003E8180 A0 83 00 04 */ lhz r4, 4(r3)
-/* 803EB244 003E8184 38 61 00 14 */ addi r3, r1, 0x14
-/* 803EB248 003E8188 38 BF 00 B4 */ addi r5, r31, 0xb4
-/* 803EB24C 003E818C 4B CF DB B9 */ bl GXInitFogAdjTable
-/* 803EB250 003E8190 48 03 7F D5 */ bl getRenderModeObj__6SystemFv
-/* 803EB254 003E8194 A0 03 00 04 */ lhz r0, 4(r3)
-/* 803EB258 003E8198 38 A1 00 14 */ addi r5, r1, 0x14
-/* 803EB25C 003E819C 38 60 00 01 */ li r3, 1
-/* 803EB260 003E81A0 54 04 FC 7E */ rlwinm r4, r0, 0x1f, 0x11, 0x1f
-/* 803EB264 003E81A4 4B CF DD 51 */ bl GXSetFogRangeAdj
-/* 803EB268 003E81A8 48 00 00 28 */ b lbl_803EB290
-lbl_803EB26C:
-/* 803EB26C 003E81AC C0 22 1A D0 */ lfs f1, lbl_8051FE30@sda21(r2)
-/* 803EB270 003E81B0 38 81 00 0C */ addi r4, r1, 0xc
-/* 803EB274 003E81B4 80 03 00 24 */ lwz r0, 0x24(r3)
-/* 803EB278 003E81B8 38 60 00 00 */ li r3, 0
-/* 803EB27C 003E81BC FC 40 08 90 */ fmr f2, f1
-/* 803EB280 003E81C0 FC 60 08 90 */ fmr f3, f1
-/* 803EB284 003E81C4 90 01 00 0C */ stw r0, 0xc(r1)
-/* 803EB288 003E81C8 FC 80 08 90 */ fmr f4, f1
-/* 803EB28C 003E81CC 4B CF D9 55 */ bl GXSetFog
-lbl_803EB290:
-/* 803EB290 003E81D0 E3 E1 00 58 */ psq_l f31, 88(r1), 0, qr0
-/* 803EB294 003E81D4 CB E1 00 50 */ lfd f31, 0x50(r1)
-/* 803EB298 003E81D8 E3 C1 00 48 */ psq_l f30, 72(r1), 0, qr0
-/* 803EB29C 003E81DC CB C1 00 40 */ lfd f30, 0x40(r1)
-/* 803EB2A0 003E81E0 E3 A1 00 38 */ psq_l f29, 56(r1), 0, qr0
-/* 803EB2A4 003E81E4 CB A1 00 30 */ lfd f29, 0x30(r1)
-/* 803EB2A8 003E81E8 80 01 00 64 */ lwz r0, 0x64(r1)
-/* 803EB2AC 003E81EC 83 E1 00 2C */ lwz r31, 0x2c(r1)
-/* 803EB2B0 003E81F0 7C 08 03 A6 */ mtlr r0
-/* 803EB2B4 003E81F4 38 21 00 60 */ addi r1, r1, 0x60
-/* 803EB2B8 003E81F8 4E 80 00 20 */ blr
-
-.global loadSettingFile__Q33ebi5title12TTitleFogMgrFP10JKRArchivePc
-loadSettingFile__Q33ebi5title12TTitleFogMgrFP10JKRArchivePc:
-/* 803EB2BC 003E81FC 94 21 FB D0 */ stwu r1, -0x430(r1)
-/* 803EB2C0 003E8200 7C 08 02 A6 */ mflr r0
-/* 803EB2C4 003E8204 90 01 04 34 */ stw r0, 0x434(r1)
-/* 803EB2C8 003E8208 93 E1 04 2C */ stw r31, 0x42c(r1)
-/* 803EB2CC 003E820C 7C 7F 1B 78 */ mr r31, r3
-/* 803EB2D0 003E8210 7C 83 23 78 */ mr r3, r4
-/* 803EB2D4 003E8214 81 84 00 00 */ lwz r12, 0(r4)
-/* 803EB2D8 003E8218 7C A4 2B 78 */ mr r4, r5
-/* 803EB2DC 003E821C 81 8C 00 14 */ lwz r12, 0x14(r12)
-/* 803EB2E0 003E8220 7D 89 03 A6 */ mtctr r12
-/* 803EB2E4 003E8224 4E 80 04 21 */ bctrl
-/* 803EB2E8 003E8228 28 03 00 00 */ cmplwi r3, 0
-/* 803EB2EC 003E822C 41 82 00 38 */ beq lbl_803EB324
-/* 803EB2F0 003E8230 7C 64 1B 78 */ mr r4, r3
-/* 803EB2F4 003E8234 38 61 00 08 */ addi r3, r1, 8
-/* 803EB2F8 003E8238 38 A0 FF FF */ li r5, -1
-/* 803EB2FC 003E823C 48 02 A5 FD */ bl __ct__9RamStreamFPvi
-/* 803EB300 003E8240 38 00 00 01 */ li r0, 1
-/* 803EB304 003E8244 2C 00 00 01 */ cmpwi r0, 1
-/* 803EB308 003E8248 90 01 00 14 */ stw r0, 0x14(r1)
-/* 803EB30C 003E824C 40 82 00 0C */ bne lbl_803EB318
-/* 803EB310 003E8250 38 00 00 00 */ li r0, 0
-/* 803EB314 003E8254 90 01 04 1C */ stw r0, 0x41c(r1)
-lbl_803EB318:
-/* 803EB318 003E8258 38 7F 00 28 */ addi r3, r31, 0x28
-/* 803EB31C 003E825C 38 81 00 08 */ addi r4, r1, 8
-/* 803EB320 003E8260 48 02 84 D5 */ bl read__10ParametersFR6Stream
-lbl_803EB324:
-/* 803EB324 003E8264 80 01 04 34 */ lwz r0, 0x434(r1)
-/* 803EB328 003E8268 83 E1 04 2C */ lwz r31, 0x42c(r1)
-/* 803EB32C 003E826C 7C 08 03 A6 */ mtlr r0
-/* 803EB330 003E8270 38 21 04 30 */ addi r1, r1, 0x430
-/* 803EB334 003E8274 4E 80 00 20 */ blr
-
-__sinit_ebiP2TitleFog_cpp: # static initializer
-/* 803EB338 003E8278 3C 80 80 51 */ lis r4, __float_nan@ha
-/* 803EB33C 003E827C 38 00 FF FF */ li r0, -1
-/* 803EB340 003E8280 C0 04 48 B0 */ lfs f0, __float_nan@l(r4)
-/* 803EB344 003E8284 3C 60 80 4F */ lis r3, govNAN___Q24Game5P2JST@ha
-/* 803EB348 003E8288 90 0D 9A 90 */ stw r0, gu32NAN___Q24Game5P2JST@sda21(r13)
-/* 803EB34C 003E828C D4 03 9F A8 */ stfsu f0, govNAN___Q24Game5P2JST@l(r3)
-/* 803EB350 003E8290 D0 0D 9A 94 */ stfs f0, gfNAN___Q24Game5P2JST@sda21(r13)
-/* 803EB354 003E8294 D0 03 00 04 */ stfs f0, 4(r3)
-/* 803EB358 003E8298 D0 03 00 08 */ stfs f0, 8(r3)
-/* 803EB35C 003E829C 4E 80 00 20 */ blr
diff --git a/include/Color4.h b/include/Color4.h
index a64855eaf..5fe9d9ce6 100644
--- a/include/Color4.h
+++ b/include/Color4.h
@@ -14,6 +14,16 @@ struct Color4 {
, b(blue)
, a(alpha) {};
+ inline GXColor toGXColor()
+ {
+ GXColor color;
+ color.r = r;
+ color.g = g;
+ color.b = b;
+ color.a = a;
+ return color;
+ }
+
void read(struct Stream&);
void write(struct Stream&);
diff --git a/include/ebi/title/TTitleFogMgr.h b/include/ebi/title/TTitleFogMgr.h
new file mode 100644
index 000000000..1006015a2
--- /dev/null
+++ b/include/ebi/title/TTitleFogMgr.h
@@ -0,0 +1,41 @@
+#ifndef _EBI_TITLE_TTITLEFOGMGR_H
+#define _EBI_TITLE_TTITLEFOGMGR_H
+
+#include "types.h"
+#include "JSystem/JKR/JKRArchive.h"
+#include "FogMgr.h"
+#include "Camera.h"
+#include "Parameters.h"
+#include "BaseParm.h"
+
+namespace ebi {
+namespace title {
+/**
+ * @size{0x140}
+ */
+struct TTitleFogMgr : public FogMgr {
+ struct Parms : public Parameters {
+ // fabricated
+ // offsets relative to TTitleFogMgr
+ Parm fg10; // _34
+ Parm fg00; // _50
+ Parm fg01; // _78
+ Parm fg02; // _A0
+ Parm fg03; // _C8
+ Parm fg04; // _F0
+ Parm fg05; // _118
+ };
+
+ virtual ~TTitleFogMgr() { } // _08 (weak)
+
+ void setGX(Camera& camera);
+ void loadSettingFile(JKRArchive* archive, char* file);
+
+ // _00 = VTBL
+ // _00-_28 = FogMgr
+ Parms m_parms; // _28
+};
+} // namespace title
+} // namespace ebi
+
+#endif
diff --git a/obj_files.mk b/obj_files.mk
index 7b0dc4f20..4f139260f 100644
--- a/obj_files.mk
+++ b/obj_files.mk
@@ -1060,7 +1060,7 @@ EBISAWA:=\
$(BUILD_DIR)/asm/plugProjectEbisawaU/ebiP2TitleChappy.o\
$(BUILD_DIR)/asm/plugProjectEbisawaU/ebiScreenTMBack.o\
$(BUILD_DIR)/asm/plugProjectEbisawaU/ebiMainTitleMgr.o\
- $(BUILD_DIR)/asm/plugProjectEbisawaU/ebiP2TitleFog.o\
+ $(BUILD_DIR)/src/plugProjectEbisawaU/ebiP2TitleFog.o\
$(BUILD_DIR)/asm/plugProjectEbisawaU/efxEnemyBoss.o\
$(BUILD_DIR)/asm/plugProjectEbisawaU/ebiCardEReader.o\
$(BUILD_DIR)/asm/plugProjectEbisawaU/ebiScreenOmake.o\
diff --git a/src/plugProjectEbisawaU/ebiP2TitleFog.cpp b/src/plugProjectEbisawaU/ebiP2TitleFog.cpp
index 51fd485c4..9b045cd35 100644
--- a/src/plugProjectEbisawaU/ebiP2TitleFog.cpp
+++ b/src/plugProjectEbisawaU/ebiP2TitleFog.cpp
@@ -1,140 +1,60 @@
#include "types.h"
-#include "JSystem/JKR/JKRArchive.h"
-#include "FogMgr.h"
-#include "Camera.h"
+#include "ebi/title/TTitleFogMgr.h"
#include "Dolphin/gx.h"
#include "System.h"
-#include "BaseParm.h"
#include "nans.h"
-/*
- Generated from dpostproc
-
- .section .ctors, "wa" # 0x80472F00 - 0x804732C0
- .4byte __sinit_ebiP2TitleFog_cpp
-
- .section .data, "wa" # 0x8049E220 - 0x804EFC20
- .global lbl_804E9FA8
- lbl_804E9FA8:
- .4byte 0x00000000
- .4byte 0x00000000
- .4byte 0x00000000
- .4byte 0x00000000
-
- .section .sbss # 0x80514D80 - 0x80516360
- .global lbl_80516110
- lbl_80516110:
- .skip 0x4
- .global lbl_80516114
- lbl_80516114:
- .skip 0x4
-
- .section .sdata2, "a" # 0x80516360 - 0x80520E40
- .global lbl_8051FE30
- lbl_8051FE30:
- .float 0.0
-*/
-
namespace ebi {
namespace title {
-struct TTitleFogMgr : public FogMgr {
- virtual ~TTitleFogMgr() { } // _08 (weak)
-
- void setGX(Camera& camera);
- void loadSettingFile(JKRArchive* archive, char* file);
-
- Parameters m_parameters;
- Parm fg10;
- Parm fg00;
- Parm fg01;
- Parm fg02;
- Parm fg03;
- Parm fg04;
- Parm fg05;
-};
-
/*
+ * sets Fog graphics effect based on parameters.
+ *
* --INFO--
* Address: 803EB1A4
* Size: 000118
*/
-// TODO: non-matching!
void TTitleFogMgr::setGX(Camera& camera)
{
- if (_4C) {
- struct {
- s8 _00;
- s8 _01;
- s8 _02;
- s8 _03;
- } v16Obj;
+ if (m_parms.fg10.m_value) {
+ Color4 color4_local(m_parms.fg02.m_value, m_parms.fg03.m_value, m_parms.fg04.m_value, m_parms.fg05.m_value);
+ GXColor color_local = color4_local.toGXColor();
- v16Obj._03 = _B8;
- v16Obj._01 = _E0;
- v16Obj._02 = _108;
- v16Obj._00 = _130;
+ float f1 = m_parms.fg00.m_value;
+ float f2 = m_parms.fg01.m_value;
- GXSetFog(GX_FOG_LINEAR, (void*)&v16Obj, _68, _90, camera.getNear(), camera.getFar());
+ GXSetFog(GX_FOG_LINEAR, f1, f2, camera.getNear(), camera.getFar(), color_local);
+ u16 width = System::getRenderModeObj()->fbWidth;
GXFogAdjTable table;
- GXInitFogAdjTable(&table, System::getRenderModeObj()->fbWidth, camera._B4);
- GXSetFogRangeAdj(TRUE, System::getRenderModeObj()->fbWidth >> 1, &table);
+ GXInitFogAdjTable(&table, width, camera.m_projectionMtx);
+ GXSetFogRangeAdj(GX_TRUE, (u16)(System::getRenderModeObj()->fbWidth) / 2, &table);
} else {
- GXSetFog(GX_FOG_NONE, _24, 0.0f, 0.0f, 0.0f, 0.0f);
+ GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, m_color.GXColorView);
}
}
/*
- * --INFO--
- * Address: ........
- * Size: 000040
- */
-void TTitleFogMgr::offGX(void)
-{
- // UNUSED FUNCTION
-}
-
-/*
+ * Sets title-screen fog parameters from file.
+ *
* --INFO--
* Address: 803EB2BC
* Size: 00007C
*/
void TTitleFogMgr::loadSettingFile(JKRArchive* archive, char* file)
{
- void* a = archive->getResource(file);
- if (a != nullptr) {
- RamStream stream(a, -1);
+ void* resource = archive->getResource(file);
+ if (resource != nullptr) {
+ RamStream stream(resource, -1);
stream.m_mode = 1;
if (stream.m_mode == 1) {
stream.m_tabCount = 0;
};
- m_parameters.read(stream);
+ m_parms.read(stream);
}
}
} // namespace title
} // namespace ebi
-
-/*
- * --INFO--
- * Address: 803EB338
- * Size: 000028
- */
-void __sinit_ebiP2TitleFog_cpp(void)
-{
- /*
- lis r4, __float_nan@ha
- li r0, -1
- lfs f0, __float_nan@l(r4)
- lis r3, lbl_804E9FA8@ha
- stw r0, lbl_80516110@sda21(r13)
- stfsu f0, lbl_804E9FA8@l(r3)
- stfs f0, lbl_80516114@sda21(r13)
- stfs f0, 4(r3)
- stfs f0, 8(r3)
- blr
- */
-}
diff --git a/tools/progress.csv b/tools/progress.csv
index af888b02d..c92f772e6 100644
--- a/tools/progress.csv
+++ b/tools/progress.csv
@@ -35,3 +35,5 @@ You have 256 out of 10000 Pokos and 12 out of 201 treasures.",2022-08-26 17:42:5
You have 257 out of 10000 Pokos and 12 out of 201 treasures.",2022-08-26 18:46:42.830782
259,120836,0.025973099197997056,12,44330,0.062186472443242394,"
You have 259 out of 10000 Pokos and 12 out of 201 treasures.",2022-08-28 22:34:46.890770
+274,127500,0.027405492963559076,12,44910,0.06300010100216594,"
+You have 274 out of 10000 Pokos and 12 out of 201 treasures.",2022-09-05 08:55:29.535672
diff --git a/unsorted_include_todo/ebi/title/TTitleFogMgr.h b/unsorted_include_todo/ebi/title/TTitleFogMgr.h
deleted file mode 100644
index e83de2424..000000000
--- a/unsorted_include_todo/ebi/title/TTitleFogMgr.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _EBI_TITLE_TTITLEFOGMGR_H
-#define _EBI_TITLE_TTITLEFOGMGR_H
-
-/*
- __vt__Q33ebi5title12TTitleFogMgr:
- .4byte 0
- .4byte 0
- .4byte __dt__Q33ebi5title12TTitleFogMgrFv
- .4byte getChildCount__5CNodeFv
-*/
-
-struct CNode {
- virtual ~CNode(); // _08 (weak)
- virtual void getChildCount(); // _0C
-};
-
-namespace ebi {
-namespace title {
-struct TTitleFogMgr : public CNode {
- virtual ~TTitleFogMgr(); // _08 (weak)
-
- void setGX(Camera&);
- void loadSettingFile(JKRArchive*, char*);
-};
-} // namespace title
-} // namespace ebi
-
-#endif