From b1f2d817a4c54c99dc5a4ec7600486f2475fa969 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 27 Feb 2025 11:38:11 +0100 Subject: [PATCH 1/2] Halfway there --- .../rels/d_a_obj_dungeon_shipNP/splits.txt | 3 + .../rels/d_a_obj_dungeon_shipNP/symbols.txt | 66 ++- config/SOUE01/symbols.txt | 18 +- include/d/a/obj/d_a_obj_dungeon_ship.h | 76 ++- include/d/col/cc/d_cc_d.h | 1 + include/m/m3d/m_anmmatclr.h | 5 + include/toBeSorted/actor_event.h | 4 + include/toBeSorted/actor_on_rail.h | 40 ++ include/toBeSorted/time_proc.h | 45 ++ src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp | 436 +++++++++++++++++- 10 files changed, 639 insertions(+), 55 deletions(-) create mode 100644 include/toBeSorted/time_proc.h diff --git a/config/SOUE01/rels/d_a_obj_dungeon_shipNP/splits.txt b/config/SOUE01/rels/d_a_obj_dungeon_shipNP/splits.txt index b0ea1ee4..92051e2b 100644 --- a/config/SOUE01/rels/d_a_obj_dungeon_shipNP/splits.txt +++ b/config/SOUE01/rels/d_a_obj_dungeon_shipNP/splits.txt @@ -17,3 +17,6 @@ REL/global_destructor_chain.c: REL/d/a/obj/d_a_obj_dungeon_ship.cpp: .text start:0x000000F0 end:0x00002828 .ctors start:0x00000000 end:0x00000004 + .rodata start:0x00000000 end:0x000000C4 + .data start:0x00000000 end:0x00000388 + .bss start:0x00000008 end:0x00000148 diff --git a/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt b/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt index 2780dbf1..86d5c646 100644 --- a/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt +++ b/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt @@ -10,17 +10,15 @@ __dt__30sFState_c<17dAcODungeonShip_c>Fv = .text:0x00000360; // type:function si __dt__33sFStateFct_c<17dAcODungeonShip_c>Fv = .text:0x000003C0; // type:function size:0x6C __dt__86sStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000430; // type:function size:0xA0 __dt__56sFStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c>Fv = .text:0x000004D0; // type:function size:0xA4 -AcODungeonShip__eventIn = .text:0x00000580; // type:function size:0xC -fn_485_58C = .text:0x0000058C; // type:function size:0x4 -AcODungeonShip__eventEnd = .text:0x00000590; // type:function size:0xC -fn_485_59C = .text:0x0000059C; // type:function size:0x4 -AcODungeonShip__initModels = .text:0x000005A0; // type:function size:0x208 -AcODungeonShip__init = .text:0x000007B0; // type:function size:0x2B8 +eventIn_Wrapper__17dAcODungeonShip_cFPv = .text:0x00000580; // type:function size:0x10 +eventEnd_Wrapper__17dAcODungeonShip_cFPv = .text:0x00000590; // type:function size:0x10 +createHeap__17dAcODungeonShip_cFv = .text:0x000005A0; // type:function size:0x208 +create__17dAcODungeonShip_cFv = .text:0x000007B0; // type:function size:0x2B8 changeState__86sStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000A70; // type:function size:0x10 -AcODungeonShip__destroy = .text:0x00000A80; // type:function size:0x34 -AcODungeonShip__update = .text:0x00000AC0; // type:function size:0x268 +doDelete__17dAcODungeonShip_cFv = .text:0x00000A80; // type:function size:0x34 +actorExecute__17dAcODungeonShip_cFv = .text:0x00000AC0; // type:function size:0x268 executeState__86sStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000D30; // type:function size:0x10 -AcODungeonShip__draw = .text:0x00000D40; // type:function size:0x38 +draw__17dAcODungeonShip_cFv = .text:0x00000D40; // type:function size:0x38 initializeState_Wait__17dAcODungeonShip_cFv = .text:0x00000D80; // type:function size:0x4 executeState_Wait__17dAcODungeonShip_cFv = .text:0x00000D90; // type:function size:0xCC finalizeState_Wait__17dAcODungeonShip_cFv = .text:0x00000E60; // type:function size:0x4 @@ -31,28 +29,26 @@ initializeState_AppearEvent__17dAcODungeonShip_cFv = .text:0x000011E0; // type:f executeState_AppearEvent__17dAcODungeonShip_cFv = .text:0x00001260; // type:function size:0x31C finalizeState_AppearEvent__17dAcODungeonShip_cFv = .text:0x00001580; // type:function size:0x4 initializeState_Appear__17dAcODungeonShip_cFv = .text:0x00001590; // type:function size:0xC -executeState_Appear__17dAcODungeonShip_cFv = .text:0x000015A0; // type:function size:0x10 -fn_485_15B0 = .text:0x000015B0; // type:function size:0x4 +executeState_Appear__17dAcODungeonShip_cFv = .text:0x000015A0; // type:function size:0x14 finalizeState_Appear__17dAcODungeonShip_cFv = .text:0x000015C0; // type:function size:0x4 initializeState_End__17dAcODungeonShip_cFv = .text:0x000015D0; // type:function size:0xC -executeState_End__17dAcODungeonShip_cFv = .text:0x000015E0; // type:function size:0x10 -fn_485_15F0 = .text:0x000015F0; // type:function size:0x4 +executeState_End__17dAcODungeonShip_cFv = .text:0x000015E0; // type:function size:0x14 finalizeState_End__17dAcODungeonShip_cFv = .text:0x00001600; // type:function size:0x4 -fn_485_1610 = .text:0x00001610; // type:function size:0x4 -fn_485_1620 = .text:0x00001620; // type:function size:0x3C -fn_485_1660 = .text:0x00001660; // type:function size:0xB4 -fn_485_1720 = .text:0x00001720; // type:function size:0x110 +eventIn__17dAcODungeonShip_cFv = .text:0x00001610; // type:function size:0x4 +eventEnd__17dAcODungeonShip_cFv = .text:0x00001620; // type:function size:0x3C +fn_485_1660__17dAcODungeonShip_cFv = .text:0x00001660; // type:function size:0xB4 +fn_485_1720__17dAcODungeonShip_cFv = .text:0x00001720; // type:function size:0x110 fn_485_1830 = .text:0x00001830; // type:function size:0xC8 -fn_485_1900 = .text:0x00001900; // type:function size:0x58 +fn_485_1900__17dAcODungeonShip_cFv = .text:0x00001900; // type:function size:0x58 fn_485_1960 = .text:0x00001960; // type:function size:0xE8 fn_485_1A50 = .text:0x00001A50; // type:function size:0xC fn_485_1A60 = .text:0x00001A60; // type:function size:0xC fn_485_1A70 = .text:0x00001A70; // type:function size:0x18 -fn_485_1A90 = .text:0x00001A90; // type:function size:0x154 -fn_485_1BF0 = .text:0x00001BF0; // type:function size:0x200 -fn_485_1DF0 = .text:0x00001DF0; // type:function size:0xA0 -AcODungeonShip__updateMatrixAndScale = .text:0x00001E90; // type:function size:0x44 -fn_485_1EE0 = .text:0x00001EE0; // type:function size:0xE0 +fn_485_1A90__17dAcODungeonShip_cFv = .text:0x00001A90; // type:function size:0x154 +fn_485_1BF0__17dAcODungeonShip_cFv = .text:0x00001BF0; // type:function size:0x200 +fn_485_1DF0__17dAcODungeonShip_cFv = .text:0x00001DF0; // type:function size:0xA0 +updateMatrixAndScale__17dAcODungeonShip_cFv = .text:0x00001E90; // type:function size:0x44 +fn_485_1EE0__17dAcODungeonShip_cFv = .text:0x00001EE0; // type:function size:0xE0 __dt__17dAcODungeonShip_cFv = .text:0x00001FC0; // type:function size:0x154 getStateID__86sStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00002120; // type:function size:0x10 fn_485_2130 = .text:0x00002130; // type:function size:0x4 @@ -89,22 +85,22 @@ lbl_485_rodata_88 = .rodata:0x00000088; // type:object size:0x14 data:float lbl_485_rodata_9C = .rodata:0x0000009C; // type:object size:0x14 data:float lbl_485_rodata_B0 = .rodata:0x000000B0; // type:object size:0x8 data:float lbl_485_rodata_B8 = .rodata:0x000000B8; // type:object size:0xC data:float -g_profile_OBJ_DUNGEON_SHIP = .data:0x00000000; // type:object size:0x3C data:4byte +g_profile_OBJ_DUNGEON_SHIP = .data:0x00000000; // type:object size:0x10 data:4byte lbl_485_data_3C = .data:0x0000003C; // type:object size:0xC data:string lbl_485_data_48 = .data:0x00000048; // type:object size:0x34 lbl_485_data_7C = .data:0x0000007C; // type:object size:0x4 data:4byte lbl_485_data_80 = .data:0x00000080; // type:object size:0x4 data:4byte lbl_485_data_84 = .data:0x00000084; // type:object size:0x4 data:4byte -AcODungeonShip__vtable = .data:0x00000088; // type:object size:0x80 -lbl_485_data_108 = .data:0x00000108; // type:object size:0x30 -lbl_485_data_138 = .data:0x00000138; // type:object size:0x30 -lbl_485_data_168 = .data:0x00000168; // type:object size:0x18 -lbl_485_data_180 = .data:0x00000180; // type:object size:0x1D4 -lbl_485_data_354 = .data:0x00000354; // type:object size:0x34 +__vt__17dAcODungeonShip_c = .data:0x00000088; // type:object size:0x80 +__vt__56sFStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c> = .data:0x00000108; // type:object size:0x30 +__vt__86sStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000138; // type:object size:0x30 +__vt__33sFStateFct_c<17dAcODungeonShip_c> = .data:0x00000168; // type:object size:0x14 +__vt__30sFState_c<17dAcODungeonShip_c> = .data:0x00000180; // type:object size:0x18 +__vt__32sFStateID_c<17dAcODungeonShip_c> = .data:0x00000354; // type:object size:0x34 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global lbl_485_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte -AcODungeonShip__STATE_WAIT = .bss:0x00000018; // type:object size:0x40 data:4byte -AcODungeonShip__STATE_TRANSPARENCY = .bss:0x00000058; // type:object size:0x40 data:4byte -AcODungeonShip__STATE_APPEAR_EVENT = .bss:0x00000098; // type:object size:0x40 data:4byte -AcODungeonShip__STATE_APPEAR = .bss:0x000000D8; // type:object size:0x40 data:4byte -AcODungeonShip__STATE_END = .bss:0x00000118; // type:object size:0x30 data:4byte +StateID_Wait__17dAcODungeonShip_c = .bss:0x00000018; // type:object size:0x30 data:4byte +StateID_Transparency__17dAcODungeonShip_c = .bss:0x00000058; // type:object size:0x30 data:4byte +StateID_AppearEvent__17dAcODungeonShip_c = .bss:0x00000098; // type:object size:0x30 data:4byte +StateID_Appear__17dAcODungeonShip_c = .bss:0x000000D8; // type:object size:0x30 data:4byte +StateID_End__17dAcODungeonShip_c = .bss:0x00000118; // type:object size:0x30 data:4byte diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index a2dc7796..c9520e1a 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3527,8 +3527,8 @@ isAdvance__17ActorEventRelatedFv = .text:0x8009D020; // type:function size:0x34 advanceNext__17ActorEventRelatedFv = .text:0x8009D060; // type:function size:0x50 ActorEventRelated__getSingleIntData2 = .text:0x8009D0B0; // type:function size:0x8C ActorEventRelated__getSingleIntData = .text:0x8009D140; // type:function size:0x8C -ActorEventRelated__getSingleFloatData = .text:0x8009D1D0; // type:function size:0x8C -ActorEventRelated__getSingleVec3f = .text:0x8009D260; // type:function size:0x9C +getSingleFloatData__17ActorEventRelatedFPfUlUl = .text:0x8009D1D0; // type:function size:0x8C +getSingleVecData__17ActorEventRelatedFP7mVec3_cUlUl = .text:0x8009D260; // type:function size:0x9C ActorEventRelated__getIntDataWithDefault = .text:0x8009D300; // type:function size:0x98 ActorEventRelated__getSingleIntDataWithDefault = .text:0x8009D3A0; // type:function size:0x98 ActorEventRelated__getFloatDataWithDefault = .text:0x8009D440; // type:function size:0x98 @@ -3710,9 +3710,9 @@ SpecialActorOnRail__moveToTargetMaybe = .text:0x800A91E0; // type:function size: fn_800A9370 = .text:0x800A9370; // type:function size:0x6C fn_800A93E0 = .text:0x800A93E0; // type:function size:0x90 fn_800A9470 = .text:0x800A9470; // type:function size:0x74 -ActorOnRail2__ctor = .text:0x800A94F0; // type:function size:0x60 -ActorOnRail__dtor2 = .text:0x800A9550; // type:function size:0x58 -ActorOnRail2__initWithSegment = .text:0x800A95B0; // type:function size:0x9C +__ct__15ActorOnRail_ExtFv = .text:0x800A94F0; // type:function size:0x60 +__dt__15ActorOnRail_ExtFv = .text:0x800A9550; // type:function size:0x58 +initExt__15ActorOnRail_ExtFiiiiifff = .text:0x800A95B0; // type:function size:0x9C fn_800A9650 = .text:0x800A9650; // type:function size:0x208 fn_800A9860 = .text:0x800A9860; // type:function size:0x50 fn_800A98B0 = .text:0x800A98B0; // type:function size:0x58 @@ -3720,7 +3720,7 @@ fn_800A9910 = .text:0x800A9910; // type:function size:0x48 fn_800A9960 = .text:0x800A9960; // type:function size:0x8 fn_800A9970 = .text:0x800A9970; // type:function size:0x58 fn_800A99D0 = .text:0x800A99D0; // type:function size:0xE0 -ActorOnRail2__setSegment = .text:0x800A9AB0; // type:function size:0x50 +setSegment__15ActorOnRail_ExtFUsf = .text:0x800A9AB0; // type:function size:0x50 checkPosInAREA = .text:0x800A9B00; // type:function size:0xC4 getAreaForIndexInRoom__Fll = .text:0x800A9BD0; // type:function size:0x78 checkPosInArea__FllRC7mVec3_cPCP4AREA = .text:0x800A9C50; // type:function size:0xD4 @@ -29889,7 +29889,11 @@ lbl_80500B60 = .data:0x80500B60; // type:object size:0x40 lbl_80500BA0 = .data:0x80500BA0; // type:object size:0x30 lbl_80500BD0 = .data:0x80500BD0; // type:object size:0x48 data:4byte lbl_80500C18 = .data:0x80500C18; // type:object size:0xC -lbl_80500C24 = .data:0x80500C24; // type:object size:0xB4 +lbl_80500C24 = .data:0x80500C24; // type:object size:0xC +lbl_80500C30 = .data:0x80500C30; // type:object size:0x2C +__vt__15MdlWithTimeProc = .data:0x80500C5C; // type:object size:0x2C +__vt__8TimeProc = .data:0x80500C88; // type:object size:0x2C +__vt__14TimeCallback_c = .data:0x80500CB8; // type:object size:0x20 lbl_80500CD8 = .data:0x80500CD8; // type:object size:0x70 lbl_80500D48 = .data:0x80500D48; // type:object size:0x78 lbl_80500DC0 = .data:0x80500DC0; // type:object size:0x70 diff --git a/include/d/a/obj/d_a_obj_dungeon_ship.h b/include/d/a/obj/d_a_obj_dungeon_ship.h index edf93860..4ef14bd3 100644 --- a/include/d/a/obj/d_a_obj_dungeon_ship.h +++ b/include/d/a/obj/d_a_obj_dungeon_ship.h @@ -1,15 +1,33 @@ #ifndef D_A_OBJ_DUNGEON_SHIP_H #define D_A_OBJ_DUNGEON_SHIP_H +#include "common.h" #include "d/a/obj/d_a_obj_base.h" +#include "d/col/bg/d_bg_w.h" +#include "d/col/cc/d_cc_d.h" +#include "m/m3d/m_anmchr.h" +#include "m/m3d/m_anmmatclr.h" +#include "m/m_vec.h" +#include "nw4r/g3d/res/g3d_resfile.h" #include "s/s_State.hpp" -#include "s/s_StateMgr.hpp" +#include "toBeSorted/actor_event.h" +#include "toBeSorted/actor_on_rail.h" +#include "toBeSorted/dowsing_target.h" +#include "toBeSorted/effects_struct.h" +#include "toBeSorted/time_proc.h" class dAcODungeonShip_c : public dAcObjBase_c { public: - dAcODungeonShip_c() : mStateMgr(*this, sStateID::null) {} + dAcODungeonShip_c() + : mStateMgr(*this, sStateID::null), mDowsingTarget(this, DowsingTarget::SLOT_NONE), mEvent(*this, nullptr) {} virtual ~dAcODungeonShip_c() {} + virtual bool createHeap() override; + virtual int create() override; + virtual int draw() override; + virtual int doDelete() override; + virtual int actorExecute() override; + STATE_FUNC_DECLARE(dAcODungeonShip_c, Wait); STATE_FUNC_DECLARE(dAcODungeonShip_c, Transparency); STATE_FUNC_DECLARE(dAcODungeonShip_c, AppearEvent); @@ -17,7 +35,59 @@ public: STATE_FUNC_DECLARE(dAcODungeonShip_c, End); private: - /* 0x??? */ STATE_MGR_DECLARE(dAcODungeonShip_c); + static const f32 someFloats[18]; + + void updateMatrixAndScale(); + + void fn_485_1660(); + void fn_485_1720(); + u32 fn_485_1900(); + u32 fn_485_1960(); + void fn_485_1A90(); + void fn_485_1BF0(); + void fn_485_1DF0(); + void fn_485_1EE0(); + + static void eventIn_Wrapper(void *arg); + void eventIn(); + static void eventEnd_Wrapper(void *arg); + void eventEnd(); + + static dCcD_SrcCps sCcSrc; + + /* 0x300 */ nw4r::g3d::ResFile mRes; + /* 0x334 */ MdlWithTimeProc mMdl; + + /* 0x374 */ m3d::anmChr_c mAnmChr; + /* 0x3AC */ m3d::anmMatClr_c mAnmMatClr; + /* 0x3D8 */ dBgW mBg; + /* 0x5E8 */ dCcD_Cps mCc; + /* 0x758 */ STATE_MGR_DECLARE(dAcODungeonShip_c); + /* 0x794 */ DowsingTarget mDowsingTarget; + /* 0x7B4 */ mVec3_c mDowsingOffset; + /* 0x7C0 */ u8 mIsRoaming; + /* 0x7C4 */ ActorOnRail_Ext mPath; + /* 0x7F8 */ ActorEventRelated mEvent; + /* 0x848 */ u8 mAppearEventFromParam; + /* 0x849 */ u8 field_0x849; + /* 0x84A */ u8 mAppearEvent; + /* 0x84B */ u8 mPathIdx; + /* 0x84C */ u8 field_0x84C[0x850 - 0x84C]; + /* 0x850 */ u32 field_0x850; + /* 0x854 */ u8 mNumTimesHit; + /* 0x855 */ u8 field_0x855; + /* 0x856 */ s8 field_0x856; + /* 0x858 */ f32 field_0x858; + /* 0x862 */ u8 field_0x862; + /* 0x863 */ u8 field_0x863; + /* 0x864 */ u8 field_0x864; + /* 0x865 */ u8 mIsDocked; + /* 0x868 */ s32 field_0x868; + /* 0x86C */ u32 field_0x86C; + /* 0x870 */ EffectsStruct mEffects[2]; + /* 0x8D8 */ u8 field_0x8D8; + /* 0x8D9 */ u8 field_0x8D9; + /* 0x8DA */ u8 field_0x8DA; }; #endif diff --git a/include/d/col/cc/d_cc_d.h b/include/d/col/cc/d_cc_d.h index 3c5bc793..a99588f9 100644 --- a/include/d/col/cc/d_cc_d.h +++ b/include/d/col/cc/d_cc_d.h @@ -18,6 +18,7 @@ public: virtual cCcD_ShapeAttr *GetShapeAttr() override; + using cM3dGCps::Set; void Set(const dCcD_SrcCps &src); void unknownCalc(); }; diff --git a/include/m/m3d/m_anmmatclr.h b/include/m/m3d/m_anmmatclr.h index 819e3ba2..071d983c 100644 --- a/include/m/m3d/m_anmmatclr.h +++ b/include/m/m3d/m_anmmatclr.h @@ -4,6 +4,7 @@ #include "m/m3d/m_bmdl.h" #include "m/m3d/m_fanm.h" #include "nw4r/g3d/g3d_anmclr.h" +#include "nw4r/g3d/g3d_scnobj.h" namespace m3d { @@ -48,6 +49,10 @@ public: void setFrameStart(f32, s32); f32 getFrameStart(s32) const; + nw4r::g3d::AnmObjMatClrRes *getChild(s32 idx) { + return nw4r::g3d::ScnObj::DynamicCast(mpChildren[idx].getAnimObj()); + } + private: child_c *mpChildren; }; diff --git a/include/toBeSorted/actor_event.h b/include/toBeSorted/actor_event.h index b9844625..5a691f53 100644 --- a/include/toBeSorted/actor_event.h +++ b/include/toBeSorted/actor_event.h @@ -3,6 +3,7 @@ #include "common.h" #include "d/a/d_a_base.h" +#include "m/m_vec.h" #include "toBeSorted/event.h" class ActorEventRelated { @@ -16,6 +17,9 @@ public: void advanceNext(); bool isAdvance(); + int getSingleFloatData(f32 *result, u32 code, u32); + int getSingleVecData(mVec3_c *result, u32 code, u32); + private: u8 field_0x00[0x50 - 0x00]; }; diff --git a/include/toBeSorted/actor_on_rail.h b/include/toBeSorted/actor_on_rail.h index 91a78daa..5243be9b 100644 --- a/include/toBeSorted/actor_on_rail.h +++ b/include/toBeSorted/actor_on_rail.h @@ -2,6 +2,7 @@ #define ACTOR_ON_RAIL_H #include "common.h" +#include "m/m_vec.h" class ActorOnRail { private: @@ -21,4 +22,43 @@ public: mVec3_c *getPntPosForIndex(int index); }; +class ActorOnRail_Ext : public ActorOnRail { +public: + ActorOnRail_Ext(); + virtual ~ActorOnRail_Ext(); + + void setSegment(u16 segmentIndex, f32 segmentFraction); + bool initExt(int pathIndex, int roomId, int, int pathSegment, int pathSubtype, f32, f32, f32); + + f32 getSegmentFraction() const { + return mSegmentFraction; + } + + bool CheckFlag(u32 flag) const { + return (field_0x1C & flag) != 0; + } + + void ClearFlag(u32 flag) { + field_0x1C &= ~flag; + } + + void SetFlag(u32 flag) { + field_0x1C |= flag; + } + + const mVec3_c &getPosition() const { + return mPosition; + } + + +private: + s32 mSegmentIndex; + f32 mSegmentFraction; + UNKWORD field_0x18; + u32 field_0x1C; + f32 field_0x20; + UNKWORD field_0x24; + mVec3_c mPosition; +}; + #endif diff --git a/include/toBeSorted/time_proc.h b/include/toBeSorted/time_proc.h new file mode 100644 index 00000000..cab1a7cd --- /dev/null +++ b/include/toBeSorted/time_proc.h @@ -0,0 +1,45 @@ +#ifndef TIME_PROC_H +#define TIME_PROC_H + +/** + * A callback implementation that controls ??? + */ + +#include "m/m3d/m_proc.h" +#include "m/m3d/m_smdl.h" +#include "nw4r/g3d/g3d_scnobj.h" + +class TimeCallback_c : public nw4r::g3d::IScnObjCallback { +public: + TimeCallback_c() : field_0x04(0), field_0x08(0), field_0x09(0) {} + virtual ~TimeCallback_c() {} + virtual void ExecCallback_CALC_VIEW( + nw4r::g3d::ScnObj::Timing /* timing */, nw4r::g3d::ScnObj * /* pObj */, u32 /* param */, void * /* pInfo */ + ) override; + + /* 0x04 */ u32 field_0x04; + /* 0x08 */ u8 field_0x08; + /* 0x09 */ u8 field_0x09; +}; + +class TimeProcBase : public m3d::proc_c { +public: + virtual ~TimeProcBase() {} +}; + +class TimeProc : public TimeProcBase { +public: + TimeProc() {} + virtual ~TimeProc() {} + + TimeCallback_c mCallback; +}; + +class MdlWithTimeProc : public m3d::smdl_c { +public: + int fn_8001F3B0(nw4r::g3d::ResMdl mdl, mAllocator_c *alloc, u32 bufferOption); + + TimeProc mProc; +}; + +#endif // TIME_PROC_H diff --git a/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp b/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp index b88b3bb7..4eec74a3 100644 --- a/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp +++ b/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp @@ -1,25 +1,441 @@ #include "d/a/obj/d_a_obj_dungeon_ship.h" +#include "common.h" +#include "d/a/d_a_player.h" +#include "d/col/bg/d_bg_s.h" +#include "d/col/cc/d_cc_s.h" +#include "d/flag/sceneflag_manager.h" +#include "d/flag/storyflag_manager.h" +#include "f/f_base.h" +#include "m/m3d/m_fanm.h" +#include "m/m_mtx.h" +#include "m/m_vec.h" +#include "nw4r/g3d/g3d_anmclr.h" +#include "nw4r/g3d/res/g3d_resanmchr.h" +#include "nw4r/g3d/res/g3d_resanmclr.h" +#include "nw4r/g3d/res/g3d_resfile.h" +#include "nw4r/g3d/res/g3d_resmdl.h" +#include "s/s_Math.h" +#include "toBeSorted/dowsing_target.h" +#include "toBeSorted/event.h" + SPECIAL_ACTOR_PROFILE(OBJ_DUNGEON_SHIP, dAcODungeonShip_c, fProfile::OBJ_DUNGEON_SHIP, 0x17B, 0, 3); +dCcD_SrcCps dAcODungeonShip_c::sCcSrc = { + { + + {0, 0x1003E, {0, 0, 0}, 0, 0, 0, 0, 0, 0}, + {~(AT_TYPE_BUGNET | AT_TYPE_BEETLE | AT_TYPE_0x80000 | AT_TYPE_0x8000 | AT_TYPE_WIND), 0x111, 0, 0x407, 0, 0}, + {0xE8}, + }, + {1000.0f}, +}; + STATE_DEFINE(dAcODungeonShip_c, Wait); STATE_DEFINE(dAcODungeonShip_c, Transparency); STATE_DEFINE(dAcODungeonShip_c, AppearEvent); STATE_DEFINE(dAcODungeonShip_c, Appear); STATE_DEFINE(dAcODungeonShip_c, End); -void dAcODungeonShip_c::initializeState_Wait() {} -void dAcODungeonShip_c::executeState_Wait() {} +const f32 dAcODungeonShip_c::someFloats[18] = { + 1.0f, 1.0f, 0.0f, 500.0f, 0.0f, 20.0f, 50.0f, 30.0f, 100.0f, + 150.0f, 100.0f, 0.0f, 0.0f, 0.0f, 4000.0f, 2000.0f, 0.0f, 0.0f, +}; + +void dAcODungeonShip_c::eventIn_Wrapper(void *arg) { + if (arg != nullptr) { + static_cast(arg)->eventIn(); + } +} + +void dAcODungeonShip_c::eventEnd_Wrapper(void *arg) { + if (arg != nullptr) { + static_cast(arg)->eventEnd(); + } +} + +bool dAcODungeonShip_c::createHeap() { + mRes = nw4r::g3d::ResFile(getOarcResFile("ShipDungeon")); + nw4r::g3d::ResMdl mdl = mRes.GetResMdl("ShipDungeonN"); + if (!mMdl.fn_8001F3B0(mdl, &heap_allocator, 0x120)) { + return false; + } + + nw4r::g3d::ResAnmChr anmChr = mRes.GetResAnmChr("ShipDungeonN"); + if (!mAnmChr.create(mdl, anmChr, &heap_allocator, nullptr)) { + return false; + } + mMdl.setAnm(mAnmChr); + + nw4r::g3d::ResAnmClr anmClr = mRes.GetResAnmClr("ShipDungeonN"); + if (!mAnmMatClr.create(mdl, anmClr, &heap_allocator, nullptr, 1)) { + return false; + } + + mAnmMatClr.setRate(0.0f, 0); + mAnmChr.setRate(0.0f); + mMdl.setPriorityDraw(0x7F, 4); + + void *dzb = getOarcDZB("ShipDungeon", "ShipDungeonN"); + void *plc = getOarcPLC("ShipDungeon", "ShipDungeonN"); + updateMatrix(); + if (mBg.Set((cBgD_t *)dzb, (PLC *)plc, 1, &mWorldMtx, &mScale)) { + return false; + } + + if (!SceneflagManager::sInstance->checkBoolFlag(roomid, (params >> 0x10) & 0xFF) || + (BOOL)mBg.InitMapStuff(&heap_allocator)) { + return true; + } + + return false; +} + +#pragma explicit_zero_data on +static u32 rotX_init = 0; +#pragma explicit_zero_data off + +int dAcODungeonShip_c::create() { + if (!StoryflagManager::sInstance->getCounterOrFlag(271)) { + return FAILED; + } + + if (SceneflagManager::sInstance->checkBoolFlag(roomid, (params >> 0x10) & 0xFF)) { + mIsDocked = true; + } + + if (!initAllocatorWork1Heap(0x40000, "dAcODungeonShip_c::m_allocator", 0x20)) { + return FAILED; + } + + mPathIdx = params & 0xFF; + if (mPathIdx == 0xFF) { + return FAILED; + } + + dBgS::GetInstance()->Regist(&mBg, this); + mStts.SetRank(2); + mCc.Set(sCcSrc); + mCc.SetStts(mStts); + forwardAccel = 0.0f; + forwardMaxSpeed = 0.0f; + boundingBox.Set(mVec3_c(-6000.0f, -500.0f, -2000.0f), mVec3_c(5000.0f, 4000.0f, 2000.0f)); + if (SceneflagManager::sInstance->checkBoolFlag(roomid, (params >> 0x10) & 0xFF)) { + dBgS::GetInstance()->RegistBg(&mBg, this); + mStateMgr.changeState(StateID_End); + } else { + mStateMgr.changeState(StateID_Wait); + } + + mEffects[0].init(this); + field_0x8D8 = 0; + mEffects[1].init(this); + field_0x8D9 = 0; + + if (!SceneflagManager::sInstance->checkBoolFlag(roomid, (params >> 0x10) & 0xFF)) { + mDowsingOffset.set(0.0f, 500.0f, 0.0f); + mDowsingTarget.initialize(DowsingTarget::SLOT_STORY_EVENT, 0, &mDowsingOffset, 10000.0); + mDowsingTarget.doRegister(); + mIsRoaming = true; + } + + mCullingDistance = 200000.0f; + clearActorProperty(0x1); + mAppearEventFromParam = (params >> 0x18); + field_0x849 = rotation.x; + rotation.x = rotX_init; + updateMatrix(); + mBg.Move(); + return SUCCEEDED; +} + +int dAcODungeonShip_c::doDelete() { + if (mIsRoaming) { + mDowsingTarget.doUnregister(); + } + return SUCCEEDED; +} + +extern "C" u16 PARTICLE_RESOURCE_ID_MAPPING_682_; +extern "C" u16 PARTICLE_RESOURCE_ID_MAPPING_683_; + +int dAcODungeonShip_c::actorExecute() { + field_0x850++; + field_0x86C++; + mStateMgr.executeState(); + + // I hate whatever this stupid pattern in actors is with + // redundant casts and adding 0.0f to stuff + int tempZero = 0; + mVec3_c offsetPosition(position.x, position.y + 1200.0f + tempZero, position.z); + + f32 scale = tempZero + 2100.0f; + mVec3_c directedScale = mVec3_c::Ex * scale; + directedScale.rotY(rotation.y); + + f32 extent = tempZero + 1800.0f; + mCc.Set(offsetPosition + directedScale, offsetPosition - directedScale, extent); + + dCcS::GetInstance()->Set(&mCc); + mMdl.play(); + mAnmMatClr.play(); + mMdl.calc(false); + if (field_0x8D8) { + mEffects[0].fn_80029A10(PARTICLE_RESOURCE_ID_MAPPING_682_, &position, &rotation, nullptr, nullptr, nullptr); + } + + if (field_0x8D9) { + mMtx_c tmpMtx; + mMdl.getNodeWorldMtx(0, tmpMtx); + if (mEffects[1].checkField0x00()) { + mEffects[1].setMtx(tmpMtx); + } else if (field_0x8DA == 0) { + mEffects[1].fn_800299F0(PARTICLE_RESOURCE_ID_MAPPING_683_, &tmpMtx, nullptr, nullptr); + field_0x8DA = 1; + } + } + updateMatrixAndScale(); + mBg.Move(); + return SUCCEEDED; +} + +int dAcODungeonShip_c::draw() { + mMdl.mProc.mCallback.field_0x08 = field_0x862; + mMdl.mProc.mCallback.field_0x09 = 1; + drawModelType1(&mMdl); + return SUCCEEDED; +} + +void dAcODungeonShip_c::initializeState_Wait() { + fn_485_1660(); +} +void dAcODungeonShip_c::executeState_Wait() { + if (mCc.ChkTgHit() && mCc.ChkTgAtHitType(AT_TYPE_BOMB)) { + mNumTimesHit++; + field_0x862 = 0x8C; + field_0x863 = 0; + field_0x864 = 0x8C; + mAppearEvent = field_0x849; + playSound(0xB62); + mStateMgr.changeState(StateID_AppearEvent); + } else { + fn_485_1BF0(); + } +} void dAcODungeonShip_c::finalizeState_Wait() {} -void dAcODungeonShip_c::initializeState_Transparency() {} -void dAcODungeonShip_c::executeState_Transparency() {} + +void dAcODungeonShip_c::initializeState_Transparency() { + field_0x862 = 0; +} +void dAcODungeonShip_c::executeState_Transparency() { + if (mCc.ChkTgHit() && mCc.ChkTgAtHitType(AT_TYPE_BOMB)) { + if (mNumTimesHit == 1) { + field_0x862 = 0xA0; + field_0x863 = 0; + field_0x855 = 0; + mNumTimesHit++; + playSound(0xB62); + } else if (mNumTimesHit == 2) { + field_0x863 = 0; + mNumTimesHit++; + SceneflagManager::sInstance->setFlag(roomid, (params >> 0x10) & 0xFF); + mAppearEvent = mAppearEventFromParam; + field_0x8D8 = 1; + mStateMgr.changeState(StateID_AppearEvent); + playSound(0xB62); + return; + } + } + + if (mNumTimesHit == 2) { + if (field_0x855 < 0x28) { + field_0x855++; + } + f32 cos = nw4r::math::CosIdx((field_0x855 * 0x199)); + if (cos < 0.0f) { + cos = 0.0f; + } + field_0x862 = cos * 160.0f; + } else { + sLib::chaseUC(&field_0x862, field_0x863, 8); + } + field_0x858 = 20.0f; + + const dAcPy_c *link = dAcPy_c::GetLink(); + if (link != nullptr) { + if (field_0x868 > 0) { + field_0x868--; + } + + // f32 distToLink = getSquareDistanceTo(link->position); + f32 dist2 = 100000000.0f; + f32 dist1 = 225000000.0f; + bool isWithinDist2 = getSquareDistanceTo(link->position) < dist2; + bool isWithinDist1 = getSquareDistanceTo(link->position) < dist1; + s32 tmp1 = fn_485_1960(); + bool tmp2 = tmp1 < 0x1555; + if (isWithinDist1 && field_0x868 == 0 && field_0x862 == 0 && tmp2) { + if (field_0x856 > 0) { + field_0x856 = 0xFF; + mPath.SetFlag(0x40000000); + } else { + field_0x856 = 1; + mPath.ClearFlag(0x40000000); + } + + u16 idx = fn_485_1900(); + if (idx != 0xFFFF) { + mPath.setSegment(idx, 1.0f - mPath.getSegmentFraction()); + field_0x868 = 900; + } + } + + if (isWithinDist2 && !tmp2) { + field_0x858 = 50.0f; + } + + if (mPath.CheckFlag(0x40000000) && field_0x858 > 0.0f) { + field_0x858 *= -1; + } + } + sLib::addCalc(&forwardSpeed, field_0x858, 0.02f, 1.0f, 0.1f); + fn_485_1720(); +} void dAcODungeonShip_c::finalizeState_Transparency() {} -void dAcODungeonShip_c::initializeState_AppearEvent() {} -void dAcODungeonShip_c::executeState_AppearEvent() {} + +void dAcODungeonShip_c::initializeState_AppearEvent() { + if (mAppearEvent != 0xFF) { + Event ev(mAppearEvent, roomid, 0x100001, (void *)&eventIn_Wrapper, (void *)&eventEnd_Wrapper); + mEvent.scheduleEvent(ev, 0); + } +} +void dAcODungeonShip_c::executeState_AppearEvent() { + if (mAppearEvent != 0xFF) { + if (mEvent.isThisActorInEvent()) { + if (mAppearEvent == mAppearEventFromParam) { + field_0x8D9 = 1; + } + + switch (mEvent.getCurrentEventCommand()) { + case 'jmap': + case 'wait': + mEvent.isAdvance(); + mEvent.advanceNext(); + break; + case 'app2': + if (mEvent.isAdvance()) { + mAnmChr.setRate(1.0f); + mAnmChr.setPlayState(m3d::PLAY_MODE_1); + mAnmMatClr.setRate(1.0f, 0); + } else { + mEvent.advanceNext(); + } + fn_485_1EE0(); + break; + case 'appe': + if (mEvent.isAdvance()) { + mAnmChr.setRate(1.0f); + mAnmChr.setPlayState(m3d::PLAY_MODE_1); + mAnmMatClr.setFrame(0.0f, 0); + mAnmMatClr.setRate(1.0f, 0); + } else if (mAnmChr.isStop()) { + mEvent.advanceNext(); + } + fn_485_1EE0(); + break; + case 'app1': + sLib::chaseUC(&field_0x862, field_0x863, 2); + if (field_0x862 == field_0x863) { + mEvent.advanceNext(); + } + fn_485_1DF0(); + break; + case 'init': + if (mEvent.isAdvance()) { + f32 f; + if (mEvent.getSingleFloatData(&f, 'ang0', 0) == 1) { + mAng ang = mAng::fromDeg(f); + rotation.y = ang; + } + mVec3_c vec; + if (mEvent.getSingleVecData(&vec, 'pos0', 0) == 1) { + position = vec; + } + field_0x8D8 = 0; + } + mEvent.advanceNext(); + break; + default: mEvent.advanceNext(); break; + } + } else { + Event ev(mAppearEvent, roomid, 0x10001, (void *)&eventIn_Wrapper, (void *)&eventEnd_Wrapper); + mEvent.scheduleEvent(ev, 0); + } + } else { + sLib::chaseUC(&field_0x862, field_0x863, 3); + if (field_0x862 == field_0x863) { + if (mAppearEvent == mAppearEventFromParam) { + mStateMgr.changeState(StateID_Appear); + } else { + mStateMgr.changeState(StateID_Transparency); + } + } + } +} void dAcODungeonShip_c::finalizeState_AppearEvent() {} -void dAcODungeonShip_c::initializeState_Appear() {} -void dAcODungeonShip_c::executeState_Appear() {} + +void dAcODungeonShip_c::initializeState_Appear() { + field_0x862 = 0xFF; +} +void dAcODungeonShip_c::executeState_Appear() { + if (!mIsDocked) { + fn_485_1A90(); + } +} void dAcODungeonShip_c::finalizeState_Appear() {} -void dAcODungeonShip_c::initializeState_End() {} -void dAcODungeonShip_c::executeState_End() {} + +void dAcODungeonShip_c::initializeState_End() { + field_0x862 = 0xFF; +} +void dAcODungeonShip_c::executeState_End() { + if (!mIsDocked) { + fn_485_1A90(); + } +} void dAcODungeonShip_c::finalizeState_End() {} + +void dAcODungeonShip_c::eventIn() {} +void dAcODungeonShip_c::eventEnd() { + if (mNumTimesHit == 1) { + mStateMgr.changeState(StateID_Transparency); + } else { + mStateMgr.changeState(StateID_Appear); + } +} + +void dAcODungeonShip_c::fn_485_1660() { + f32 arg = 0.0f; + f32 arg2 = 0.0001f; + field_0x856 = 1; + if (mPath.initExt(mPathIdx, roomid, 0, 0, 0, arg, arg, arg2)) { + mPath.setSegment(0, arg); + position = mPath.getPosition(); + mOldPosition = mPath.getPosition(); + } +} + +void dAcODungeonShip_c::updateMatrixAndScale() { + updateMatrix(); + mMdl.setLocalMtx(mWorldMtx); + mMdl.setScale(mScale); +} + +void dAcODungeonShip_c::fn_485_1EE0() { + if (cM::isZero(mAnmMatClr.getRate(0))) { + return; + } + + nw4r::g3d::AnmObjMatClrRes *nw4rObj = mAnmMatClr.getChild(0); + nw4r::g3d::ClrAnmResult result; + field_0x862 = nw4rObj->GetResult(&result, 0)->rgba[nw4r::g3d::ClrAnmResult::CLA_TEV1]; +} From 9b6e3e860d297a62581eaa330b2bc901b55c7436 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 27 Feb 2025 15:44:19 +0100 Subject: [PATCH 2/2] A bit more --- .../rels/d_a_obj_dungeon_shipNP/symbols.txt | 14 +- config/SOUE01/symbols.txt | 72 ++++++++++- include/d/a/obj/d_a_obj_dungeon_ship.h | 12 +- include/toBeSorted/actor_on_rail.h | 14 +- src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp | 121 ++++++++++++++++-- 5 files changed, 209 insertions(+), 24 deletions(-) diff --git a/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt b/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt index 86d5c646..6e332544 100644 --- a/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt +++ b/config/SOUE01/rels/d_a_obj_dungeon_shipNP/symbols.txt @@ -4,8 +4,8 @@ _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 dAcODungeonShip_c_classInit__Fv = .text:0x000000F0; // type:function size:0x1CC -fn_485_2C0 = .text:0x000002C0; // type:function size:0x58 -fn_485_320 = .text:0x00000320; // type:function size:0x40 +__dt__12TimeProcBaseFv = .text:0x000002C0; // type:function size:0x58 +__dt__Q34nw4r3g3d15IScnObjCallbackFv = .text:0x00000320; // type:function size:0x40 __dt__30sFState_c<17dAcODungeonShip_c>Fv = .text:0x00000360; // type:function size:0x58 __dt__33sFStateFct_c<17dAcODungeonShip_c>Fv = .text:0x000003C0; // type:function size:0x6C __dt__86sStateMgr_c<17dAcODungeonShip_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000430; // type:function size:0xA0 @@ -38,12 +38,12 @@ eventIn__17dAcODungeonShip_cFv = .text:0x00001610; // type:function size:0x4 eventEnd__17dAcODungeonShip_cFv = .text:0x00001620; // type:function size:0x3C fn_485_1660__17dAcODungeonShip_cFv = .text:0x00001660; // type:function size:0xB4 fn_485_1720__17dAcODungeonShip_cFv = .text:0x00001720; // type:function size:0x110 -fn_485_1830 = .text:0x00001830; // type:function size:0xC8 +fn_485_1830__17dAcODungeonShip_cFllPl = .text:0x00001830; // type:function size:0xC8 fn_485_1900__17dAcODungeonShip_cFv = .text:0x00001900; // type:function size:0x58 -fn_485_1960 = .text:0x00001960; // type:function size:0xE8 -fn_485_1A50 = .text:0x00001A50; // type:function size:0xC -fn_485_1A60 = .text:0x00001A60; // type:function size:0xC -fn_485_1A70 = .text:0x00001A70; // type:function size:0x18 +fn_485_1960__17dAcODungeonShip_cFv = .text:0x00001960; // type:function size:0xE8 +fn_485_1A50__17dAcODungeonShip_cFv = .text:0x00001A50; // type:function size:0xC +fn_485_1A60__17dAcODungeonShip_cFv = .text:0x00001A60; // type:function size:0xC +fn_485_1A70__17dAcODungeonShip_cFP7mVec3_c = .text:0x00001A70; // type:function size:0x18 fn_485_1A90__17dAcODungeonShip_cFv = .text:0x00001A90; // type:function size:0x154 fn_485_1BF0__17dAcODungeonShip_cFv = .text:0x00001BF0; // type:function size:0x200 fn_485_1DF0__17dAcODungeonShip_cFv = .text:0x00001DF0; // type:function size:0xA0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c9520e1a..6445d024 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -965,7 +965,7 @@ fn_800298C0 = .text:0x800298C0; // type:function size:0x4C fn_80029910 = .text:0x80029910; // type:function size:0x4 fn_80029920 = .text:0x80029920; // type:function size:0x54 fn_80029980 = .text:0x80029980; // type:function size:0x64 -fn_800299F0 = .text:0x800299F0; // type:function size:0x20 +fn_800299F0__13EffectsStructFUsP6mMtx_cPvPv = .text:0x800299F0; // type:function size:0x20 fn_80029A10__13EffectsStructFUsP7mVec3_cP7mAng3_cP7mVec3_cPvPv = .text:0x80029A10; // type:function size:0x54 fn_80029A70 = .text:0x80029A70; // type:function size:0x64 fn_80029AE0 = .text:0x80029AE0; // type:function size:0x20 @@ -3691,7 +3691,7 @@ fn_800A6F90 = .text:0x800A6F90; // type:function size:0x184 fn_800A7120 = .text:0x800A7120; // type:function size:0x464 fn_800A7590 = .text:0x800A7590; // type:function size:0x3BC fn_800A7950 = .text:0x800A7950; // type:function size:0x324 -fn_800A7C80 = .text:0x800A7C80; // type:function size:0x4CC +fn_800A7C80__11ActorOnRailFiR7mVec3_cf = .text:0x800A7C80; // type:function size:0x4CC fn_800A8150 = .text:0x800A8150; // type:function size:0x124 fn_800A8280 = .text:0x800A8280; // type:function size:0x138 fn_800A83C0 = .text:0x800A83C0; // type:function size:0x144 @@ -3713,7 +3713,7 @@ fn_800A9470 = .text:0x800A9470; // type:function size:0x74 __ct__15ActorOnRail_ExtFv = .text:0x800A94F0; // type:function size:0x60 __dt__15ActorOnRail_ExtFv = .text:0x800A9550; // type:function size:0x58 initExt__15ActorOnRail_ExtFiiiiifff = .text:0x800A95B0; // type:function size:0x9C -fn_800A9650 = .text:0x800A9650; // type:function size:0x208 +fn_800A9650__15ActorOnRail_ExtFv = .text:0x800A9650; // type:function size:0x208 fn_800A9860 = .text:0x800A9860; // type:function size:0x50 fn_800A98B0 = .text:0x800A98B0; // type:function size:0x58 fn_800A9910 = .text:0x800A9910; // type:function size:0x48 @@ -17871,7 +17871,7 @@ fn_802F2920 = .text:0x802F2920; // type:function size:0x48 createProjectionXZ__7mVec3_cFRC7mAng3_cf = .text:0x802F2970; // type:function size:0x110 mVec__fromXY = .text:0x802F2A80; // type:function size:0xF0 normalize__7mVec3_cFv = .text:0x802F2B70; // type:function size:0x78 -mVec__normalizeRS = .text:0x802F2BF0; // type:function size:0x84 +normalizeRS__7mVec3_cFv = .text:0x802F2BF0; // type:function size:0x84 rotX__7mVec3_cFRC4mAng = .text:0x802F2C80; // type:function size:0xA8 rotY__7mVec3_cFRC4mAng = .text:0x802F2D30; // type:function size:0xAC rotZ__7mVec3_cFRC4mAng = .text:0x802F2DE0; // type:function size:0xA8 @@ -44021,7 +44021,69 @@ PARTICLE_RESOURCE_ID_MAPPING_620_ = .sdata2:0x8057A888; // type:object size:0x2 PARTICLE_RESOURCE_ID_MAPPING_621_ = .sdata2:0x8057A88A; // type:object size:0x2 data:2byte PARTICLE_RESOURCE_ID_MAPPING_622_ = .sdata2:0x8057A88C; // type:object size:0x2 data:2byte PARTICLE_RESOURCE_ID_MAPPING_623_ = .sdata2:0x8057A88E; // type:object size:0x2 -PARTICLE_RESOURCE_ID_MAPPING_624_ = .sdata2:0x8057A890; // type:object size:0x7E data:2byte +PARTICLE_RESOURCE_ID_MAPPING_624_ = .sdata2:0x8057A890; // type:object size:0x2 data:2byte +lbl_8057A892 = .sdata2:0x8057A892; // type:object size:0x2 +lbl_8057A894 = .sdata2:0x8057A894; // type:object size:0x2 +lbl_8057A896 = .sdata2:0x8057A896; // type:object size:0x2 +lbl_8057A898 = .sdata2:0x8057A898; // type:object size:0x2 +lbl_8057A89A = .sdata2:0x8057A89A; // type:object size:0x2 +lbl_8057A89C = .sdata2:0x8057A89C; // type:object size:0x2 +lbl_8057A89E = .sdata2:0x8057A89E; // type:object size:0x2 +lbl_8057A8A0 = .sdata2:0x8057A8A0; // type:object size:0x2 +lbl_8057A8A2 = .sdata2:0x8057A8A2; // type:object size:0x2 +lbl_8057A8A4 = .sdata2:0x8057A8A4; // type:object size:0x2 +lbl_8057A8A6 = .sdata2:0x8057A8A6; // type:object size:0x2 +lbl_8057A8A8 = .sdata2:0x8057A8A8; // type:object size:0x2 +lbl_8057A8AA = .sdata2:0x8057A8AA; // type:object size:0x2 +lbl_8057A8AC = .sdata2:0x8057A8AC; // type:object size:0x2 +lbl_8057A8AE = .sdata2:0x8057A8AE; // type:object size:0x2 +lbl_8057A8B0 = .sdata2:0x8057A8B0; // type:object size:0x2 +lbl_8057A8B2 = .sdata2:0x8057A8B2; // type:object size:0x2 +lbl_8057A8B4 = .sdata2:0x8057A8B4; // type:object size:0x2 +lbl_8057A8B6 = .sdata2:0x8057A8B6; // type:object size:0x2 +lbl_8057A8B8 = .sdata2:0x8057A8B8; // type:object size:0x2 +lbl_8057A8BA = .sdata2:0x8057A8BA; // type:object size:0x2 +lbl_8057A8BC = .sdata2:0x8057A8BC; // type:object size:0x2 +lbl_8057A8BE = .sdata2:0x8057A8BE; // type:object size:0x2 +lbl_8057A8C0 = .sdata2:0x8057A8C0; // type:object size:0x2 +lbl_8057A8C2 = .sdata2:0x8057A8C2; // type:object size:0x2 +lbl_8057A8C4 = .sdata2:0x8057A8C4; // type:object size:0x2 +lbl_8057A8C6 = .sdata2:0x8057A8C6; // type:object size:0x2 +lbl_8057A8C8 = .sdata2:0x8057A8C8; // type:object size:0x2 +lbl_8057A8CA = .sdata2:0x8057A8CA; // type:object size:0x2 +lbl_8057A8CC = .sdata2:0x8057A8CC; // type:object size:0x2 +lbl_8057A8CE = .sdata2:0x8057A8CE; // type:object size:0x2 +lbl_8057A8D0 = .sdata2:0x8057A8D0; // type:object size:0x2 +lbl_8057A8D2 = .sdata2:0x8057A8D2; // type:object size:0x2 +lbl_8057A8D4 = .sdata2:0x8057A8D4; // type:object size:0x2 +lbl_8057A8D6 = .sdata2:0x8057A8D6; // type:object size:0x2 +lbl_8057A8D8 = .sdata2:0x8057A8D8; // type:object size:0x2 +lbl_8057A8DA = .sdata2:0x8057A8DA; // type:object size:0x2 +lbl_8057A8DC = .sdata2:0x8057A8DC; // type:object size:0x2 +lbl_8057A8DE = .sdata2:0x8057A8DE; // type:object size:0x2 +lbl_8057A8E0 = .sdata2:0x8057A8E0; // type:object size:0x2 +lbl_8057A8E2 = .sdata2:0x8057A8E2; // type:object size:0x2 +lbl_8057A8E4 = .sdata2:0x8057A8E4; // type:object size:0x2 +lbl_8057A8E6 = .sdata2:0x8057A8E6; // type:object size:0x2 +lbl_8057A8E8 = .sdata2:0x8057A8E8; // type:object size:0x2 +lbl_8057A8EA = .sdata2:0x8057A8EA; // type:object size:0x2 +lbl_8057A8EC = .sdata2:0x8057A8EC; // type:object size:0x2 +lbl_8057A8EE = .sdata2:0x8057A8EE; // type:object size:0x2 +lbl_8057A8F0 = .sdata2:0x8057A8F0; // type:object size:0x2 +lbl_8057A8F2 = .sdata2:0x8057A8F2; // type:object size:0x2 +lbl_8057A8F4 = .sdata2:0x8057A8F4; // type:object size:0x2 +lbl_8057A8F6 = .sdata2:0x8057A8F6; // type:object size:0x2 +lbl_8057A8F8 = .sdata2:0x8057A8F8; // type:object size:0x2 +lbl_8057A8FA = .sdata2:0x8057A8FA; // type:object size:0x2 +lbl_8057A8FC = .sdata2:0x8057A8FC; // type:object size:0x2 +lbl_8057A8FE = .sdata2:0x8057A8FE; // type:object size:0x2 +lbl_8057A900 = .sdata2:0x8057A900; // type:object size:0x2 +lbl_8057A902 = .sdata2:0x8057A902; // type:object size:0x2 +PARTICLE_RESOURCE_ID_MAPPING_682_ = .sdata2:0x8057A904; // type:object size:0x2 data:2byte +PARTICLE_RESOURCE_ID_MAPPING_683_ = .sdata2:0x8057A906; // type:object size:0x2 data:2byte +lbl_8057A908 = .sdata2:0x8057A908; // type:object size:0x2 +lbl_8057A90A = .sdata2:0x8057A90A; // type:object size:0x2 +lbl_8057A90C = .sdata2:0x8057A90C; // type:object size:0x2 PARTICLE_RESOURCE_ID_MAPPING_687_ = .sdata2:0x8057A90E; // type:object size:0x12 data:2byte PARTICLE_RESOURCE_ID_MAPPING_696_ = .sdata2:0x8057A920; // type:object size:0x2 data:2byte PARTICLE_RESOURCE_ID_MAPPING_697_ = .sdata2:0x8057A922; // type:object size:0xC data:2byte diff --git a/include/d/a/obj/d_a_obj_dungeon_ship.h b/include/d/a/obj/d_a_obj_dungeon_ship.h index 4ef14bd3..18fbdb31 100644 --- a/include/d/a/obj/d_a_obj_dungeon_ship.h +++ b/include/d/a/obj/d_a_obj_dungeon_ship.h @@ -41,8 +41,13 @@ private: void fn_485_1660(); void fn_485_1720(); - u32 fn_485_1900(); + bool fn_485_1830(s32 pathSegmentIndex, s32 direction, s32 *out); + u16 fn_485_1900(); u32 fn_485_1960(); + f32 fn_485_1A50(); + f32 fn_485_1A60(); + static void fn_485_1A70(mVec3_c *); + void fn_485_1A90(); void fn_485_1BF0(); void fn_485_1DF0(); @@ -72,12 +77,15 @@ private: /* 0x849 */ u8 field_0x849; /* 0x84A */ u8 mAppearEvent; /* 0x84B */ u8 mPathIdx; - /* 0x84C */ u8 field_0x84C[0x850 - 0x84C]; + /* 0x84C */ u16 field_0x84C; /* 0x850 */ u32 field_0x850; /* 0x854 */ u8 mNumTimesHit; /* 0x855 */ u8 field_0x855; /* 0x856 */ s8 field_0x856; /* 0x858 */ f32 field_0x858; + /* 0x85C */ UNKWORD field_0x85C; + /* 0x862 */ u8 field_0x860; + /* 0x862 */ u8 field_0x861; /* 0x862 */ u8 field_0x862; /* 0x863 */ u8 field_0x863; /* 0x864 */ u8 field_0x864; diff --git a/include/toBeSorted/actor_on_rail.h b/include/toBeSorted/actor_on_rail.h index 5243be9b..11a4fd16 100644 --- a/include/toBeSorted/actor_on_rail.h +++ b/include/toBeSorted/actor_on_rail.h @@ -20,6 +20,8 @@ public: bool init(int pathIndex, int roomId, int pathSubtype); /* 800A68B0 */ mVec3_c *getPntPosForIndex(int index); + + void fn_800A7C80(int segmentIndex, mVec3_c &vec, f32 segmentFraction); }; class ActorOnRail_Ext : public ActorOnRail { @@ -29,7 +31,12 @@ public: void setSegment(u16 segmentIndex, f32 segmentFraction); bool initExt(int pathIndex, int roomId, int, int pathSegment, int pathSubtype, f32, f32, f32); + void fn_800A9650(); + s32 getSegmentIndex() const { + return mSegmentIndex; + } + f32 getSegmentFraction() const { return mSegmentFraction; } @@ -50,11 +57,16 @@ public: return mPosition; } + void setSpeed(f32 speed) { + mSpeed = speed; + } + + private: s32 mSegmentIndex; f32 mSegmentFraction; - UNKWORD field_0x18; + f32 mSpeed; u32 field_0x1C; f32 field_0x20; UNKWORD field_0x24; diff --git a/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp b/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp index 4eec74a3..1758197d 100644 --- a/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp +++ b/src/REL/d/a/obj/d_a_obj_dungeon_ship.cpp @@ -1,5 +1,7 @@ #include "d/a/obj/d_a_obj_dungeon_ship.h" +#include "c/c_lib.h" +#include "c/c_math.h" #include "common.h" #include "d/a/d_a_player.h" #include "d/col/bg/d_bg_s.h" @@ -8,6 +10,7 @@ #include "d/flag/storyflag_manager.h" #include "f/f_base.h" #include "m/m3d/m_fanm.h" +#include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_vec.h" #include "nw4r/g3d/g3d_anmclr.h" @@ -15,6 +18,7 @@ #include "nw4r/g3d/res/g3d_resanmclr.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/g3d/res/g3d_resmdl.h" +#include "nw4r/math/math_triangular.h" #include "s/s_Math.h" #include "toBeSorted/dowsing_target.h" #include "toBeSorted/event.h" @@ -55,7 +59,8 @@ void dAcODungeonShip_c::eventEnd_Wrapper(void *arg) { } bool dAcODungeonShip_c::createHeap() { - mRes = nw4r::g3d::ResFile(getOarcResFile("ShipDungeon")); + const char *arcName = "ShipDungeon"; + mRes = nw4r::g3d::ResFile(getOarcResFile(arcName)); nw4r::g3d::ResMdl mdl = mRes.GetResMdl("ShipDungeonN"); if (!mMdl.fn_8001F3B0(mdl, &heap_allocator, 0x120)) { return false; @@ -76,19 +81,25 @@ bool dAcODungeonShip_c::createHeap() { mAnmChr.setRate(0.0f); mMdl.setPriorityDraw(0x7F, 4); - void *dzb = getOarcDZB("ShipDungeon", "ShipDungeonN"); - void *plc = getOarcPLC("ShipDungeon", "ShipDungeonN"); + const char *dzbPlcName = "ShipDungeonN"; + void *dzb = getOarcDZB(arcName, dzbPlcName); + void *plc = getOarcPLC(arcName, dzbPlcName); updateMatrix(); if (mBg.Set((cBgD_t *)dzb, (PLC *)plc, 1, &mWorldMtx, &mScale)) { return false; } - if (!SceneflagManager::sInstance->checkBoolFlag(roomid, (params >> 0x10) & 0xFF) || - (BOOL)mBg.InitMapStuff(&heap_allocator)) { - return true; + // wat + if (!SceneflagManager::sInstance->checkBoolFlag(roomid, (params >> 0x10) & 0xFF)) { + goto ok; + } else { + bool result = (BOOL)mBg.InitMapStuff(&heap_allocator); + if (result == false) { + return false; + } } - - return false; +ok: + return true; } #pragma explicit_zero_data on @@ -368,7 +379,7 @@ void dAcODungeonShip_c::executeState_AppearEvent() { default: mEvent.advanceNext(); break; } } else { - Event ev(mAppearEvent, roomid, 0x10001, (void *)&eventIn_Wrapper, (void *)&eventEnd_Wrapper); + Event ev(mAppearEvent, roomid, 0x100001, (void *)&eventIn_Wrapper, (void *)&eventEnd_Wrapper); mEvent.scheduleEvent(ev, 0); } } else { @@ -424,6 +435,92 @@ void dAcODungeonShip_c::fn_485_1660() { } } +static u32 rot_7fff = 0x7FFF; +static u32 rot_4000 = 0x4000; + +void dAcODungeonShip_c::fn_485_1720() { + mPath.setSpeed(forwardSpeed); + mPath.fn_800A9650(); + // TODO + position = mPath.getPosition(); + + mVec3_c tmp; + mPath.fn_800A7C80(mPath.getSegmentIndex(), tmp, mPath.getSegmentFraction()); + rotation.y = cM::atan2s(tmp.x, tmp.z); + if (mPath.CheckFlag(0x40000000)) { + rotation.y += rot_7fff; + } + rotation.y += rot_4000; + angle.y = rotation.y; + + int factor = 0x12C; + f32 tmp2 = nw4r::math::SinIdx((field_0x850 * 800)); + tmp2 *= factor; + field_0x84C = tmp2; +} + +bool dAcODungeonShip_c::fn_485_1830(s32 pathSegmentIndex, s32 direction, s32 *out) { + +} + +u16 dAcODungeonShip_c::fn_485_1900() { + s32 sign = mPath.CheckFlag(0x40000000) ? -1 : 1; + s32 result; + if (fn_485_1830(mPath.getSegmentIndex(), sign, &result)) { + return result; + } else { + return -1; + } +} + +u32 dAcODungeonShip_c::fn_485_1960() { + const dAcPy_c *link = dAcPy_c::GetLink(); + if (link == nullptr) { + return 0; + } + mVec3_c v = mVec3_c::Ez; + v.rotY(angle.y + mAng(-0x4000)); + mVec3_c dist = link->position - position; + dist.y = 0.0f; + dist.normalizeRS(); + int a1 = cLib::targetAngleY(mVec3_c::Zero, v); + int a2 = cLib::targetAngleY(mVec3_c::Zero, dist); + // okay + return labs(mAng(mAng(a1) - mAng(a2))); +} + +f32 dAcODungeonShip_c::fn_485_1A50() { + return 4000.0f; +} + +f32 dAcODungeonShip_c::fn_485_1A60() { + return 2000.0f; +} + +void dAcODungeonShip_c::fn_485_1A70(mVec3_c *v) { + v->set(0.0f, 0.0f, 0.0f); +} + +void dAcODungeonShip_c::fn_485_1A90() { + +} + +void dAcODungeonShip_c::fn_485_1BF0() { + +} + +void dAcODungeonShip_c::fn_485_1DF0() { + const dAcPy_c *link = dAcPy_c::GetLink(); + if (link != nullptr) { + // unused, stack problems + mVec3_c dist = position - link->position; + fn_485_1960(); + field_0x858 = 30.0f; + sLib::addCalc(&forwardSpeed, 30.0f, 0.02f, 1.0f, 0.1f); + fn_485_1720(); + } +} + void dAcODungeonShip_c::updateMatrixAndScale() { updateMatrix(); mMdl.setLocalMtx(mWorldMtx); @@ -439,3 +536,9 @@ void dAcODungeonShip_c::fn_485_1EE0() { nw4r::g3d::ClrAnmResult result; field_0x862 = nw4rObj->GetResult(&result, 0)->rgba[nw4r::g3d::ClrAnmResult::CLA_TEV1]; } + +void unusedFloats() { + // these are probably not floats but I have no idea why this data is here + 2.24E-43f; + 5.6E-44f; +}