diff --git a/config/SOUE01/rels/d_a_obj_sun_lightNP/splits.txt b/config/SOUE01/rels/d_a_obj_sun_lightNP/splits.txt index b8d525de..676fd6be 100644 --- a/config/SOUE01/rels/d_a_obj_sun_lightNP/splits.txt +++ b/config/SOUE01/rels/d_a_obj_sun_lightNP/splits.txt @@ -17,3 +17,6 @@ REL/global_destructor_chain.c: REL/d/a/obj/d_a_obj_sun_light.cpp: .text start:0x000000F0 end:0x00000BD8 .ctors start:0x00000000 end:0x00000004 + .rodata start:0x00000000 end:0x00000014 + .data start:0x00000000 end:0x000001D8 + .bss start:0x00000008 end:0x00000048 diff --git a/config/SOUE01/rels/d_a_obj_sun_lightNP/symbols.txt b/config/SOUE01/rels/d_a_obj_sun_lightNP/symbols.txt index edc8d734..df8edfce 100644 --- a/config/SOUE01/rels/d_a_obj_sun_lightNP/symbols.txt +++ b/config/SOUE01/rels/d_a_obj_sun_lightNP/symbols.txt @@ -3,55 +3,55 @@ _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_434_F0 = .text:0x000000F0; // type:function size:0xEC -fn_434_1E0 = .text:0x000001E0; // type:function size:0x58 -fn_434_240 = .text:0x00000240; // type:function size:0x6C -fn_434_2B0 = .text:0x000002B0; // type:function size:0xA0 -fn_434_350 = .text:0x00000350; // type:function size:0xA4 -fn_434_400 = .text:0x00000400; // type:function size:0xE4 -fn_434_4F0 = .text:0x000004F0; // type:function size:0xE8 -fn_434_5E0 = .text:0x000005E0; // type:function size:0x10 -fn_434_5F0 = .text:0x000005F0; // type:function size:0x8 -fn_434_600 = .text:0x00000600; // type:function size:0x78 -fn_434_680 = .text:0x00000680; // type:function size:0x10 -fn_434_690 = .text:0x00000690; // type:function size:0x44 -fn_434_6E0 = .text:0x000006E0; // type:function size:0x4 -fn_434_6F0 = .text:0x000006F0; // type:function size:0x4 -fn_434_700 = .text:0x00000700; // type:function size:0x4 -fn_434_710 = .text:0x00000710; // type:function size:0x18 -fn_434_730 = .text:0x00000730; // type:function size:0xD8 -fn_434_810 = .text:0x00000810; // type:function size:0x10 -fn_434_820 = .text:0x00000820; // type:function size:0x60 -fn_434_880 = .text:0x00000880; // type:function size:0xC -fn_434_890 = .text:0x00000890; // type:function size:0x1C -fn_434_8B0 = .text:0x000008B0; // type:function size:0x1C -fn_434_8D0 = .text:0x000008D0; // type:function size:0x1C -fn_434_8F0 = .text:0x000008F0; // type:function size:0x10 -fn_434_900 = .text:0x00000900; // type:function size:0x10 -fn_434_910 = .text:0x00000910; // type:function size:0x10 -fn_434_920 = .text:0x00000920; // type:function size:0x10 -fn_434_930 = .text:0x00000930; // type:function size:0x10 -fn_434_940 = .text:0x00000940; // type:function size:0x10 -fn_434_950 = .text:0x00000950; // type:function size:0x30 -fn_434_980 = .text:0x00000980; // type:function size:0x30 -fn_434_9B0 = .text:0x000009B0; // type:function size:0x30 -fn_434_9E0 = .text:0x000009E0; // type:function size:0x10C -fn_434_AF0 = .text:0x00000AF0; // type:function size:0x58 -fn_434_B50 = .text:0x00000B50; // type:function size:0x88 +dAcOsunLight_c_classInit__Fv = .text:0x000000F0; // type:function size:0xEC +__dt__27sFState_c<14dAcOsunLight_c>Fv = .text:0x000001E0; // type:function size:0x58 +__dt__30sFStateFct_c<14dAcOsunLight_c>Fv = .text:0x00000240; // type:function size:0x6C +__dt__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002B0; // type:function size:0xA0 +__dt__53sFStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000350; // type:function size:0xA4 +createHeap__14dAcOsunLight_cFv = .text:0x00000400; // type:function size:0xE4 +create__14dAcOsunLight_cFv = .text:0x000004F0; // type:function size:0xE8 +changeState__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x000005E0; // type:function size:0x10 +doDelete__14dAcOsunLight_cFv = .text:0x000005F0; // type:function size:0x8 +actorExecute__14dAcOsunLight_cFv = .text:0x00000600; // type:function size:0x78 +executeState__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000680; // type:function size:0x10 +draw__14dAcOsunLight_cFv = .text:0x00000690; // type:function size:0x44 +initializeState_Wait__14dAcOsunLight_cFv = .text:0x000006E0; // type:function size:0x4 +executeState_Wait__14dAcOsunLight_cFv = .text:0x000006F0; // type:function size:0x4 +finalizeState_Wait__14dAcOsunLight_cFv = .text:0x00000700; // type:function size:0x4 +isDay__14dAcOsunLight_cFv = .text:0x00000710; // type:function size:0x18 +__dt__14dAcOsunLight_cFv = .text:0x00000730; // type:function size:0xD8 +getStateID__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000810; // type:function size:0x10 +build__30sFStateFct_c<14dAcOsunLight_c>FRC12sStateIDIf_c = .text:0x00000820; // type:function size:0x60 +dispose__30sFStateFct_c<14dAcOsunLight_c>FRP10sStateIf_c = .text:0x00000880; // type:function size:0xC +initialize__27sFState_c<14dAcOsunLight_c>Fv = .text:0x00000890; // type:function size:0x1C +execute__27sFState_c<14dAcOsunLight_c>Fv = .text:0x000008B0; // type:function size:0x1C +finalize__27sFState_c<14dAcOsunLight_c>Fv = .text:0x000008D0; // type:function size:0x1C +initializeState__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000008F0; // type:function size:0x10 +finalizeState__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000900; // type:function size:0x10 +refreshState__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000910; // type:function size:0x10 +getState__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000920; // type:function size:0x10 +getNewStateID__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000930; // type:function size:0x10 +getOldStateID__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000940; // type:function size:0x10 +finalizeState__29sFStateID_c<14dAcOsunLight_c>CFR14dAcOsunLight_c = .text:0x00000950; // type:function size:0x30 +executeState__29sFStateID_c<14dAcOsunLight_c>CFR14dAcOsunLight_c = .text:0x00000980; // type:function size:0x30 +initializeState__29sFStateID_c<14dAcOsunLight_c>CFR14dAcOsunLight_c = .text:0x000009B0; // type:function size:0x30 +__sinit_\d_a_obj_sun_light_cpp = .text:0x000009E0; // type:function size:0x10C scope:local +__dt__29sFStateID_c<14dAcOsunLight_c>Fv = .text:0x00000AF0; // type:function size:0x58 +isSameName__29sFStateID_c<14dAcOsunLight_c>CFPCc = .text:0x00000B50; // 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_434_rodata_0 = .rodata:0x00000000; // type:object size:0x14 data:float -lbl_434_data_0 = .data:0x00000000; // type:object size:0x10 data:4byte -lbl_434_data_10 = .data:0x00000010; // type:object size:0x10 data:string -lbl_434_data_20 = .data:0x00000020; // type:object size:0x10 -lbl_434_data_30 = .data:0x00000030; // type:object size:0x20 -lbl_434_data_50 = .data:0x00000050; // type:object size:0x80 -lbl_434_data_D0 = .data:0x000000D0; // type:object size:0x30 -lbl_434_data_100 = .data:0x00000100; // type:object size:0x30 -lbl_434_data_130 = .data:0x00000130; // type:object size:0x18 -lbl_434_data_148 = .data:0x00000148; // type:object size:0x5C -lbl_434_data_1A4 = .data:0x000001A4; // type:object size:0x34 +lbl_434_rodata_0 = .rodata:0x00000000; // type:object size:0x14 scope:local data:float +g_profile_OBJ_SUN_LIGHT = .data:0x00000000; // type:object size:0x10 data:4byte +lbl_434_data_10 = .data:0x00000010; // type:object size:0x10 scope:local data:string +lbl_434_data_20 = .data:0x00000020; // type:object size:0x10 scope:local +lbl_434_data_30 = .data:0x00000030; // type:object size:0x20 scope:local +__vt__14dAcOsunLight_c = .data:0x00000050; // type:object size:0x80 +__vt__53sFStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c> = .data:0x000000D0; // type:object size:0x30 +__vt__83sStateMgr_c<14dAcOsunLight_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000100; // type:object size:0x30 +__vt__30sFStateFct_c<14dAcOsunLight_c> = .data:0x00000130; // type:object size:0x14 +__vt__27sFState_c<14dAcOsunLight_c> = .data:0x00000148; // type:object size:0x18 +__vt__29sFStateID_c<14dAcOsunLight_c> = .data:0x000001A4; // type:object size:0x34 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global -lbl_434_bss_8 = .bss:0x00000008; // type:object size:0x10 -lbl_434_bss_18 = .bss:0x00000018; // type:object size:0x30 data:4byte +lbl_434_bss_8 = .bss:0x00000008; // type:object size:0x10 scope:local +StateID_Wait__14dAcOsunLight_c = .bss:0x00000018; // type:object size:0x30 data:4byte diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index fd32ee0d..5a0d51ce 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -17653,7 +17653,7 @@ fn_802EBE10 = .text:0x802EBE10; // type:function size:0x8 calc__Q23m3d9scnLeaf_cFb = .text:0x802EBE20; // type:function size:0x78 calcVtx__Q23m3d9scnLeaf_cFb = .text:0x802EBEA0; // type:function size:0x78 fn_802EBF20 = .text:0x802EBF20; // type:function size:0x84 -fn_802EBFB0 = .text:0x802EBFB0; // type:function size:0x48 +setPriorityDraw__Q23m3d9scnLeaf_cFii = .text:0x802EBFB0; // type:function size:0x48 fn_802EC000 = .text:0x802EC000; // type:function size:0x88 fn_802EC090 = .text:0x802EC090; // type:function size:0x7C fn_802EC110 = .text:0x802EC110; // type:function size:0x1E8 @@ -48783,7 +48783,7 @@ lbl_805B3760 = .bss:0x805B3760; // type:object size:0x80 lbl_805B37E0 = .bss:0x805B37E0; // type:object size:0xC lbl_805B37EC = .bss:0x805B37EC; // type:object size:0x40 data:4byte lbl_805B382C = .bss:0x805B382C; // type:object size:0x34 data:4byte -lbl_805B3860 = .bss:0x805B3860; // type:object size:0x2C data:4byte +sInstance__11SpawnStruct = .bss:0x805B3860; // type:object size:0x2C data:4byte lbl_805B388C = .bss:0x805B388C; // type:object size:0x2C data:byte lbl_805B38B8 = .bss:0x805B38B8; // type:object size:0x50 lbl_805B3908 = .bss:0x805B3908; // type:object size:0x40 data:4byte diff --git a/configure.py b/configure.py index 2f676909..ea8d8e70 100644 --- a/configure.py +++ b/configure.py @@ -960,7 +960,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Rel(NonMatching, "d_a_obj_stopper_rock", "REL/d/a/obj/d_a_obj_stopper_rock.cpp"), Rel(NonMatching, "d_a_obj_stopping_rope", "REL/d/a/obj/d_a_obj_stopping_rope.cpp"), Rel(NonMatching, "d_a_obj_stream_lava", "REL/d/a/obj/d_a_obj_stream_lava.cpp"), - Rel(NonMatching, "d_a_obj_sun_light", "REL/d/a/obj/d_a_obj_sun_light.cpp"), + Rel(Matching, "d_a_obj_sun_light", "REL/d/a/obj/d_a_obj_sun_light.cpp"), Rel(NonMatching, "d_a_obj_swhit", "REL/d/a/obj/d_a_obj_swhit.cpp"), Rel(NonMatching, "d_a_obj_switch_shutter", "REL/d/a/obj/d_a_obj_switch_shutter.cpp"), Rel(NonMatching, "d_a_obj_switch_wall", "REL/d/a/obj/d_a_obj_switch_wall.cpp"), diff --git a/include/d/a/obj/d_a_obj_ring.h b/include/d/a/obj/d_a_obj_ring.h index fcc63e31..5b5b69e7 100644 --- a/include/d/a/obj/d_a_obj_ring.h +++ b/include/d/a/obj/d_a_obj_ring.h @@ -1,5 +1,5 @@ -#ifndef D_A_OBJ_RING -#define D_A_OBJ_RING +#ifndef D_A_OBJ_RING_H +#define D_A_OBJ_RING_H #include #include diff --git a/include/d/a/obj/d_a_obj_sun_light.h b/include/d/a/obj/d_a_obj_sun_light.h new file mode 100644 index 00000000..38756d16 --- /dev/null +++ b/include/d/a/obj/d_a_obj_sun_light.h @@ -0,0 +1,36 @@ +#ifndef D_A_OBJ_SUN_LIGHT_H +#define D_A_OBJ_SUN_LIGHT_H + +#include +#include +#include +#include +#include + +class dAcOsunLight_c : public dAcObjBase_c { +public: + dAcOsunLight_c() : mStateMgr(*this, sStateID::null) {} + virtual ~dAcOsunLight_c() {} + virtual bool createHeap() override; + virtual int create() override; + virtual int actorExecute() override; + 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); + +private: + nw4r::g3d::ResFile mBrres; + m3d::smdl_c mModel; + STATE_MGR_DECLARE(dAcOsunLight_c); + m3d::anmTexSrt_c mTexAnm; +}; + +#endif diff --git a/include/m/m3d/m_anmtexsrt.h b/include/m/m3d/m_anmtexsrt.h index 8441d0ea..f6da84f8 100644 --- a/include/m/m3d/m_anmtexsrt.h +++ b/include/m/m3d/m_anmtexsrt.h @@ -22,7 +22,7 @@ class anmTexSrt_c : public banm_c { }; public: - anmTexSrt_c() {} + anmTexSrt_c(): mpChildren(nullptr) {} virtual ~anmTexSrt_c(); virtual int getType() override; diff --git a/include/m/m3d/m_scnleaf.h b/include/m/m3d/m_scnleaf.h index 32f63565..ab2ce20d 100644 --- a/include/m/m3d/m_scnleaf.h +++ b/include/m/m3d/m_scnleaf.h @@ -20,7 +20,7 @@ class scnLeaf_c : UnkClass, EGG::Disposer { virtual void remove(); virtual int entry(); - void setOption(unsigned long flag, unsigned long set); + void setOption(u32 flag, u32 set); void setScale(f32, f32, f32); void setScale(const nw4r::math::VEC3 &); @@ -32,6 +32,8 @@ class scnLeaf_c : UnkClass, EGG::Disposer { void calc(bool); void calcVtx(bool); + void setPriorityDraw(int, int); + protected: nw4r::g3d::ScnLeaf *mpScnLeaf; }; diff --git a/include/nw4r/g3d/g3d_resfile.h b/include/nw4r/g3d/g3d_resfile.h index c5dc7fea..9a8c51cd 100644 --- a/include/nw4r/g3d/g3d_resfile.h +++ b/include/nw4r/g3d/g3d_resfile.h @@ -18,6 +18,9 @@ struct ResFileData { struct ResFile { ResCommon mFile; // at 0x0 + ResFile(): mFile((void*)nullptr) {} + ResFile(void *ptr): mFile(ptr) {} + inline ResFileData &ref() const { return mFile.ref(); } diff --git a/include/toBeSorted/arc_managers/current_stage_arc_manager.h b/include/toBeSorted/arc_managers/current_stage_arc_manager.h index f4f11ce5..26194c8d 100644 --- a/include/toBeSorted/arc_managers/current_stage_arc_manager.h +++ b/include/toBeSorted/arc_managers/current_stage_arc_manager.h @@ -6,15 +6,10 @@ #include class CurrentStageArcManager { +public: CurrentStageArcManager(); virtual ~CurrentStageArcManager(); - SizedString<32> mStageName; - SizedString<32> mCurrentLoadingStageArcName; - SizedString<32> mStageExtraLayerArcName; - - dRawArcTable_c mArcTable; - static CurrentStageArcManager *sInstance; static bool create(EGG::Heap *heap); @@ -36,6 +31,13 @@ class CurrentStageArcManager { const char *getRoomArcDirectory(int room) const; static EGG::ExpHeap *getHeap(); + +private: + SizedString<32> mStageName; + SizedString<32> mCurrentLoadingStageArcName; + SizedString<32> mStageExtraLayerArcName; + + dRawArcTable_c mArcTable; }; #endif diff --git a/include/toBeSorted/spawn_struct.h b/include/toBeSorted/spawn_struct.h new file mode 100644 index 00000000..8bad4516 --- /dev/null +++ b/include/toBeSorted/spawn_struct.h @@ -0,0 +1,20 @@ +#ifndef SPAWN_STRUCT_H +#define SPAWN_STRUCT_H + +#include + +struct SpawnStruct { + /* 0x00 */ char mName[32]; // Could be SizedString<32> + /* 0x20 */ u16 mTransitionFadeFrames; + /* 0x22 */ s8 mRoom; + /* 0x23 */ s8 mLayer; + /* 0x24 */ s8 mEntrance; + /* 0x25 */ bool mNight; + /* 0x26 */ bool mTrial; + /* 0x27 */ bool mTransitionType; + /* 0x28 */ u8 UNK_0x28[0x2C - 0x28]; + + static SpawnStruct sInstance; +}; + +#endif 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 e69de29b..7f03ecfe 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 @@ -0,0 +1,69 @@ +#include +#include +#include + +SPECIAL_ACTOR_PROFILE(OBJ_SUN_LIGHT, dAcOsunLight_c, fProfile::OBJ_SUN_LIGHT, 0x0219, 0, 3); + +STATE_DEFINE(dAcOsunLight_c, Wait); + +extern "C" void fn_801B42D0(nw4r::g3d::ResFile *); +extern "C" void fn_801B4320(nw4r::g3d::ResFile *); + +bool dAcOsunLight_c::createHeap() { + // TODO stack order shuffle + mBrres = CurrentStageArcManager::sInstance->getData("g3d/stage.brres"); + fn_801B42D0(&mBrres); + fn_801B4320(&mBrres); + nw4r::g3d::ResMdl mdl = mBrres.GetResMdl("StageF000Light"); + // This whole code is a bit weird again + bool success1 = createModel(mdl); + if (!success1) { + return success1; + } + nw4r::g3d::ResAnmTexSrt srt = mBrres.GetResAnmTexSrt("StageF000Light"); + bool success2 = mTexAnm.create(mdl, srt, &heap_allocator, nullptr, 1); + return success2 ? true : success2; +} + +int dAcOsunLight_c::create() { + if (!initAllocatorWork1Heap(-1, "dAcOsunLight_c::m_allocator", 0x20)) { + return 2; + } + + mModel.setAnm(mTexAnm); + mStateMgr.changeState(StateID_Wait); + mModel.setPriorityDraw(0x1C, 9); + setBoundingBox(mVec3_c(-200.0f, -100.0f, -200.0f), mVec3_c(200.0f, 600.0f, 500.0f)); + return 1; +} + +int dAcOsunLight_c::doDelete() { + return 1; +} + +int dAcOsunLight_c::actorExecute() { + mStateMgr.executeState(); + if (isDay()) { + mTexAnm.play(); + } + updateMatrix(); + mModel.setLocalMtx(&worldMatrix.nw4rm); + return 1; +} + +int dAcOsunLight_c::draw() { + if (isDay()) { + drawModelType1(&mModel); + } + return 1; +} + +void dAcOsunLight_c::initializeState_Wait() {} + +void dAcOsunLight_c::executeState_Wait() {} + +void dAcOsunLight_c::finalizeState_Wait() {} + +bool dAcOsunLight_c::isDay() { + return !SpawnStruct::sInstance.mNight; +}