From f2fe70ba8ebeb23d23ea6036b33ead083bf38383 Mon Sep 17 00:00:00 2001 From: robojumper Date: Tue, 25 Jun 2024 20:02:16 +0200 Subject: [PATCH] dAcOmoleSoil_c OK --- .../rels/d_a_obj_mole_soilNP/splits.txt | 3 + .../rels/d_a_obj_mole_soilNP/symbols.txt | 114 ++++++++-------- configure.py | 2 +- include/d/a/obj/d_a_obj_mole_soil.h | 39 ++++++ include/d/a/obj/d_a_obj_sun_light.h | 5 - include/m/m3d/m_smdl.h | 3 + include/m/m_mtx.h | 4 + include/s/README.txt | 6 + include/s/s_StateID.hpp | 4 +- include/s/s_StateInterfaces.hpp | 4 +- include/s/s_StateMgr.hpp | 5 + src/REL/d/a/obj/d_a_obj_mole_soil.cpp | 128 ++++++++++++++++++ src/REL/d/a/obj/d_a_obj_ring.cpp | 4 +- src/REL/d/a/obj/d_a_obj_sun_light.cpp | 4 +- src/m/m3d/m_anmmatclr.cpp | 2 +- src/s/s_StateID.cpp | 4 +- 16 files changed, 257 insertions(+), 74 deletions(-) create mode 100644 include/d/a/obj/d_a_obj_mole_soil.h diff --git a/config/SOUE01/rels/d_a_obj_mole_soilNP/splits.txt b/config/SOUE01/rels/d_a_obj_mole_soilNP/splits.txt index d317971d..2e881ae6 100644 --- a/config/SOUE01/rels/d_a_obj_mole_soilNP/splits.txt +++ b/config/SOUE01/rels/d_a_obj_mole_soilNP/splits.txt @@ -17,3 +17,6 @@ REL/global_destructor_chain.c: REL/d/a/obj/d_a_obj_mole_soil.cpp: .text start:0x000000F0 end:0x00000F18 .ctors start:0x00000000 end:0x00000004 + .rodata start:0x00000000 end:0x00000030 + .data start:0x00000000 end:0x0000024C + .bss start:0x00000008 end:0x000000C8 diff --git a/config/SOUE01/rels/d_a_obj_mole_soilNP/symbols.txt b/config/SOUE01/rels/d_a_obj_mole_soilNP/symbols.txt index a60ebd39..1c3c22e8 100644 --- a/config/SOUE01/rels/d_a_obj_mole_soilNP/symbols.txt +++ b/config/SOUE01/rels/d_a_obj_mole_soilNP/symbols.txt @@ -3,64 +3,64 @@ _epilog = .text:0x00000030; // type:function size:0x2C scope:global _unresolved = .text:0x00000060; // type:function size:0x4 scope:global __register_global_object = .text:0x00000070; // type:function size:0x1C scope:global __destroy_global_chain = .text:0x00000090; // type:function size:0x54 scope:global -fn_101_F0 = .text:0x000000F0; // type:function size:0xC0 -fn_101_1B0 = .text:0x000001B0; // type:function size:0x58 -fn_101_210 = .text:0x00000210; // type:function size:0x6C -fn_101_280 = .text:0x00000280; // type:function size:0xA0 -fn_101_320 = .text:0x00000320; // type:function size:0xA4 -fn_101_3D0 = .text:0x000003D0; // type:function size:0x9C -fn_101_470 = .text:0x00000470; // type:function size:0xCC -fn_101_540 = .text:0x00000540; // type:function size:0x10 -fn_101_550 = .text:0x00000550; // type:function size:0x8 -fn_101_560 = .text:0x00000560; // type:function size:0x174 -fn_101_6E0 = .text:0x000006E0; // type:function size:0x10 -fn_101_6F0 = .text:0x000006F0; // type:function size:0x10 -fn_101_700 = .text:0x00000700; // type:function size:0x34 -fn_101_740 = .text:0x00000740; // type:function size:0xC -fn_101_750 = .text:0x00000750; // type:function size:0x4 -fn_101_760 = .text:0x00000760; // type:function size:0x4 -fn_101_770 = .text:0x00000770; // type:function size:0xC -fn_101_780 = .text:0x00000780; // type:function size:0x7C -fn_101_800 = .text:0x00000800; // type:function size:0x24 -fn_101_830 = .text:0x00000830; // type:function size:0xC -fn_101_840 = .text:0x00000840; // type:function size:0xA8 -fn_101_8F0 = .text:0x000008F0; // type:function size:0x24 -fn_101_920 = .text:0x00000920; // type:function size:0xCC -fn_101_9F0 = .text:0x000009F0; // type:function size:0x60 -fn_101_A50 = .text:0x00000A50; // type:function size:0xC -fn_101_A60 = .text:0x00000A60; // type:function size:0x1C -fn_101_A80 = .text:0x00000A80; // type:function size:0x1C -fn_101_AA0 = .text:0x00000AA0; // type:function size:0x1C -fn_101_AC0 = .text:0x00000AC0; // type:function size:0x10 -fn_101_AD0 = .text:0x00000AD0; // type:function size:0x10 -fn_101_AE0 = .text:0x00000AE0; // type:function size:0x10 -fn_101_AF0 = .text:0x00000AF0; // type:function size:0x10 -fn_101_B00 = .text:0x00000B00; // type:function size:0x10 -fn_101_B10 = .text:0x00000B10; // type:function size:0x10 -fn_101_B20 = .text:0x00000B20; // type:function size:0x30 -fn_101_B50 = .text:0x00000B50; // type:function size:0x30 -fn_101_B80 = .text:0x00000B80; // type:function size:0x30 -fn_101_BB0 = .text:0x00000BB0; // type:function size:0x27C -fn_101_E30 = .text:0x00000E30; // type:function size:0x58 -fn_101_E90 = .text:0x00000E90; // type:function size:0x88 +dAcOmoleSoil_c_classInit__Fv = .text:0x000000F0; // type:function size:0xC0 +__dt__27sFState_c<14dAcOmoleSoil_c>Fv = .text:0x000001B0; // type:function size:0x58 +__dt__30sFStateFct_c<14dAcOmoleSoil_c>Fv = .text:0x00000210; // type:function size:0x6C +__dt__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000280; // type:function size:0xA0 +__dt__53sFStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000320; // type:function size:0xA4 +createHeap__14dAcOmoleSoil_cFv = .text:0x000003D0; // type:function size:0x9C +create__14dAcOmoleSoil_cFv = .text:0x00000470; // type:function size:0xCC +changeState__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000540; // type:function size:0x10 +doDelete__14dAcOmoleSoil_cFv = .text:0x00000550; // type:function size:0x8 +actorExecute__14dAcOmoleSoil_cFv = .text:0x00000560; // type:function size:0x174 +getStateID__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x000006E0; // type:function size:0x10 +executeState__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000006F0; // type:function size:0x10 +draw__14dAcOmoleSoil_cFv = .text:0x00000700; // type:function size:0x34 +initializeState_Wait__14dAcOmoleSoil_cFv = .text:0x00000740; // type:function size:0xC +executeState_Wait__14dAcOmoleSoil_cFv = .text:0x00000750; // type:function size:0x4 +finalizeState_Wait__14dAcOmoleSoil_cFv = .text:0x00000760; // type:function size:0x4 +initializeState_Appear__14dAcOmoleSoil_cFv = .text:0x00000770; // type:function size:0xC +executeState_Appear__14dAcOmoleSoil_cFv = .text:0x00000780; // type:function size:0x7C +finalizeState_Appear__14dAcOmoleSoil_cFv = .text:0x00000800; // type:function size:0x24 +initializeState_DisAppear__14dAcOmoleSoil_cFv = .text:0x00000830; // type:function size:0xC +executeState_DisAppear__14dAcOmoleSoil_cFv = .text:0x00000840; // type:function size:0xA8 +finalizeState_DisAppear__14dAcOmoleSoil_cFv = .text:0x000008F0; // type:function size:0x24 +__dt__14dAcOmoleSoil_cFv = .text:0x00000920; // type:function size:0xCC +build__30sFStateFct_c<14dAcOmoleSoil_c>FRC12sStateIDIf_c = .text:0x000009F0; // type:function size:0x60 +dispose__30sFStateFct_c<14dAcOmoleSoil_c>FRP10sStateIf_c = .text:0x00000A50; // type:function size:0xC +initialize__27sFState_c<14dAcOmoleSoil_c>Fv = .text:0x00000A60; // type:function size:0x1C +execute__27sFState_c<14dAcOmoleSoil_c>Fv = .text:0x00000A80; // type:function size:0x1C +finalize__27sFState_c<14dAcOmoleSoil_c>Fv = .text:0x00000AA0; // type:function size:0x1C +initializeState__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000AC0; // type:function size:0x10 +finalizeState__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000AD0; // type:function size:0x10 +refreshState__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000AE0; // type:function size:0x10 +getState__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000AF0; // type:function size:0x10 +getNewStateID__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000B00; // type:function size:0x10 +getOldStateID__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000B10; // type:function size:0x10 +finalizeState__29sFStateID_c<14dAcOmoleSoil_c>CFR14dAcOmoleSoil_c = .text:0x00000B20; // type:function size:0x30 +executeState__29sFStateID_c<14dAcOmoleSoil_c>CFR14dAcOmoleSoil_c = .text:0x00000B50; // type:function size:0x30 +initializeState__29sFStateID_c<14dAcOmoleSoil_c>CFR14dAcOmoleSoil_c = .text:0x00000B80; // type:function size:0x30 +__sinit_\d_a_obj_mole_soil_cpp = .text:0x00000BB0; // type:function size:0x27C scope:local +__dt__29sFStateID_c<14dAcOmoleSoil_c>Fv = .text:0x00000E30; // type:function size:0x58 +isSameName__29sFStateID_c<14dAcOmoleSoil_c>CFPCc = .text:0x00000E90; // type:function size:0x88 _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global __destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global -lbl_101_rodata_0 = .rodata:0x00000000; // type:object size:0x8 data:float -lbl_101_rodata_8 = .rodata:0x00000008; // type:object size:0x10 data:float -lbl_101_rodata_18 = .rodata:0x00000018; // type:object size:0x4 data:float -lbl_101_rodata_1C = .rodata:0x0000001C; // type:object size:0x14 data:float -lbl_101_data_0 = .data:0x00000000; // type:object size:0x10 data:4byte -lbl_101_data_10 = .data:0x00000010; // type:object size:0xC -lbl_101_data_1C = .data:0x0000001C; // type:object size:0x1C data:string -lbl_101_data_38 = .data:0x00000038; // type:object size:0x80 -lbl_101_data_B8 = .data:0x000000B8; // type:object size:0x30 -lbl_101_data_E8 = .data:0x000000E8; // type:object size:0x30 -lbl_101_data_118 = .data:0x00000118; // type:object size:0x18 -lbl_101_data_130 = .data:0x00000130; // type:object size:0xE8 -lbl_101_data_218 = .data:0x00000218; // type:object size:0x34 +lbl_101_rodata_0 = .rodata:0x00000000; // type:object size:0x8 scope:local data:float +lbl_101_rodata_8 = .rodata:0x00000008; // type:object size:0x10 scope:local data:float +lbl_101_rodata_18 = .rodata:0x00000018; // type:object size:0x4 scope:local data:float +lbl_101_rodata_1C = .rodata:0x0000001C; // type:object size:0x14 scope:local data:float +g_profile_OBJ_MOLE_SOIL = .data:0x00000000; // type:object size:0x10 data:4byte +lbl_101_data_10 = .data:0x00000010; // type:object size:0xA scope:local data:string +lbl_101_data_1C = .data:0x0000001C; // type:object size:0x1C scope:local data:string +__vt__14dAcOmoleSoil_c = .data:0x00000038; // type:object size:0x80 +__vt__53sFStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c> = .data:0x000000B8; // type:object size:0x30 +__vt__83sStateMgr_c<14dAcOmoleSoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x000000E8; // type:object size:0x30 +__vt__30sFStateFct_c<14dAcOmoleSoil_c> = .data:0x00000118; // type:object size:0x14 +__vt__27sFState_c<14dAcOmoleSoil_c> = .data:0x00000130; // type:object size:0x18 +__vt__29sFStateID_c<14dAcOmoleSoil_c> = .data:0x00000218; // type:object size:0x34 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global -lbl_101_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte -lbl_101_bss_18 = .bss:0x00000018; // type:object size:0x40 data:4byte -lbl_101_bss_58 = .bss:0x00000058; // type:object size:0x40 data:4byte -lbl_101_bss_98 = .bss:0x00000098; // type:object size:0x30 data:4byte +lbl_101_bss_8 = .bss:0x00000008; // type:object size:0xC scope:local data:4byte +StateID_Wait__14dAcOmoleSoil_c = .bss:0x00000018; // type:object size:0x30 data:4byte +StateID_Appear__14dAcOmoleSoil_c = .bss:0x00000058; // type:object size:0x30 data:4byte +StateID_DisAppear__14dAcOmoleSoil_c = .bss:0x00000098; // type:object size:0x30 data:4byte diff --git a/configure.py b/configure.py index 3e74a912..865bb18e 100644 --- a/configure.py +++ b/configure.py @@ -884,7 +884,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Rel(NonMatching, "d_a_obj_megami_island", "REL/d/a/obj/d_a_obj_megami_island.cpp"), Rel(NonMatching, "d_a_obj_mg_pumpkin", "REL/d/a/obj/d_a_obj_mg_pumpkin.cpp"), Rel(NonMatching, "d_a_obj_mole_cover", "REL/d/a/obj/d_a_obj_mole_cover.cpp"), - Rel(NonMatching, "d_a_obj_mole_soil", "REL/d/a/obj/d_a_obj_mole_soil.cpp"), + Rel(Matching, "d_a_obj_mole_soil", "REL/d/a/obj/d_a_obj_mole_soil.cpp"), Rel(NonMatching, "d_a_obj_move_elec", "REL/d/a/obj/d_a_obj_move_elec.cpp"), Rel(NonMatching, "d_a_obj_move_lift_vol", "REL/d/a/obj/d_a_obj_move_lift_vol.cpp"), Rel(NonMatching, "d_a_obj_musasabi", "REL/d/a/obj/d_a_obj_musasabi.cpp"), diff --git a/include/d/a/obj/d_a_obj_mole_soil.h b/include/d/a/obj/d_a_obj_mole_soil.h new file mode 100644 index 00000000..34342bf8 --- /dev/null +++ b/include/d/a/obj/d_a_obj_mole_soil.h @@ -0,0 +1,39 @@ +#ifndef D_A_OBJ_MOLE_SOIL_H +#define D_A_OBJ_MOLE_SOIL_H + +#include +#include +#include +#include + +class dAcOmoleSoil_c : public dAcObjBase_c { +public: + dAcOmoleSoil_c() : mStateMgr(*this, sStateID::null) {} + virtual ~dAcOmoleSoil_c() {} + virtual bool createHeap() override; + virtual int create() override; + virtual int actorExecute() override; + virtual int draw() override; + virtual int doDelete() override; + + STATE_FUNC_DECLARE(dAcOmoleSoil_c, Wait); + STATE_FUNC_DECLARE(dAcOmoleSoil_c, Appear); + STATE_FUNC_DECLARE(dAcOmoleSoil_c, DisAppear); + +private: + const static f32 sHalfScale; + const static f32 sFullScale; + + u8 getNextState() { + return mDesiredNextState; + } + + nw4r::g3d::ResFile mBrres; + m3d::smdl_c mModel; + STATE_MGR_DECLARE(dAcOmoleSoil_c); + f32 mScale; + u8 mDesiredNextState; + bool field_0x391; +}; + +#endif diff --git a/include/d/a/obj/d_a_obj_sun_light.h b/include/d/a/obj/d_a_obj_sun_light.h index 38756d16..b3badc71 100644 --- a/include/d/a/obj/d_a_obj_sun_light.h +++ b/include/d/a/obj/d_a_obj_sun_light.h @@ -17,11 +17,6 @@ class dAcOsunLight_c : public dAcObjBase_c { virtual int draw() override; virtual int doDelete() override; - // This inline fixes stack alloc - inline bool createModel(nw4r::g3d::ResMdl mdl) { - return mModel.create(mdl, &heap_allocator, 0x120, 1, nullptr); - } - bool isDay(); STATE_FUNC_DECLARE(dAcOsunLight_c, Wait); diff --git a/include/m/m3d/m_smdl.h b/include/m/m3d/m_smdl.h index 7089d07a..e55f759a 100644 --- a/include/m/m3d/m_smdl.h +++ b/include/m/m3d/m_smdl.h @@ -15,6 +15,9 @@ class smdl_c : public bmdl_c, UnkClass2 { virtual ~smdl_c(); bool create(nw4r::g3d::ResMdl mdl, mAllocator_c *alloc, u32 bufferOption, int nView, u32 *pSize); + bool create(nw4r::g3d::ResMdl mdl, mAllocator_c *alloc, u32 bufferOption) { + return create(mdl, alloc, bufferOption, 1, nullptr); + } }; } // namespace m3d diff --git a/include/m/m_mtx.h b/include/m/m_mtx.h index 8158e9ac..7172d8bc 100644 --- a/include/m/m_mtx.h +++ b/include/m/m_mtx.h @@ -38,6 +38,10 @@ class mMtx_c { /* 802f1c40 */ void rot(int, int); // does some werrd operation to rotate the matrix /* 802f1e60 */ bool quatRelated(); + operator nw4r::math::MTX34*() { + return &nw4rm; + } + public: union { EGG::Matrix34f mat; diff --git a/include/s/README.txt b/include/s/README.txt index 5be519ee..48466fb0 100644 --- a/include/s/README.txt +++ b/include/s/README.txt @@ -16,3 +16,9 @@ In order for vtable ordering to match, some classes had to be extracted to a new S_StateMethod_c's destructors calls back into another destructors. sStateMethodIf_c follows the example of the other abstract interface classes and provides this dtor. + +## operator== / != return BOOL instead of bool + +We're observing a lot of word-to-bool casts in code after these +operators are invoked, and while there are ways to force the conversion, +this seems the most reasonable. diff --git a/include/s/s_StateID.hpp b/include/s/s_StateID.hpp index 422d9143..4c2ee84f 100644 --- a/include/s/s_StateID.hpp +++ b/include/s/s_StateID.hpp @@ -27,8 +27,8 @@ class sStateID_c : public sStateIDIf_c { virtual bool isNull() const; virtual bool isEqual(const sStateIDIf_c &other) const; - virtual bool operator==(const sStateIDIf_c &other) const; - virtual bool operator!=(const sStateIDIf_c &other) const; + virtual BOOL operator==(const sStateIDIf_c &other) const; + virtual BOOL operator!=(const sStateIDIf_c &other) const; virtual bool isSameName(const char *name) const; virtual const char *name() const; diff --git a/include/s/s_StateInterfaces.hpp b/include/s/s_StateInterfaces.hpp index 8e28f44c..92101b2c 100644 --- a/include/s/s_StateInterfaces.hpp +++ b/include/s/s_StateInterfaces.hpp @@ -23,8 +23,8 @@ class sStateIDIf_c { virtual bool isNull() const = 0; ///< Returns whether this is a null state. virtual bool isEqual(const sStateIDIf_c &other) const = 0; ///< Returns whether both states have the same number. - virtual bool operator==(const sStateIDIf_c &other) const = 0; ///< Overloaded equality operator, using ::isEqual. - virtual bool operator!=(const sStateIDIf_c &other) const = 0; ///< Overloaded inequality operator, using ::isEqual. + virtual BOOL operator==(const sStateIDIf_c &other) const = 0; ///< Overloaded equality operator, using ::isEqual. + virtual BOOL operator!=(const sStateIDIf_c &other) const = 0; ///< Overloaded inequality operator, using ::isEqual. virtual bool isSameName(const char *name) const = 0; ///< Returns whether this state ID is called @p name. virtual const char *name() const = 0; ///< Returns the name of this state ID. diff --git a/include/s/s_StateMgr.hpp b/include/s/s_StateMgr.hpp index c043eb71..09f5f217 100644 --- a/include/s/s_StateMgr.hpp +++ b/include/s/s_StateMgr.hpp @@ -35,6 +35,11 @@ class sStateMgr_c : sStateMgrIf_c { virtual const sStateIDIf_c *getStateID() const { return mMethod.getStateID(); } virtual const sStateIDIf_c *getOldStateID() const { return mMethod.getOldStateID(); } + // SS addition + bool isState(const sStateIDIf_c& other) { + return *getStateID() == other; + } + private: Check mCheck; Factory mFactory; diff --git a/src/REL/d/a/obj/d_a_obj_mole_soil.cpp b/src/REL/d/a/obj/d_a_obj_mole_soil.cpp index e69de29b..72c9415e 100644 --- a/src/REL/d/a/obj/d_a_obj_mole_soil.cpp +++ b/src/REL/d/a/obj/d_a_obj_mole_soil.cpp @@ -0,0 +1,128 @@ +#include +#include +#include + +SPECIAL_ACTOR_PROFILE(OBJ_MOLE_SOIL, dAcOmoleSoil_c, fProfile::OBJ_MOLE_SOIL, 0x008B, 0, 6); + +STATE_DEFINE(dAcOmoleSoil_c, Wait); +STATE_DEFINE(dAcOmoleSoil_c, Appear); +STATE_DEFINE(dAcOmoleSoil_c, DisAppear); + +const f32 dAcOmoleSoil_c::sHalfScale = 0.5f; +const f32 dAcOmoleSoil_c::sFullScale = 1.0f; + +bool dAcOmoleSoil_c::createHeap() { + nw4r::g3d::ResFile file = getOarcResFile("MogumaMud"); + if (!file.mFile.IsValid()) { + return false; + } + mBrres = file; + nw4r::g3d::ResMdl mdl = mBrres.GetResMdl("MogumaMud"); + // This whole code is a bit weird again + bool success1 = mModel.create(mdl, &heap_allocator, 0x120, 1, nullptr); + if (!success1) { + return success1; + } + mModel.setPriorityDraw(0x1c, 9); + return true; +} + +bool intToBool(int a) { + return a; +} + +int dAcOmoleSoil_c::create() { + if (!initAllocatorWork1Heap(-1, "dAcOmoleSoil_c::m_allocator", 0x20)) { + return 2; + } + + mScale = sHalfScale; + scale.set(sHalfScale, sHalfScale, sHalfScale); + mStateMgr.changeState(StateID_Wait); + + setBoundingBox(mVec3_c(-100.0f, -0.0f, -100.0f), mVec3_c(100.0f, 100.0f, 100.0f)); + return 1; +} + +int dAcOmoleSoil_c::doDelete() { + return 1; +} + +int dAcOmoleSoil_c::actorExecute() { + switch (getNextState()) { + case 1: + if (!mStateMgr.isState(StateID_Appear)) { + mStateMgr.changeState(StateID_Appear); + } + break; + case 2: + if (!mStateMgr.isState(StateID_DisAppear)) { + mStateMgr.changeState(StateID_DisAppear); + } + break; + case 3: + if (!mStateMgr.isState(StateID_Appear)) { + mStateMgr.changeState(StateID_Appear); + } + break; + } + mStateMgr.executeState(); + updateMatrix(); + mModel.setLocalMtx(worldMatrix); + return 1; +} + +int dAcOmoleSoil_c::draw() { + if (field_0x391) { + drawModelType1(&mModel); + } + return 1; +} + +// sLib::chase +extern "C" bool fn_802DECC0(f32 *, f32, f32); + +void dAcOmoleSoil_c::initializeState_Wait() { + mDesiredNextState = 0; +} +void dAcOmoleSoil_c::executeState_Wait() {} +void dAcOmoleSoil_c::finalizeState_Wait() {} + +void dAcOmoleSoil_c::initializeState_Appear() { + field_0x391 = true; +} +void dAcOmoleSoil_c::executeState_Appear() { + f32 stepSize = 0.05f; + if (fn_802DECC0(&mScale, sFullScale, stepSize)) { + mStateMgr.changeState(StateID_Wait); + } else { + mModel.setScale(mScale, mScale, mScale); + } +} +void dAcOmoleSoil_c::finalizeState_Appear() { + mDesiredNextState = 0; + mScale = sFullScale; + mModel.setScale(sFullScale, sFullScale, sFullScale); +} + +void dAcOmoleSoil_c::initializeState_DisAppear() { + field_0x391 = true; +} + +void dAcOmoleSoil_c::executeState_DisAppear() { + // Nothing about this makes sense but this creates the necessary casts + // and operations. Note that Ghidra constant-folds this despite + // all the stack operations for the cast. + int scalar = 0; + f32 stepSize = 0.01f * scalar + 0.05f; + if (fn_802DECC0(&mScale, sHalfScale, stepSize)) { + mStateMgr.changeState(StateID_Wait); + } else { + mModel.setScale(mScale, mScale, mScale); + } +} +void dAcOmoleSoil_c::finalizeState_DisAppear() { + mDesiredNextState = 0; + mScale = sHalfScale; + mModel.setScale(sHalfScale, sHalfScale, sHalfScale); +} diff --git a/src/REL/d/a/obj/d_a_obj_ring.cpp b/src/REL/d/a/obj/d_a_obj_ring.cpp index d489a287..1e279ee3 100644 --- a/src/REL/d/a/obj/d_a_obj_ring.cpp +++ b/src/REL/d/a/obj/d_a_obj_ring.cpp @@ -27,7 +27,7 @@ int dAcOring_c::create() { setBoundingBox(mVec3_c(-100.0f, -100.0f, -100.0f), mVec3_c(100.0f, 100.0f, 100.0f)); updateMatrix(); mModel.setScale(scale); - mModel.setLocalMtx(&worldMatrix.nw4rm); + mModel.setLocalMtx(worldMatrix); forwardAccel = -5.0f; forwardMaxSpeed = -40.0f; field_0x38C = dPlayer::LINK->position.y; @@ -45,7 +45,7 @@ int dAcOring_c::actorExecute() { position += velocity; position += posIncrements; updateMatrix(); - mModel.setLocalMtx(&worldMatrix.nw4rm); + mModel.setLocalMtx(worldMatrix); return 1; } diff --git a/src/REL/d/a/obj/d_a_obj_sun_light.cpp b/src/REL/d/a/obj/d_a_obj_sun_light.cpp index fb8eaf27..5de9958f 100644 --- a/src/REL/d/a/obj/d_a_obj_sun_light.cpp +++ b/src/REL/d/a/obj/d_a_obj_sun_light.cpp @@ -15,7 +15,7 @@ bool dAcOsunLight_c::createHeap() { fn_801B4320(&mBrres); nw4r::g3d::ResMdl mdl = mBrres.GetResMdl("StageF000Light"); // This whole code is a bit weird again - bool success1 = createModel(mdl); + bool success1 = mModel.create(mdl, &heap_allocator, 0x120); if (!success1) { return success1; } @@ -46,7 +46,7 @@ int dAcOsunLight_c::actorExecute() { mTexAnm.play(); } updateMatrix(); - mModel.setLocalMtx(&worldMatrix.nw4rm); + mModel.setLocalMtx(worldMatrix); return 1; } diff --git a/src/m/m3d/m_anmmatclr.cpp b/src/m/m3d/m_anmmatclr.cpp index dc741412..3b0d2706 100644 --- a/src/m/m3d/m_anmmatclr.cpp +++ b/src/m/m3d/m_anmmatclr.cpp @@ -173,7 +173,7 @@ void anmMatClr_c::setFrame(f32 f, s32 idx) { } f32 anmMatClr_c::getRate(s32 idx) const { - mpChildren[idx].getRate(); + return mpChildren[idx].getRate(); } void anmMatClr_c::setRate(f32 f, s32 idx) { diff --git a/src/s/s_StateID.cpp b/src/s/s_StateID.cpp index bf9100ec..c03ca5a7 100644 --- a/src/s/s_StateID.cpp +++ b/src/s/s_StateID.cpp @@ -25,11 +25,11 @@ bool sStateID_c::isEqual(const sStateIDIf_c &other) const { return number() == other.number(); } -bool sStateID_c::operator==(const sStateIDIf_c &other) const { +BOOL sStateID_c::operator==(const sStateIDIf_c &other) const { return isEqual(other); } -bool sStateID_c::operator!=(const sStateIDIf_c &other) const { +BOOL sStateID_c::operator!=(const sStateIDIf_c &other) const { return !isEqual(other); }