diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index 377746bb9d5..a976be81c9b 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -10,13 +10,13 @@ #include "m_Do/m_Do_lib.h" struct J3DGXColorS10 { - /* 8000E460 */ J3DGXColorS10(); + /* 8000E460 */ J3DGXColorS10() {} _GXColorS10 mColor; }; struct J3DGXColor : public _GXColor { - /* 8000E538 */ J3DGXColor(); + /* 8000E538 */ J3DGXColor() {} }; struct J3DNBTScaleInfo { diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h index cb98164d030..5fa9a87af1a 100644 --- a/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -23,6 +23,8 @@ class J3DLightObj { public: /* 80018C0C */ J3DLightObj() : mInfo(j3dDefaultLightInfo) {} + J3DLightInfo& getLightInfo() { return mInfo; } + /* 0x00 */ J3DLightInfo mInfo; /* 0x34 */ u8 field_0x34[64]; }; // Size = 0x74 diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index 0e2e4b29826..baaa513365d 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -29,6 +29,7 @@ enum cCcD_ObjAtType { /* 0x00000008 */ AT_TYPE_THROW_OBJ = (1 << 3), /* 0x00000010 */ AT_TYPE_SHIELD_ATTACK = (1 << 4), /* 0x00000020 */ AT_TYPE_BOMB = (1 << 5), + /* 0x00000040 */ AT_TYPE_40 = (1 << 6), /* 0x00000080 */ AT_TYPE_SLINGSHOT = (1 << 7), /* 0x00000200 */ AT_TYPE_LANTERN_SWING = (1 << 9), /* 0x00000400 */ AT_TYPE_CSTATUE_SWING = (1 << 10), @@ -272,25 +273,33 @@ public: STATIC_ASSERT(0x40 == sizeof(cCcD_DivideArea)); +struct cCcD_SrcObjCommonBase { + /* 0x0 */ s32 mSPrm; +}; + struct cCcD_SrcObjTg { /* 0x0 */ s32 mType; - /* 0x4 */ s32 mSPrm; + /* 0x4 */ cCcD_SrcObjCommonBase mBase; }; // Size: 0x8 struct cCcD_SrcObjAt { /* 0x0 */ s32 mType; /* 0x4 */ u8 mAtp; - /* 0x8 */ s32 mSPrm; + /* 0x8 */ cCcD_SrcObjCommonBase mBase; }; // Size: 0xC +struct cCcD_SrcObjCo { + /* 0x0 */ cCcD_SrcObjCommonBase mBase; +}; // Size: 0x4 + struct cCcD_SrcObjHitInf { /* 0x00 */ cCcD_SrcObjAt mObjAt; /* 0x0C */ cCcD_SrcObjTg mObjTg; - /* 0x14 */ s32 mSPrm; + /* 0x14 */ cCcD_SrcObjCo mObjCo; }; // Size: 0x18 struct cCcD_SrcObj { - /* 0x0 */ int field_0x0; + /* 0x0 */ int mFlags; /* 0x4 */ cCcD_SrcObjHitInf mSrcObjHitInf; }; // Size: 0x1C @@ -345,6 +354,13 @@ protected: /* 0x08 */ cCcD_Obj* mHitObj; /* 0x0C vtable */ public: + enum CoSPrm_e { + CO_SPRM_SET = 1, + CO_SPRM_NO_CRR = 0x100, + CO_SPRM_NO_CO_HIT_INF_SET = 0x200, + CO_SPRM_SAME_ACTOR_HIT = 0x400, + }; + cCcD_ObjCommonBase() { ct(); } /* 8008409C */ virtual ~cCcD_ObjCommonBase() {} /* 802639B0 */ void ct(); @@ -357,6 +373,10 @@ public: u32 MskRPrm(u32 mask) { return mRPrm & mask; } void OnSPrmBit(u32 flag) { mSPrm |= flag; } void OffSPrmBit(u32 flag) { mSPrm &= ~flag; } + + void Set(cCcD_SrcObjCommonBase const& src) { + mSPrm = src.mSPrm; + } }; STATIC_ASSERT(0x10 == sizeof(cCcD_ObjCommonBase)); @@ -421,6 +441,10 @@ public: u32 ChkSph3DCrr() const { return MskSPrm(0x80); } void ClrSet() { OffSPrmBit(1); } u32 ChkHit() { return MskRPrm(1); } + + void Set(cCcD_SrcObjCo const& src) { + cCcD_ObjCommonBase::Set(src.mBase); + } }; STATIC_ASSERT(0x10 == sizeof(cCcD_ObjCo)); @@ -510,10 +534,10 @@ public: void SetStts(cCcD_Stts* stts) { mStts = stts; } cCcD_DivideInfo& GetDivideInfo() { return mDivideInfo; } cCcD_DivideInfo* GetPDivideInfo() { return &mDivideInfo; } - int ChkBsRevHit() const { return field_0x40 & 2; } + int ChkBsRevHit() const { return mFlags & 2; } private: - /* 0x040 */ int field_0x40; + /* 0x040 */ int mFlags; /* 0x044 */ cCcD_Stts* mStts; /* 0x048 */ cCcD_DivideInfo mDivideInfo; }; // Size = 0x58 diff --git a/include/SSystem/SComponent/c_counter.h b/include/SSystem/SComponent/c_counter.h index 6967d2a678f..19cd6bd3a43 100644 --- a/include/SSystem/SComponent/c_counter.h +++ b/include/SSystem/SComponent/c_counter.h @@ -4,7 +4,7 @@ #include "dolphin/types.h" struct counter_class { - s32 mCounter0; + u32 mCounter0; s32 mCounter1; s32 mTimer; }; diff --git a/include/d/com/d_com_inf_game.h b/include/d/com/d_com_inf_game.h index c57fe0a3b60..23ff32697d1 100644 --- a/include/d/com/d_com_inf_game.h +++ b/include/d/com/d_com_inf_game.h @@ -1789,6 +1789,12 @@ inline u8 dComIfGp_att_getCatchChgItem() { return dComIfGp_getAttention().getCatchChgItem(); } +inline void dComIfGp_att_LookRequest(fopAc_ac_c* param_0, f32 i_horizontalDist, f32 i_upDist, + f32 i_downDist, s16 i_angle, int param_5) { + dComIfGp_getAttention().LookRequest(param_0, i_horizontalDist, i_upDist, i_downDist, i_angle, + param_5); +} + inline J2DGrafContext* dComIfGp_getCurrentGrafPort() { return g_dComIfG_gameInfo.play.getCurrentGrafPort(); } diff --git a/include/d/d_attention.h b/include/d/d_attention.h index 0fec633004c..234053d9630 100644 --- a/include/d/d_attention.h +++ b/include/d/d_attention.h @@ -215,10 +215,15 @@ public: int GetActionCount() { return mActionCount; } int GetLockonCount() { return mLockonCount; } bool Lockon() { return LockonTruth() || chkFlag(0x20000000); } // only matches with -O2? - int ZHintRequest(fopAc_ac_c *param_1, int param_2) { + int ZHintRequest(fopAc_ac_c* param_1, int param_2) { return mZHintTarget.request(param_1, param_2); } + void LookRequest(fopAc_ac_c* param_0, f32 i_horizontalDist, f32 i_upDist, f32 i_downDist, + s16 i_angle, int param_5) { + mLookTarget.request(param_0, i_horizontalDist, i_upDist, i_downDist, i_angle, param_5); + } + static dist_entry& i_getDistTable(int i_no) { return dist_table[i_no]; } static type_tbl_entry loc_type_tbl[3]; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 491a769ec52..ecd86856dc0 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -782,7 +782,7 @@ public: /* 80024954 */ static bool resetArchiveBank(int); /* 80024DB0 */ static void SetTimePass(int); /* 8025BAAC */ static void setZoneNo(int, int); - static s32 GetTimePass(); + static s8 GetTimePass(); static s8 getStayNo() { return mStayNo; } static u8 getRegionNo(int i_roomNo) { return mStatus[i_roomNo].mRegionNo; } @@ -1031,7 +1031,7 @@ inline s32 i_dStage_stagInfo_GetSaveTbl(stage_stag_info_class* param_0) { } inline s8 dStage_stagInfo_GetTimeH(stage_stag_info_class* p_info) { - return p_info->field_0x0c >> 8; + return (p_info->field_0x0c >> 8) & 0xFF; } inline BOOL dStage_staginfo_GetArchiveHeap(stage_stag_info_class* p_info) { diff --git a/include/d/kankyo/d_kankyo.h b/include/d/kankyo/d_kankyo.h index 8a380332974..e9735f1ec32 100644 --- a/include/d/kankyo/d_kankyo.h +++ b/include/d/kankyo/d_kankyo.h @@ -12,6 +12,7 @@ class JPABaseEmitter; class cBgS_PolyInfo; +class color_RGB_class; void dKankyo_DayProc(); void dKy_set_nexttime(f32); @@ -44,6 +45,11 @@ void dKy_setLight(); cXyz dKy_plight_near_pos(); void dKy_BossSpotLight_set(cXyz* param_0, f32 param_1, f32 param_2, f32 param_3, _GXColor* param_4, f32 param_5, u8 param_6, u8 param_7); +static void dKy_calc_color_set(_GXColorS10* param_0, color_RGB_class* param_1, + color_RGB_class* param_2, color_RGB_class* param_3, + color_RGB_class* param_4, f32 param_5, f32 param_6, + _GXColorS10 param_7, f32 param_8); +static void dKy_twilight_camelight_set(); struct LIGHT_INFLUENCE { /* 800CFC7C */ ~LIGHT_INFLUENCE() {} @@ -203,7 +209,7 @@ public: /* 0x367 */ u8 field_0x367; /* 0x368 */ f32 mFogStartZ; /* 0x36C */ f32 mFogEndZ; - /* 0x370 */ f32 field_0x370; + /* 0x370 */ f32 mColpatBlend; /* 0x374 */ f32 field_0x374; /* 0x378 */ u16 field_0x378; /* 0x37A */ u8 field_0x37a; @@ -379,9 +385,7 @@ public: /* 0x1058 */ dKankyo_evil_Packet* mpEvilPacket; /* 0x105C */ mDoExt_btkAnm* field_0x105c; /* 0x1060 */ fopAc_ac_c* field_0x1060; - /* 0x1064 */ f32 field_0x1064; - /* 0x1068 */ f32 field_0x1068; - /* 0x106C */ f32 field_0x106c; + /* 0x1064 */ Vec field_0x1064; /* 0x1070 */ cXyz mSunPos2; /* 0x107C */ cXyz mPLightNearPos; /* 0x1088 */ cXyz mSunPos; @@ -394,10 +398,7 @@ public: /* 0x10D8 */ GXColorS10 mUnderCloudShadowColor; /* 0x10E0 */ GXColorS10 mCloudOuterHazeColor; /* 0x10E8 */ GXColorS10 mCloudInnerHazeColor; - /* 0x10F0 */ s16 field_0x10f0; - /* 0x10F2 */ s16 field_0x10f2; - /* 0x10F4 */ s16 field_0x10f4; - /* 0x10F6 */ s16 field_0x10f6; + /* 0x10F0 */ GXColorS10 field_0x10f0; /* 0x10F8 */ s16 field_0x10f8; /* 0x10FA */ s16 field_0x10fa; /* 0x10FC */ s16 field_0x10fc; @@ -493,7 +494,7 @@ public: /* 0x12B8 */ u8 field_0x12b8[4]; /* 0x12BC */ u16 mFogAdjCenter; /* 0x12BE */ u16 mDate; - /* 0x12C0 */ u16 mActorLightEffect; + /* 0x12C0 */ s16 mActorLightEffect; /* 0x12C2 */ u8 mColPatPrev; /* 0x12C3 */ u8 mColPatCurr; /* 0x12C4 */ u8 mColpatPrevGather; diff --git a/include/d/kankyo/d_kankyo_wether.h b/include/d/kankyo/d_kankyo_wether.h index 2242f483861..46cb651a503 100644 --- a/include/d/kankyo/d_kankyo_wether.h +++ b/include/d/kankyo/d_kankyo_wether.h @@ -237,7 +237,6 @@ public: virtual void draw(); virtual ~dKankyo_vrkumo_Packet(); -private: /* 0x0010 */ GXColor mColor; /* 0x0014 */ u8* mpResCloudtx_01; /* 0x0018 */ u8* mpResCloudtx_02; diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index 5e8fd551899..2d05cdb5bef 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -119,6 +119,10 @@ inline void mDoAud_mEnvse_framework() { g_mEnvSeMgr.framework(); } +inline void mDoAud_mEnvse_resetScene() { + g_mEnvSeMgr.resetScene(); +} + inline void mDoAud_mEnvSe_startFarThunderSe(const Vec* param_0) { g_mEnvSeMgr.startFarThunderSe((Vec*)param_0, 0); } diff --git a/include/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.h b/include/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.h index cc02f28f257..5336a6e0982 100644 --- a/include/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.h +++ b/include/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.h @@ -1,6 +1,49 @@ #ifndef D_A_OBJ_SWPROPELLER_H #define D_A_OBJ_SWPROPELLER_H -#include "dolphin/types.h" +#include "d/cc/d_cc_d.h" +#include "f_op/f_op_actor_mng.h" + +class daObjSwPr_c : public fopAc_ac_c { +public: + /* 8059A5E8 */ void initBaseMtx(); + /* 8059A624 */ void setBaseMtx(); + /* 8059A670 */ int Create(); + /* 8059A808 */ int CreateHeap(); + /* 8059A888 */ int create(); + /* 8059AB04 */ int setRotateTime(); + /* 8059AB14 */ void switchCtrl(); + /* 8059AB9C */ void execute_type_boomerang(); + /* 8059ADCC */ void execute_type_wind(); + /* 8059B014 */ int execute(); + /* 8059B148 */ int draw(); + /* 8059B1AC */ int _delete(); + + u8 getNameArg() { return fopAcM_GetParamBit(this, 8, 8); } + u8 getMdlType() { return fopAcM_GetParamBit(this, 0x10, 4); } + int getSwbit() { return fopAcM_GetParamBit(this, 0, 8); } + u32 getSwbit2() { return fopAcM_GetParamBit(this, 0x18, 8); } + + /* 0x568 */ request_of_phase_process_class mPhase; + /* 0x570 */ J3DModel* mpModel; + /* 0x574 */ dCcD_Stts mCcStts; + /* 0x5B0 */ dCcD_Cyl mCyl1; + /* 0x6EC */ dCcD_Cyl mCyl2; + /* 0x828 */ s16 mRotateSpeed; + /* 0x82A */ s16 mRotateInitSpeed; + /* 0x82C */ s16 field_0x82c; // rotate angle? + /* 0x82E */ s16 mRotateTime; + /* 0x830 */ u16 mKaitenJntID; + /* 0x832 */ s16 mSwDelayTimer; + /* 0x834 */ u16 field_0x834; + /* 0x836 */ u16 mSwOffDelayTimer; + /* 0x838 */ u8 field_0x838; + /* 0x839 */ u8 field_0x839; + /* 0x83A */ u8 field_0x83a; + /* 0x83B */ u8 field_0x83b; + /* 0x83C */ u8 mNameArg; + /* 0x83D */ u8 field_0x83d; + /* 0x83E */ u8 mModelType; +}; #endif /* D_A_OBJ_SWPROPELLER_H */ diff --git a/libs/SSystem/SComponent/c_cc_d.cpp b/libs/SSystem/SComponent/c_cc_d.cpp index bde61fb1eff..b934b5a5608 100644 --- a/libs/SSystem/SComponent/c_cc_d.cpp +++ b/libs/SSystem/SComponent/c_cc_d.cpp @@ -257,17 +257,17 @@ void cCcD_ObjCommonBase::ct() { void cCcD_ObjHitInf::Set(cCcD_SrcObjHitInf const& src) { mObjAt.Set(src.mObjAt); mObjTg.Set(src.mObjTg); - mObjCo.SetSPrm(src.mSPrm); + mObjCo.Set(src.mObjCo); } /* 80263A10-80263A1C 25E350 000C+00 0/0 1/1 0/0 .text ct__8cCcD_ObjFv */ void cCcD_Obj::ct() { - field_0x40 = 0; + mFlags = 0; } /* 80263A1C-80263A48 25E35C 002C+00 0/0 1/1 0/0 .text Set__8cCcD_ObjFRC11cCcD_SrcObj */ void cCcD_Obj::Set(cCcD_SrcObj const& src) { - field_0x40 = src.field_0x0; + mFlags = src.mFlags; cCcD_ObjHitInf::Set(src.mSrcObjHitInf); } @@ -725,7 +725,7 @@ void cCcD_ObjAt::SetHit(cCcD_Obj* pObj) { /* 8026484C-80264868 25F18C 001C+00 1/1 0/0 0/0 .text Set__10cCcD_ObjAtFRC13cCcD_SrcObjAt */ void cCcD_ObjAt::Set(cCcD_SrcObjAt const& src) { - mSPrm = src.mSPrm; + cCcD_ObjCommonBase::Set(src.mBase); mType = src.mType; mAtp = src.mAtp; } @@ -739,7 +739,7 @@ void cCcD_ObjAt::ClrHit() { /* 80264880-80264894 25F1C0 0014+00 1/1 0/0 0/0 .text Set__10cCcD_ObjTgFRC13cCcD_SrcObjTg */ void cCcD_ObjTg::Set(cCcD_SrcObjTg const& src) { - mSPrm = src.mSPrm; + cCcD_ObjCommonBase::Set(src.mBase); mType = src.mType; } diff --git a/rel/d/a/d_a_bg/d_a_bg.cpp b/rel/d/a/d_a_bg/d_a_bg.cpp index 9ecc9c554a7..75de1a107a0 100644 --- a/rel/d/a/d_a_bg/d_a_bg.cpp +++ b/rel/d/a/d_a_bg/d_a_bg.cpp @@ -15,6 +15,7 @@ #include "dol2asm.h" #include "f_op/f_op_actor_mng.h" #include "m_Do/m_Do_lib.h" +#include "JSystem/J3DGraphBase/J3DMaterial.h" // // Types: @@ -618,11 +619,11 @@ int daBg_c::createHeap() { const char* name = modelData->getMaterialName()->getName(j); if (name[3] == 'M' && name[4] == 'A') { - if (!memcmp(&name[5], &"00", 2)) { + if (!memcmp(&name[5], "00", 2)) { modelFlags |= 0x1200; - } else if (!memcmp(&name[5], &"01", 2)) { + } else if (!memcmp(&name[5], "01", 2)) { modelFlags |= 0x20000000; - } else if (!memcmp(&name[5], &"12", 2) || !memcmp(&name[5], &"18", 2)) { + } else if (!memcmp(&name[5], "12", 2) || !memcmp(&name[5], "18", 2)) { field_0x5f0 = 1; } } diff --git a/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.cpp b/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.cpp index 40c75f0d852..0bacb181ed5 100644 --- a/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.cpp +++ b/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.cpp @@ -4,605 +4,363 @@ // #include "rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller.h" -#include "dol2asm.h" -#include "dolphin/types.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "d/com/d_com_inf_game.h" +#include "d/d_procname.h" -// -// Types: -// +#define MODEL_K_PURO 0 +#define MODEL_LV9_PURO 1 -struct request_of_phase_process_class {}; +#define TYPE_BOOMERANG 0 // only turns when hit with boomerang +#define TYPE_WIND 1 // automatically turns -struct csXyz {}; - -struct Vec {}; - -struct cXyz { - /* 80266AE4 */ void operator+(Vec const&) const; - - static f32 Zero[3]; -}; - -struct mDoMtx_stack_c { - /* 8000CD64 */ void transS(cXyz const&); - /* 8000CF44 */ void ZXYrotM(csXyz const&); - - static u8 now[48]; -}; - -struct fopAc_ac_c { - /* 80018B64 */ fopAc_ac_c(); -}; - -struct daObjSwPr_c { - /* 8059A5E8 */ void initBaseMtx(); - /* 8059A624 */ void setBaseMtx(); - /* 8059A670 */ void Create(); - /* 8059A808 */ void CreateHeap(); - /* 8059A888 */ void create(); - /* 8059AB04 */ void setRotateTime(); - /* 8059AB14 */ void switchCtrl(); - /* 8059AB9C */ void execute_type_boomerang(); - /* 8059ADCC */ void execute_type_wind(); - /* 8059B014 */ void execute(); - /* 8059B148 */ void draw(); - /* 8059B1AC */ void _delete(); -}; - -struct dSv_info_c { - /* 80035200 */ void onSwitch(int, int); - /* 800352B0 */ void offSwitch(int, int); -}; - -struct dKy_tevstr_c {}; - -struct J3DModelData {}; - -struct dScnKy_env_light_c { - /* 801A37C4 */ void settingTevStruct(int, cXyz*, dKy_tevstr_c*); - /* 801A4DA0 */ void setLightTevColorType_MAJI(J3DModelData*, dKy_tevstr_c*); -}; - -struct dRes_info_c {}; - -struct dRes_control_c { - /* 8003C2EC */ void getRes(char const*, s32, dRes_info_c*, int); -}; - -struct dCcD_Stts { - /* 80083860 */ void Init(int, int, fopAc_ac_c*); -}; - -struct dCcD_SrcCyl {}; - -struct dCcD_GStts { - /* 80083760 */ dCcD_GStts(); -}; - -struct dCcD_GObjInf { - /* 80083A28 */ dCcD_GObjInf(); - /* 80084460 */ void ChkTgHit(); - /* 800844F8 */ void GetTgHitObj(); - /* 80084548 */ void GetTgHitGObj(); -}; - -struct dCcD_Cyl { - /* 800848B4 */ void Set(dCcD_SrcCyl const&); -}; - -struct dAttLook_c { - /* 80073D08 */ void request(fopAc_ac_c*, f32, f32, f32, s16, int); -}; - -struct cM3dGCyl { - /* 8026F1DC */ void SetC(cXyz const&); - /* 8059AA74 */ ~cM3dGCyl(); -}; - -struct cM3dGAab { - /* 8059AABC */ ~cM3dGAab(); -}; - -struct cCcD_Obj {}; - -struct cCcS { - /* 80264BA8 */ void Set(cCcD_Obj*); -}; - -struct JAISoundID {}; - -struct Z2SeMgr { - /* 802AB984 */ void seStart(JAISoundID, Vec const*, u32, s8, f32, f32, f32, f32, u8); - /* 802AC50C */ void seStartLevel(JAISoundID, Vec const*, u32, s8, f32, f32, f32, f32, u8); -}; - -struct Z2AudioMgr { - static u8 mAudioMgrPtr[4 + 4 /* padding */]; -}; - -struct JUTNameTab { - /* 802DEAF8 */ void getName(u16) const; -}; - -struct J3DSys { - static u8 mCurrentMtx[48]; -}; - -struct J3DModel {}; - -struct J3DJoint {}; - -// -// Forward References: -// - -extern "C" static void nodeCallBack__FP8J3DJointi(); -extern "C" static void CheckCreateHeap__FP10fopAc_ac_c(); -extern "C" void initBaseMtx__11daObjSwPr_cFv(); -extern "C" void setBaseMtx__11daObjSwPr_cFv(); -extern "C" void Create__11daObjSwPr_cFv(); -extern "C" void CreateHeap__11daObjSwPr_cFv(); -extern "C" void create__11daObjSwPr_cFv(); -extern "C" void __dt__8cM3dGCylFv(); -extern "C" void __dt__8cM3dGAabFv(); -extern "C" void setRotateTime__11daObjSwPr_cFv(); -extern "C" void switchCtrl__11daObjSwPr_cFv(); -extern "C" void execute_type_boomerang__11daObjSwPr_cFv(); -extern "C" void execute_type_wind__11daObjSwPr_cFv(); -extern "C" void execute__11daObjSwPr_cFv(); -extern "C" void draw__11daObjSwPr_cFv(); -extern "C" void _delete__11daObjSwPr_cFv(); -extern "C" static void daObjSwPr_Draw__FP11daObjSwPr_c(); -extern "C" static void daObjSwPr_Execute__FP11daObjSwPr_c(); -extern "C" static void daObjSwPr_Delete__FP11daObjSwPr_c(); -extern "C" static void daObjSwPr_Create__FP10fopAc_ac_c(); -extern "C" void func_8059B26C(void* _this, u16*); -extern "C" void func_8059B288(void* _this, u8*); -extern "C" void func_8059B2A4(void* _this, s16*); -extern "C" extern char const* const d_a_obj_swpropeller__stringBase0; - -// -// External References: -// - -extern "C" void mDoMtx_YrotM__FPA4_fs(); -extern "C" void transS__14mDoMtx_stack_cFRC4cXyz(); -extern "C" void ZXYrotM__14mDoMtx_stack_cFRC5csXyz(); -extern "C" void mDoExt_modelUpdateDL__FP8J3DModel(); -extern "C" void mDoExt_J3DModel__create__FP12J3DModelDataUlUl(); -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void fopAcM_entrySolidHeap__FP10fopAc_ac_cPFP10fopAc_ac_c_iUl(); -extern "C" void fopAcM_setCullSizeBox__FP10fopAc_ac_cffffff(); -extern "C" void dComIfG_resLoad__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfG_resDelete__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfGp_getReverb__Fi(); -extern "C" void onSwitch__10dSv_info_cFii(); -extern "C" void offSwitch__10dSv_info_cFii(); -extern "C" void getRes__14dRes_control_cFPCclP11dRes_info_ci(); -extern "C" void request__10dAttLook_cFP10fopAc_ac_cfffsi(); -extern "C" void __ct__10dCcD_GSttsFv(); -extern "C" void Init__9dCcD_SttsFiiP10fopAc_ac_c(); -extern "C" void __ct__12dCcD_GObjInfFv(); -extern "C" void ChkTgHit__12dCcD_GObjInfFv(); -extern "C" void GetTgHitObj__12dCcD_GObjInfFv(); -extern "C" void GetTgHitGObj__12dCcD_GObjInfFv(); -extern "C" void Set__8dCcD_CylFRC11dCcD_SrcCyl(); -extern "C" void settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c(); -extern "C" void setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c(); -extern "C" void Set__4cCcSFP8cCcD_Obj(); -extern "C" void __pl__4cXyzCFRC3Vec(); -extern "C" void SetC__8cM3dGCylFRC4cXyz(); -extern "C" void cLib_addCalcAngleS__FPsssss(); -extern "C" void cLib_chaseAngleS__FPsss(); -extern "C" void seStart__7Z2SeMgrF10JAISoundIDPC3VecUlScffffUc(); -extern "C" void seStartLevel__7Z2SeMgrF10JAISoundIDPC3VecUlScffffUc(); -extern "C" void __dl__FPv(); -extern "C" void getName__10JUTNameTabCFUs(); -extern "C" void PSMTXCopy(); -extern "C" void __cvt_fp2unsigned(); -extern "C" void _savegpr_26(); -extern "C" void _savegpr_27(); -extern "C" void _savegpr_28(); -extern "C" void _savegpr_29(); -extern "C" void _restgpr_26(); -extern "C" void _restgpr_27(); -extern "C" void _restgpr_28(); -extern "C" void _restgpr_29(); -extern "C" void strcmp(); -extern "C" extern void* g_fopAc_Method[8]; -extern "C" extern void* g_fpcLf_Method[5 + 1 /* padding */]; -extern "C" extern void* __vt__8dCcD_Cyl[36]; -extern "C" extern void* __vt__9dCcD_Stts[11]; -extern "C" extern void* __vt__12cCcD_CylAttr[25]; -extern "C" extern void* __vt__14cCcD_ShapeAttr[22]; -extern "C" extern void* __vt__9cCcD_Stts[8]; -extern "C" u8 now__14mDoMtx_stack_c[48]; -extern "C" extern u8 g_dComIfG_gameInfo[122384]; -extern "C" extern u8 g_env_light[4880]; -extern "C" f32 Zero__4cXyz[3]; -extern "C" extern u8 j3dSys[284]; -extern "C" u8 mCurrentMtx__6J3DSys[48]; -extern "C" u8 mAudioMgrPtr__10Z2AudioMgr[4 + 4 /* padding */]; - -// -// Declarations: -// +extern "C" u16 func_8059B26C(u16*); +extern "C" u8 func_8059B288(u8*); +extern "C" s16 func_8059B2A4(s16*); /* 8059A518-8059A5C8 000078 00B0+00 1/1 0/0 0/0 .text nodeCallBack__FP8J3DJointi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void nodeCallBack(J3DJoint* param_0, int param_1) { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/nodeCallBack__FP8J3DJointi.s" +static int nodeCallBack(J3DJoint* i_joint, int param_1) { + if (param_1 == 0) { + int jnt_no = i_joint->getJntNo(); + J3DModel* model_p = j3dSys.getModel(); + daObjSwPr_c* swpr_p = (daObjSwPr_c*)model_p->getUserArea(); + + if (jnt_no == swpr_p->mKaitenJntID) { + cMtx_copy(model_p->i_getAnmMtx(jnt_no), mDoMtx_stack_c::get()); + mDoMtx_stack_c::YrotM(swpr_p->field_0x82c); + model_p->i_setAnmMtx(jnt_no, mDoMtx_stack_c::get()); + mDoMtx_copy(mDoMtx_stack_c::get(), J3DSys::mCurrentMtx); + } + } + + return 1; } -#pragma pop /* 8059A5C8-8059A5E8 000128 0020+00 1/1 0/0 0/0 .text CheckCreateHeap__FP10fopAc_ac_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void CheckCreateHeap(fopAc_ac_c* param_0) { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/CheckCreateHeap__FP10fopAc_ac_c.s" +static int CheckCreateHeap(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); } -#pragma pop /* 8059A5E8-8059A624 000148 003C+00 1/1 0/0 0/0 .text initBaseMtx__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::initBaseMtx() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/initBaseMtx__11daObjSwPr_cFv.s" +void daObjSwPr_c::initBaseMtx() { + mpModel->setBaseScale(mScale); + setBaseMtx(); } -#pragma pop /* 8059A624-8059A670 000184 004C+00 3/3 0/0 0/0 .text setBaseMtx__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::setBaseMtx() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/setBaseMtx__11daObjSwPr_cFv.s" +void daObjSwPr_c::setBaseMtx() { + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::ZXYrotM(shape_angle); + mpModel->i_setBaseTRMtx(mDoMtx_stack_c::get()); } -#pragma pop -/* ############################################################################################## */ /* 8059B2C8-8059B2D0 000000 0008+00 3/3 0/0 0/0 .rodata l_bmdName */ -SECTION_RODATA static u8 const l_bmdName[8] = { - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, -}; -COMPILER_STRIP_GATE(0x8059B2C8, &l_bmdName); +static int const l_bmdName[] = {3, 3}; /* 8059B2D0-8059B2D8 000008 0008+00 1/1 0/0 0/0 .rodata l_heap_size */ -SECTION_RODATA static u8 const l_heap_size[8] = { - 0x00, 0x00, 0x0F, 0x20, 0x00, 0x00, 0x36, 0xC0, -}; -COMPILER_STRIP_GATE(0x8059B2D0, &l_heap_size); +static u32 const l_heap_size[] = {0xF20, 0x36C0}; /* 8059B2D8-8059B31C 000010 0044+00 0/1 0/0 0/0 .rodata l_cyl_src */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const l_cyl_src[68] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x58, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x42, 0xC8, 0x00, 0x00, 0x42, 0xC8, 0x00, 0x00, +static const dCcD_SrcCyl l_cyl_src = { + { + {0, {{0, 0, 0}, {0x10040, 0x11}, 0x58}}, + {dCcD_SE_NONE, 0, 0, 0, {0}}, + {dCcD_SE_NONE, 2, 0, 0, {2}}, + {0}, + }, + { + {0.0f, 0.0f, 0.0f}, + 100.0f, + 100.0f, + }, }; -COMPILER_STRIP_GATE(0x8059B2D8, &l_cyl_src); -#pragma pop /* 8059B31C-8059B334 000054 0018+00 0/1 0/0 0/0 .rodata l_cull_size */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const l_cull_size[24] = { - 0xC3, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x16, 0x00, 0x00, - 0x43, 0x16, 0x00, 0x00, 0x43, 0x16, 0x00, 0x00, 0x43, 0x16, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x8059B31C, &l_cull_size); -#pragma pop +static f32 const l_cull_size[] = {-150.0f, 0.0f, -150.0f, 150.0f, 150.0f, 150.0f}; /* 8059B334-8059B33C 00006C 0006+02 0/0 0/0 0/0 .rodata l_r00_rot_time */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const l_r00_rot_time[6 + 2 /* padding */] = { - 0x00, - 0xBE, - 0x00, - 0x94, - 0x00, - 0x64, - /* padding */ - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x8059B334, &l_r00_rot_time); -#pragma pop - -/* 8059B33C-8059B340 000074 0004+00 0/1 0/0 0/0 .rodata @3747 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3747 = 100.0f; -COMPILER_STRIP_GATE(0x8059B33C, &lit_3747); -#pragma pop - -/* 8059B360-8059B360 000098 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8059B360 = "K_prop00"; -SECTION_DEAD static char const* const stringBase_8059B369 = "Lv9_puro"; -SECTION_DEAD static char const* const stringBase_8059B372 = "kaiten"; -SECTION_DEAD static char const* const stringBase_8059B379 = "D_MN05"; -#pragma pop +// This was used for this object's HIO, which was removed in retail +static s16 const l_r00_rot_time[] = {190, 148, 100}; /* 8059B380-8059B388 -00001 0008+00 3/3 0/0 0/0 .data l_arcName */ -SECTION_DATA static void* l_arcName[2] = { - (void*)&d_a_obj_swpropeller__stringBase0, - (void*)(((char*)&d_a_obj_swpropeller__stringBase0) + 0x9), -}; +static char* l_arcName[] = {"K_prop00", "Lv9_puro"}; /* 8059B388-8059B38C -00001 0004+00 1/1 0/0 0/0 .data l_joint_name */ -SECTION_DATA static void* l_joint_name = (void*)(((char*)&d_a_obj_swpropeller__stringBase0) + 0x12); +static char* l_joint_name = "kaiten"; /* 8059A670-8059A808 0001D0 0198+00 1/1 0/0 0/0 .text Create__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::Create() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/Create__11daObjSwPr_cFv.s" +int daObjSwPr_c::Create() { + initBaseMtx(); + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + + mCcStts.Init(0xFF, 0xFF, this); + mCyl1.Set(l_cyl_src); + mCyl1.SetStts(&mCcStts); + + if (mNameArg == 1) { + mCyl2.Set(l_cyl_src); + mCyl2.SetStts(&mCcStts); + mCyl2.SetTgType(0x200); + mCyl2.SetTgMtrl(3); + } + + fopAcM_setCullSizeBox(this, l_cull_size[0], l_cull_size[1], l_cull_size[2], l_cull_size[3], + l_cull_size[4], l_cull_size[5]); + + JUTNameTab* jnt_nt_p = mpModel->getModelData()->getJointTree().getJointName(); + mKaitenJntID = 0xFFFF; + + for (u16 i = 0; i < mpModel->getModelData()->getJointNum(); i++) { + if (strcmp(jnt_nt_p->getName(i), l_joint_name) == 0) { + mKaitenJntID = i; + } + } + + J3DJoint* jnt = mpModel->getModelData()->getJointNodePointer(mKaitenJntID); + jnt->setCallBack(nodeCallBack); + mpModel->setUserArea((u32)this); + + mEyePos.y += 100.0f; + + // Set CullSizeFar for Outside Bridge room in Forest Temple + if (strcmp(dComIfGp_getStartStageName(), "D_MN05") == 0 && fopAcM_GetRoomNo(this) == 4) { + fopAcM_setCullSizeFar(this, 100.0f); + } + + return 1; } -#pragma pop /* 8059A808-8059A888 000368 0080+00 1/1 0/0 0/0 .text CreateHeap__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::CreateHeap() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/CreateHeap__11daObjSwPr_cFv.s" +int daObjSwPr_c::CreateHeap() { + J3DModelData* modelData = + (J3DModelData*)dComIfG_getObjectRes(l_arcName[mModelType], l_bmdName[mModelType]); + mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); + + if (mpModel == NULL) { + return 0; + } + + return 1; } -#pragma pop - -/* ############################################################################################## */ -/* 8059B38C-8059B3AC -00001 0020+00 1/0 0/0 0/0 .data l_daObjSwPr_Method */ -SECTION_DATA static void* l_daObjSwPr_Method[8] = { - (void*)daObjSwPr_Create__FP10fopAc_ac_c, - (void*)daObjSwPr_Delete__FP11daObjSwPr_c, - (void*)daObjSwPr_Execute__FP11daObjSwPr_c, - (void*)NULL, - (void*)daObjSwPr_Draw__FP11daObjSwPr_c, - (void*)NULL, - (void*)NULL, - (void*)NULL, -}; - -/* 8059B3AC-8059B3DC -00001 0030+00 0/0 0/0 1/0 .data g_profile_Obj_Swpropeller */ -SECTION_DATA extern void* g_profile_Obj_Swpropeller[12] = { - (void*)0xFFFFFFFD, (void*)0x0003FFFD, - (void*)0x005E0000, (void*)&g_fpcLf_Method, - (void*)0x00000840, (void*)NULL, - (void*)NULL, (void*)&g_fopAc_Method, - (void*)0x01C00000, (void*)&l_daObjSwPr_Method, - (void*)0x00044100, (void*)0x000E0000, -}; - -/* 8059B3DC-8059B3E8 00005C 000C+00 2/2 0/0 0/0 .data __vt__8cM3dGCyl */ -SECTION_DATA extern void* __vt__8cM3dGCyl[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__8cM3dGCylFv, -}; - -/* 8059B3E8-8059B3F4 000068 000C+00 2/2 0/0 0/0 .data __vt__8cM3dGAab */ -SECTION_DATA extern void* __vt__8cM3dGAab[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__8cM3dGAabFv, -}; /* 8059A888-8059AA74 0003E8 01EC+00 1/1 0/0 0/0 .text create__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::create() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/func_8059A888.s" -} -#pragma pop +int daObjSwPr_c::create() { + if (!fopAcM_CheckCondition(this, 8)) { + new (this) daObjSwPr_c(); + fopAcM_OnCondition(this, 8); + } -/* 8059AA74-8059AABC 0005D4 0048+00 1/0 0/0 0/0 .text __dt__8cM3dGCylFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm cM3dGCyl::~cM3dGCyl() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/__dt__8cM3dGCylFv.s" -} -#pragma pop + mNameArg = getNameArg(); -/* 8059AABC-8059AB04 00061C 0048+00 1/0 0/0 0/0 .text __dt__8cM3dGAabFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm cM3dGAab::~cM3dGAab() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/__dt__8cM3dGAabFv.s" + if (getMdlType() == 15 || getMdlType() == 0) { + mModelType = MODEL_K_PURO; + } else if (getMdlType() == 1) { + mModelType = MODEL_LV9_PURO; + } + + int phase = dComIfG_resLoad(&mPhase, l_arcName[mModelType]); + if (phase == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(this, CheckCreateHeap, l_heap_size[mModelType])) { + return cPhs_ERROR_e; + } + + if (!Create()) { + return cPhs_ERROR_e; + } + } + + return phase; } -#pragma pop /* 8059AB04-8059AB14 000664 0010+00 1/1 0/0 0/0 .text setRotateTime__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::setRotateTime() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/setRotateTime__11daObjSwPr_cFv.s" +int daObjSwPr_c::setRotateTime() { + field_0x83a = 0; + return 100; } -#pragma pop /* 8059AB14-8059AB9C 000674 0088+00 1/1 0/0 0/0 .text switchCtrl__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::switchCtrl() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/switchCtrl__11daObjSwPr_cFv.s" +void daObjSwPr_c::switchCtrl() { + int sw = getSwbit(); + + if (mRotateSpeed == 0) { + i_fopAcM_offSwitch(this, sw); + } else if (func_8059B2A4(&mSwDelayTimer) == 0) { + i_fopAcM_onSwitch(this, sw); + } } -#pragma pop - -/* ############################################################################################## */ -/* 8059B340-8059B344 000078 0004+00 1/2 0/0 0/0 .rodata @3983 */ -SECTION_RODATA static f32 const lit_3983 = 1.0f; -COMPILER_STRIP_GATE(0x8059B340, &lit_3983); - -/* 8059B344-8059B348 00007C 0004+00 1/2 0/0 0/0 .rodata @3984 */ -SECTION_RODATA static f32 const lit_3984 = -1.0f; -COMPILER_STRIP_GATE(0x8059B344, &lit_3984); /* 8059AB9C-8059ADCC 0006FC 0230+00 1/1 0/0 0/0 .text execute_type_boomerang__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::execute_type_boomerang() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/execute_type_boomerang__11daObjSwPr_cFv.s" +void daObjSwPr_c::execute_type_boomerang() { + bool tg_hit = mCyl1.ChkTgHit(); + + field_0x82c += mRotateSpeed; + cLib_chaseAngleS(&mRotateSpeed, 0, mRotateInitSpeed / mRotateTime); + + BOOL start_rotate = false; + if (mCyl1.ChkTgHit() && field_0x838 == 0) { + cCcD_Obj* tg_obj = mCyl1.GetTgHitObj(); + + if (tg_obj != NULL && ((tg_obj->ChkAtType(AT_TYPE_40) && mCyl1.GetTgHitGObj() != NULL && + mCyl1.GetTgHitGObj()->GetAtMtrl() == 3) || + tg_obj->ChkAtType(AT_TYPE_BOOMERANG))) + { + start_rotate = true; + } + + mCyl1.ClrTgHit(); + } + + if (start_rotate) { + field_0x839++; + mRotateInitSpeed = 0x2000; + mRotateSpeed = 0x2000; + mRotateTime = setRotateTime(); + fopAcM_seStart(this, Z2SE_OBJ_BOOMSHTR_HIT_SW, 0); + + // Set delay to 0 if in Forest Temple Central Room + if (strcmp(dComIfGp_getStartStageName(), "D_MN05") == 0 && fopAcM_GetRoomNo(this) == 0) { + mSwDelayTimer = 0; + } else { + mSwDelayTimer = 8; + } + } + + if (func_8059B288(&field_0x83a) != 0) { + mRotateSpeed = 0x2000; + } + + switchCtrl(); + setBaseMtx(); + + cXyz pos_offset(cXyz::Zero); + mCyl1.SetC(current.pos + pos_offset); + dComIfG_Ccsp()->Set(&mCyl1); + + field_0x838 = tg_hit; } -#pragma pop /* 8059ADCC-8059B014 00092C 0248+00 1/1 0/0 0/0 .text execute_type_wind__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::execute_type_wind() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/execute_type_wind__11daObjSwPr_cFv.s" +void daObjSwPr_c::execute_type_wind() { + s16 target_speed = 0; + int sw = getSwbit(); + BOOL var_r29 = 0; + + if (mCyl2.ChkTgHit()) { + if (mCyl2.GetTgHitGObj() != NULL) { + if (mCyl2.GetTgHitGObj()->GetAtMtrl() == 3 && mCyl2.GetTgHitObj() != NULL) { + target_speed = 7000; + mRotateInitSpeed = 7000; + var_r29 = 1; + + field_0x834++; + if (field_0x834 == 20) { + i_fopAcM_onSwitch(this, sw); + } else if (field_0x834 == 25) { + i_fopAcM_offSwitch(this, sw); + } + } + } + } else { + field_0x834 = 0; + } + + if (mCyl1.ChkTgHit()) { + if (mCyl1.GetTgHitGObj() != NULL && mCyl1.GetTgHitGObj()->GetAtMtrl() == 3) { + cCcD_Obj* tg_obj = mCyl1.GetTgHitObj(); + + if (tg_obj != NULL && + (tg_obj->ChkAtType(AT_TYPE_40) || tg_obj->ChkAtType(AT_TYPE_BOOMERANG))) + { + mRotateSpeed = 7000; + mRotateInitSpeed = mRotateSpeed; + i_fopAcM_onSwitch(this, sw); + mSwOffDelayTimer = 10; + + if (getSwbit2() != 0xFF) { + i_fopAcM_onSwitch(this, getSwbit2()); + } + } + } + } else if (mSwOffDelayTimer != 0 && func_8059B26C(&mSwOffDelayTimer) == 0) { + i_fopAcM_offSwitch(this, sw); + } + + cLib_addCalcAngleS(&mRotateSpeed, target_speed, 30, 100, 50); + field_0x82c += mRotateSpeed; + + setBaseMtx(); + + mCyl1.SetC(current.pos); + dComIfG_Ccsp()->Set(&mCyl1); + mCyl2.SetC(current.pos); + dComIfG_Ccsp()->Set(&mCyl2); + + field_0x83d = var_r29; } -#pragma pop - -/* ############################################################################################## */ -/* 8059B348-8059B34C 000080 0004+00 0/1 0/0 0/0 .rodata @4086 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4086 = 127.0f; -COMPILER_STRIP_GATE(0x8059B348, &lit_4086); -#pragma pop - -/* 8059B34C-8059B350 000084 0004+00 0/1 0/0 0/0 .rodata @4087 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4087 = 1200.0f; -COMPILER_STRIP_GATE(0x8059B34C, &lit_4087); -#pragma pop - -/* 8059B350-8059B354 000088 0004+00 0/1 0/0 0/0 .rodata @4088 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4088 = 600.0f; -COMPILER_STRIP_GATE(0x8059B350, &lit_4088); -#pragma pop - -/* 8059B354-8059B358 00008C 0004+00 0/1 0/0 0/0 .rodata @4089 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4089[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x8059B354, &lit_4089); -#pragma pop - -/* 8059B358-8059B360 000090 0008+00 0/1 0/0 0/0 .rodata @4091 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4091[8] = { - 0x43, 0x30, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x8059B358, &lit_4091); -#pragma pop /* 8059B014-8059B148 000B74 0134+00 1/1 0/0 0/0 .text execute__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::execute() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/execute__11daObjSwPr_cFv.s" +int daObjSwPr_c::execute() { + switch (mNameArg) { + case TYPE_BOOMERANG: + execute_type_boomerang(); + break; + case TYPE_WIND: + execute_type_wind(); + break; + } + + if (mRotateSpeed != 0 && mRotateInitSpeed != 0) { + fopAcM_seStartLevel(this, Z2SE_OBJ_BOOMSHTR_SWITCH, + ((f32)mRotateSpeed / (f32)mRotateInitSpeed) * 127.0f); + } + + dComIfGp_att_LookRequest(this, 1200.0f, 600.0f, 0.0f, 27000, 2); + return 1; } -#pragma pop /* 8059B148-8059B1AC 000CA8 0064+00 1/1 0/0 0/0 .text draw__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::draw() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/draw__11daObjSwPr_cFv.s" +int daObjSwPr_c::draw() { + g_env_light.settingTevStruct(0x10, ¤t.pos, &mTevStr); + g_env_light.setLightTevColorType_MAJI(mpModel, &mTevStr); + + mDoExt_modelUpdateDL(mpModel); + return 1; } -#pragma pop /* 8059B1AC-8059B1EC 000D0C 0040+00 1/1 0/0 0/0 .text _delete__11daObjSwPr_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daObjSwPr_c::_delete() { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/_delete__11daObjSwPr_cFv.s" +int daObjSwPr_c::_delete() { + dComIfG_resDelete(&mPhase, l_arcName[mModelType]); + return 1; } -#pragma pop /* 8059B1EC-8059B20C 000D4C 0020+00 1/0 0/0 0/0 .text daObjSwPr_Draw__FP11daObjSwPr_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daObjSwPr_Draw(daObjSwPr_c* param_0) { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/daObjSwPr_Draw__FP11daObjSwPr_c.s" +static int daObjSwPr_Draw(daObjSwPr_c* i_this) { + return i_this->draw(); } -#pragma pop /* 8059B20C-8059B22C 000D6C 0020+00 1/0 0/0 0/0 .text daObjSwPr_Execute__FP11daObjSwPr_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daObjSwPr_Execute(daObjSwPr_c* param_0) { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/daObjSwPr_Execute__FP11daObjSwPr_c.s" +static int daObjSwPr_Execute(daObjSwPr_c* i_this) { + return i_this->execute(); } -#pragma pop /* 8059B22C-8059B24C 000D8C 0020+00 1/0 0/0 0/0 .text daObjSwPr_Delete__FP11daObjSwPr_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daObjSwPr_Delete(daObjSwPr_c* param_0) { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/daObjSwPr_Delete__FP11daObjSwPr_c.s" +static int daObjSwPr_Delete(daObjSwPr_c* i_this) { + return i_this->_delete(); } -#pragma pop /* 8059B24C-8059B26C 000DAC 0020+00 1/0 0/0 0/0 .text daObjSwPr_Create__FP10fopAc_ac_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daObjSwPr_Create(fopAc_ac_c* param_0) { - nofralloc -#include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/daObjSwPr_Create__FP10fopAc_ac_c.s" +static int daObjSwPr_Create(fopAc_ac_c* i_this) { + return static_cast(i_this)->create(); } -#pragma pop /* 8059B26C-8059B288 000DCC 001C+00 1/1 0/0 0/0 .text cLib_calcTimer__FPUs */ #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -extern "C" asm void func_8059B26C(void* _this, u16* param_0) { +extern "C" asm u16 func_8059B26C(u16* param_0) { nofralloc #include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/func_8059B26C.s" } @@ -612,7 +370,7 @@ extern "C" asm void func_8059B26C(void* _this, u16* param_0) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -extern "C" asm void func_8059B288(void* _this, u8* param_0) { +extern "C" asm u8 func_8059B288(u8* param_0) { nofralloc #include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/func_8059B288.s" } @@ -622,10 +380,33 @@ extern "C" asm void func_8059B288(void* _this, u8* param_0) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -extern "C" asm void func_8059B2A4(void* _this, s16* param_0) { +extern "C" asm s16 func_8059B2A4(s16* param_0) { nofralloc #include "asm/rel/d/a/obj/d_a_obj_swpropeller/d_a_obj_swpropeller/func_8059B2A4.s" } #pragma pop -/* 8059B360-8059B360 000098 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ +/* 8059B38C-8059B3AC -00001 0020+00 1/0 0/0 0/0 .data l_daObjSwPr_Method */ +static actor_method_class l_daObjSwPr_Method = { + (process_method_func)daObjSwPr_Create, (process_method_func)daObjSwPr_Delete, + (process_method_func)daObjSwPr_Execute, (process_method_func)NULL, + (process_method_func)daObjSwPr_Draw, +}; + +/* 8059B3AC-8059B3DC -00001 0030+00 0/0 0/0 1/0 .data g_profile_Obj_Swpropeller */ +extern actor_process_profile_definition g_profile_Obj_Swpropeller = { + -3, + 3, + -3, + PROC_Obj_Swpropeller, + &g_fpcLf_Method.mBase, + sizeof(daObjSwPr_c), + 0, + 0, + &g_fopAc_Method.base, + 448, + &l_daObjSwPr_Method, + 0x44100, + 0, + 14, +}; diff --git a/src/d/kankyo/d_kankyo.cpp b/src/d/kankyo/d_kankyo.cpp index 4a803405ce5..0cd0bd0daa0 100644 --- a/src/d/kankyo/d_kankyo.cpp +++ b/src/d/kankyo/d_kankyo.cpp @@ -4,12 +4,14 @@ // #include "d/kankyo/d_kankyo.h" -#include "MSL_C/string.h" #include "JSystem/J3DGraphBase/J3DMatBlock.h" +#include "JSystem/J3DGraphBase/J3DMaterial.h" +#include "MSL_C/string.h" #include "SSystem/SComponent/c_counter.h" #include "SSystem/SComponent/c_math.h" #include "d/com/d_com_inf_game.h" #include "d/kankyo/d_kankyo_data.h" +#include "d/kankyo/d_kankyo_rain.h" #include "d/meter/d_meter2_info.h" #include "d/msg/d_msg_object.h" #include "dol2asm.h" @@ -374,7 +376,8 @@ static s32 dKy_sense_pat_get() { // Room is Lake if (dComIfGp_roomControl_getStayNo() == 0 && dComIfGs_isSaveSwitch(0x11) && - !dComIfGs_isSaveSwitch(0x75)) { + !dComIfGs_isSaveSwitch(0x75)) + { pat = 2; } @@ -383,7 +386,8 @@ static s32 dKy_sense_pat_get() { } } // Stage is Zora's Domain - else if (!strcmp(dComIfGp_getStartStageName(), "F_SP113")) { + else if (!strcmp(dComIfGp_getStartStageName(), "F_SP113")) + { if (dComIfGs_sense_type_change_Get() > 0) { pat = 13; } else { @@ -391,19 +395,23 @@ static s32 dKy_sense_pat_get() { } } // Stage is Faron Woods Cave - else if (!strcmp(dComIfGp_getStartStageName(), "D_SB10")) { + else if (!strcmp(dComIfGp_getStartStageName(), "D_SB10")) + { pat = 1; } // Stage is Zora's River - else if (!strcmp(dComIfGp_getStartStageName(), "F_SP112")) { + else if (!strcmp(dComIfGp_getStartStageName(), "F_SP112")) + { pat = 3; } // Stage is Upper Zora's River - else if (!strcmp(dComIfGp_getStartStageName(), "F_SP126")) { + else if (!strcmp(dComIfGp_getStartStageName(), "F_SP126")) + { pat = 6; } // Stage is Snowpeak - else if (!strcmp(dComIfGp_getStartStageName(), "F_SP114")) { + else if (!strcmp(dComIfGp_getStartStageName(), "F_SP114")) + { pat = 4; } // Stage is Forest Temple or Goron Mines or Goron Stockcave or Grotto @@ -414,20 +422,24 @@ static s32 dKy_sense_pat_get() { !memcmp(dComIfGp_getStartStageName(), "D_SB06", 6) || !memcmp(dComIfGp_getStartStageName(), "D_SB07", 6) || !memcmp(dComIfGp_getStartStageName(), "D_SB08", 6) || - !memcmp(dComIfGp_getStartStageName(), "D_SB09", 6)) { + !memcmp(dComIfGp_getStartStageName(), "D_SB09", 6)) + { pat = 5; } // Stage is Stallord arena or Argorok arena else if (!strcmp(dComIfGp_getStartStageName(), "D_MN10A") || - !strcmp(dComIfGp_getStartStageName(), "D_MN07A")) { + !strcmp(dComIfGp_getStartStageName(), "D_MN07A")) + { pat = 14; } // Stage is Death Sword arena - else if (!strcmp(dComIfGp_getStartStageName(), "D_MN10B")) { + else if (!strcmp(dComIfGp_getStartStageName(), "D_MN10B")) + { pat = 15; } // Stage is Arbiter's Grounds - else if (!strcmp(dComIfGp_getStartStageName(), "D_MN10")) { + else if (!strcmp(dComIfGp_getStartStageName(), "D_MN10")) + { pat = 8; // Room is Central Poe room if (dComIfGp_roomControl_getStayNo() == 2) { @@ -438,25 +450,29 @@ static s32 dKy_sense_pat_get() { } } // Stage is Blizzeta arena - else if (!strcmp(dComIfGp_getStartStageName(), "D_MN11A")) { + else if (!strcmp(dComIfGp_getStartStageName(), "D_MN11A")) + { pat = 4; } // Stage is Snowpeak Ruins or Darkhammer or Ice Puzzle cave else if (!strcmp(dComIfGp_getStartStageName(), "D_MN11") || !strcmp(dComIfGp_getStartStageName(), "D_MN11B") || - !memcmp(dComIfGp_getStartStageName(), "D_SB00", 6)) { + !memcmp(dComIfGp_getStartStageName(), "D_SB00", 6)) + { pat = 7; // Stage is Snowpeak Ruins and Room is Courtyard if (!strcmp(dComIfGp_getStartStageName(), "D_MN11") && - dComIfGp_roomControl_getStayNo() == 4) { + dComIfGp_roomControl_getStayNo() == 4) + { pat = 4; } } // Stage is Ganondorf Field or Ganondorf Defeated or Castle Town else if (!strcmp(dComIfGp_getStartStageName(), "D_MN09B") || !strcmp(dComIfGp_getStartStageName(), "D_MN09C") || - !strcmp(dComIfGp_getStartStageName(), "F_SP116")) { + !strcmp(dComIfGp_getStartStageName(), "F_SP116")) + { pat = 1; } // Stage is Temple of Time or City in the Sky or Hyrule Castle Throne Room or @@ -468,20 +484,24 @@ static s32 dKy_sense_pat_get() { !strcmp(dComIfGp_getStartStageName(), "R_SP300") || !strcmp(dComIfGp_getStartStageName(), "R_SP301") || !strcmp(dComIfGp_getStartStageName(), "D_MN01") || - !strcmp(dComIfGp_getStartStageName(), "D_MN01B")) { + !strcmp(dComIfGp_getStartStageName(), "D_MN01B")) + { pat = 8; } // Stage is Morpheel arena - else if (!strcmp(dComIfGp_getStartStageName(), "D_MN01A")) { + else if (!strcmp(dComIfGp_getStartStageName(), "D_MN01A")) + { pat = 14; } // Stage is Palace of Twilight - else if (!memcmp(dComIfGp_getStartStageName(), "D_MN08", 6)) { + else if (!memcmp(dComIfGp_getStartStageName(), "D_MN08", 6)) + { pat = 9; } // Stage is Gorge Cave or Lake Hylia Cave else if (!memcmp(dComIfGp_getStartStageName(), "D_SB02", 6) || - !memcmp(dComIfGp_getStartStageName(), "D_SB03", 6)) { + !memcmp(dComIfGp_getStartStageName(), "D_SB03", 6)) + { pat = 10; } // Stage is Ordon Village Interiors or Faron Woods Interiors or @@ -493,23 +513,27 @@ static s32 dKy_sense_pat_get() { !strcmp(dComIfGp_getStartStageName(), "R_SP116") || !strcmp(dComIfGp_getStartStageName(), "R_SP161") || !strcmp(dComIfGp_getStartStageName(), "F_SP110") || - !strcmp(dComIfGp_getStartStageName(), "R_SP107")) { + !strcmp(dComIfGp_getStartStageName(), "R_SP107")) + { pat = 11; // Stage is Ordon Village and Room is Sera's Shop if (!strcmp(dComIfGp_getStartStageName(), "R_SP01") && - dComIfGp_roomControl_getStayNo() == 1) { + dComIfGp_roomControl_getStayNo() == 1) + { pat = 12; } } // Stage is Hidden Village interiors or Castle Town interiors or Fishing Pond interiors else if (!strcmp(dComIfGp_getStartStageName(), "R_SP128") || !strcmp(dComIfGp_getStartStageName(), "R_SP160") || - !strcmp(dComIfGp_getStartStageName(), "R_SP127")) { + !strcmp(dComIfGp_getStartStageName(), "R_SP127")) + { pat = 12; } // Stage is Kakariko Village interiors - else if (!strcmp(dComIfGp_getStartStageName(), "R_SP109")) { + else if (!strcmp(dComIfGp_getStartStageName(), "R_SP109")) + { pat = 12; // Room is Sanctuary or Inn @@ -707,6 +731,73 @@ SECTION_SDATA2 static f32 lit_4363 = 4750.0f; /* 8019CCDC-8019CE5C 19761C 0180+00 4/3 0/0 0/0 .text dKy_WolfPowerup_FogNearFar__FPfPf */ +// matches with literals +#ifdef NONMATCHING +static void dKy_WolfPowerup_FogNearFar(f32* near_p, f32* far_p) { + switch (dKy_sense_pat_get()) { + case 1: + *near_p = 750.0f; + *far_p = 1750.0f; + break; + case 2: + *near_p = 5000.0f; + *far_p = 40000.0f; + break; + case 3: + *near_p = 4000.0f; + *far_p = 12000.0f; + break; + case 4: + *near_p = 500.0f; + *far_p = 2250.0f; + break; + case 5: + *near_p = 1000.0f; + *far_p = 1800.0f; + break; + case 6: + *near_p = 1000.0f; + *far_p = 2750.0f; + break; + case 7: + *near_p = 750.0f; + *far_p = 1750.0f; + break; + case 8: + *near_p = 750.0f; + *far_p = 1750.0f; + break; + case 9: + *near_p = 2000.0f; + *far_p = 3000.0f; + break; + case 10: + *near_p = 300.0f; + *far_p = 700.0f; + break; + case 11: + *near_p = 750.0f; + *far_p = 1500.0f; + break; + case 12: + *near_p = 500.0f; + *far_p = 1250.0f; + break; + case 13: + *near_p = 1000.0f; + *far_p = 80000.0f; + break; + case 14: + *near_p = 1250.0f; + *far_p = 3000.0f; + break; + case 15: + *near_p = 1000.0f; + *far_p = 4750.0f; + break; + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -715,6 +806,7 @@ static asm void dKy_WolfPowerup_FogNearFar(f32* param_0, f32* param_1) { #include "asm/d/kankyo/d_kankyo/dKy_WolfPowerup_FogNearFar__FPfPf.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80453C0C-80453C10 00220C 0004+00 46/46 0/0 0/0 .sdata2 @4409 */ @@ -737,6 +829,16 @@ SECTION_SDATA2 static u8 lit_4412[8] = { }; /* 8019CE5C-8019CFE4 19779C 0188+00 1/1 0/0 0/0 .text dKy_pos2_get_angle__FP4cXyzP4cXyzPsPs */ +// matches with literals +#ifdef NONMATCHING +static void dKy_pos2_get_angle(cXyz* param_0, cXyz* param_1, s16* param_2, s16* param_3) { + cXyz sp28; + sp28 = *param_0 - *param_1; + + *param_2 = cM_atan2s(-sp28.y, sp28.absXZ()); + *param_3 = cM_atan2s(sp28.x, sp28.z); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -745,6 +847,7 @@ static asm void dKy_pos2_get_angle(cXyz* param_0, cXyz* param_1, s16* param_2, s #include "asm/d/kankyo/d_kankyo/dKy_pos2_get_angle__FP4cXyzP4cXyzPsPs.s" } #pragma pop +#endif /* 8042CA54-8042DD64 059774 1310+00 116/118 128/128 649/649 .bss g_env_light */ dScnKy_env_light_c g_env_light; @@ -1075,7 +1178,7 @@ SECTION_SDATA2 static f32 lit_4852[1 + 1 /* padding */] = { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void dKy_light_influence_id(cXyz param_0, int param_1) { +static asm int dKy_light_influence_id(cXyz param_0, int param_1) { nofralloc #include "asm/d/kankyo/d_kankyo/dKy_light_influence_id__F4cXyzi.s" } @@ -1086,7 +1189,7 @@ static asm void dKy_light_influence_id(cXyz param_0, int param_1) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void dKy_eflight_influence_id(cXyz param_0, int param_1) { +static asm int dKy_eflight_influence_id(cXyz param_0, int param_1) { nofralloc #include "asm/d/kankyo/d_kankyo/dKy_eflight_influence_id__F4cXyzi.s" } @@ -1307,6 +1410,7 @@ SECTION_SDATA2 static f32 lit_5348 = 360.0f; SECTION_SDATA2 static f32 lit_5349 = 0.012000000104308128f; /* 8019EC98-8019F264 1995D8 05CC+00 1/1 0/0 0/0 .text envcolor_init__Fv */ +// matches with literals #ifdef NONMATCHING static void envcolor_init() { stage_palette_info_class* palette = dComIfGp_getStagePaletteInfo(); @@ -1396,7 +1500,8 @@ static void envcolor_init() { g_env_light.field_0xecc = 0.0f; if (!strcmp(dComIfGp_getStartStageName(), "F_SP127") || - !strcmp(dComIfGp_getStartStageName(), "R_SP127")) { + !strcmp(dComIfGp_getStartStageName(), "R_SP127")) + { if (g_env_light.field_0x12cc >= 7) { g_env_light.mColpatWeather = 2; } else if (g_env_light.field_0x12cc != 0) { @@ -1854,7 +1959,8 @@ void dScnKy_env_light_c::setDaytime() { // Stage is Fishing Pond or Hena's Hut if (!strcmp(dComIfGp_getStartStageName(), "F_SP127") || - !strcmp(dComIfGp_getStartStageName(), "R_SP127")) { + !strcmp(dComIfGp_getStartStageName(), "R_SP127")) + { f32 current_time = mDaytime; if (current_time >= 300.0f || current_time <= 60.0f) { mDaytime += mTimeSpeed; @@ -1904,14 +2010,9 @@ asm void dScnKy_env_light_c::setDaytime() { #endif /* 8019F780-8019F788 19A0C0 0008+00 1/1 0/0 0/0 .text GetTimePass__20dStage_roomControl_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 dStage_roomControl_c::GetTimePass() { - nofralloc -#include "asm/d/kankyo/d_kankyo/GetTimePass__20dStage_roomControl_cFv.s" +s8 dStage_roomControl_c::GetTimePass() { + return m_time_pass; } -#pragma pop /* ############################################################################################## */ /* 80394C6C-80394C6C 0212CC 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ @@ -1938,8 +2039,83 @@ SECTION_SDATA2 static f32 lit_5617 = 0.01745329238474369f; /* 80453CDC-80453CE0 0022DC 0004+00 1/1 0/0 0/0 .sdata2 @5618 */ SECTION_SDATA2 static f32 lit_5618 = -48000.0f; +// setSunpos calls these functions as inlines somehow +// these need to be moved to MSL_C once an appropriate solution is found +inline float sinf(float x) { + return sin(x); +} + +inline float cosf(float x) { + return cos(x); +} + /* 8019F788-8019FA08 19A0C8 0280+00 1/1 0/0 0/0 .text setSunpos__18dScnKy_env_light_cFv */ +// matches with literals +#ifdef NONMATCHING +void dScnKy_env_light_c::setSunpos() { + camera_class* camera_p = dComIfGp_getCamera(0); + cXyz sp8; + + if (camera_p != NULL && strcmp(dComIfGp_getStartStageName(), "F_SP200") != 0) { + f32 var_f3 = g_env_light.mDaytime; + f32 var_f31; + f32 var_f3_2; + f32 var_f30; + + if (var_f3 >= 90.0f && var_f3 <= 270.0f) { + f32 percent = get_parcent(270.0f, 90.0f, var_f3); + var_f31 = (percent * 150.0f) + 105.0f; + } else { + if (var_f3 < 90.0f) { + var_f3 += 360.0f; + } + + f32 percent = get_parcent(450.0f, 270.0f, var_f3); + var_f31 = (percent * 210.0f) + 255.0f; + if (var_f31 > 360.0f) { + var_f31 -= 360.0f; + } + } + + var_f3_2 = 180.0f + g_env_light.mDaytime; + if (var_f3_2 >= 360.0f) { + var_f3_2 -= 360.0f; + } + + if (var_f3_2 >= 90.0f && var_f3_2 <= 270.0f) { + f32 percent = get_parcent(270.0f, 90.0f, var_f3_2); + var_f30 = (percent * 150.0f) + 105.0f; + } else { + if (var_f3_2 < 90.0f) { + var_f3_2 += 360.0f; + } + + f32 percent = get_parcent(450.0f, 270.0f, var_f3_2); + var_f30 = (percent * 210.0f) + 255.0f; + if (var_f30 > 360.0f) { + var_f30 -= 360.0f; + } + } + + sp8.x = sinf(var_f31 * 0.01745329238474369f) * 80000.0f; + sp8.y = cosf(var_f31 * 0.01745329238474369f) * 80000.0f; + sp8.z = cosf(var_f31 * 0.01745329238474369f) * -48000.0f; + + mSunPos.x = camera_p->mLookat.mEye.x + sp8.x; + mSunPos.y = camera_p->mLookat.mEye.y - sp8.y; + mSunPos.z = camera_p->mLookat.mEye.z + sp8.z; + + sp8.x = sinf(var_f30 * 0.01745329238474369f) * 80000.0f; + sp8.y = cosf(var_f30 * 0.01745329238474369f) * 80000.0f; + sp8.z = cosf(var_f30 * 0.01745329238474369f) * -48000.0f; + + mMoonPos.x = sp8.x; + mMoonPos.y = -sp8.y; + mMoonPos.z = sp8.z; + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -1948,6 +2124,7 @@ asm void dScnKy_env_light_c::setSunpos() { #include "asm/d/kankyo/d_kankyo/setSunpos__18dScnKy_env_light_cFv.s" } #pragma pop +#endif /* 8019FA08-8019FA10 19A348 0008+00 3/3 5/5 1/1 .text getDaytime__18dScnKy_env_light_cFv */ @@ -1961,11 +2138,11 @@ s32 dKy_getdaytime_hour() { } /* 8019FA3C-8019FAB8 19A37C 007C+00 1/1 1/1 26/26 .text dKy_getdaytime_minute__Fv */ -// just small regalloc +// matches with literals #ifdef NONMATCHING s32 dKy_getdaytime_minute() { - f32 tmp = ((s32)(dComIfGs_getTime() * lit_4850) % 15000000); - return tmp / lit_4850 / lit_5347 * lit_5554; + f32 tmp = ((s32)(dComIfGs_getTime() * 1000000.0f) % 15000000); + return tmp / 1000000.0f / 15.0f * 60.0f; } #else #pragma push @@ -1995,14 +2172,21 @@ s32 dKy_getDarktime_hour() { } /* 8019FB30-8019FBBC 19A470 008C+00 0/0 0/0 19/19 .text dKy_getDarktime_minute__Fv */ +#ifdef NONMATCHING +s32 dKy_getDarktime_minute() { + f32 tmp = ((s32)(g_env_light.getDarkDaytime() * 1000000.0f) % 15000000); + return tmp / 1000000.0f / 15.0f * 60.0f; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void dKy_getDarktime_minute() { +asm s32 dKy_getDarktime_minute() { nofralloc #include "asm/d/kankyo/d_kankyo/dKy_getDarktime_minute__Fv.s" } #pragma pop +#endif /* 8019FBBC-8019FBCC 19A4FC 0010+00 0/0 0/0 8/8 .text dKy_getDarktime_week__Fv */ s32 dKy_getDarktime_week() { @@ -2030,6 +2214,278 @@ SECTION_SDATA2 static f32 lit_5840 = 1.0f / 15.0f; /* 8019FBD4-801A0340 19A514 076C+00 5/3 0/0 0/0 .text * setLight_palno_get__18dScnKy_env_light_cFPUcPUcPUcPUcPUcPUcPUcPUcPfPiPiPfPUc */ +// lots of issues +#ifdef NONMATCHING +void dScnKy_env_light_c::setLight_palno_get(u8* param_0, u8* param_1, u8* param_2, u8* param_3, + u8* param_4, u8* param_5, u8* param_6, u8* param_7, + f32* param_8, int* param_9, int* param_10, + f32* param_11, u8* param_12) { + u8 uvar3 = 0; + + if (*param_12 != 0) { + *param_12 += 1; + + if (*param_12 > 20) { + *param_12 = 0; + } + + if (g_env_light.mColPatMode == 0 && g_env_light.mColPatModeGather == 0) { + *param_11 = g_env_light.mColPatBlend; + + if (*param_11 >= 1.0f) { + *param_0 = *param_1; + *param_2 = *param_3; + } + } + } + + for (int i = 0; i < 11; i++) { + // dKyd_lightSchejule* schedule_p = &mpSchedule[i]; + + if (mDaytime >= mpSchedule->startTime && mDaytime <= mpSchedule->endTime) { + *param_9 = mpSchedule->startTimeLight; + *param_10 = mpSchedule->endTimeLight; + *param_8 = get_parcent(mpSchedule->endTime, mpSchedule->startTime, mDaytime); + + stage_envr_info_class* envr_p = &g_env_light.mpDmEnvr[*param_0]; + u32 tmp = *param_2; + switch (tmp) { + case 0: + uvar3 = envr_p->field_0x0[0]; + break; + case 1: + uvar3 = envr_p->field_0x0[1]; + break; + case 2: + uvar3 = envr_p->field_0x0[2]; + break; + case 3: + uvar3 = envr_p->field_0x0[3]; + break; + case 4: + uvar3 = envr_p->field_0x0[4]; + break; + case 5: + uvar3 = envr_p->field_0x0[5]; + break; + case 6: + uvar3 = envr_p->field_0x0[6]; + break; + case 7: + uvar3 = envr_p->field_0x0[7]; + break; + default: + if (tmp > 7 && tmp < 64) { + uvar3 = envr_p->field_0x0[tmp]; + } + break; + } + + if (g_env_light.mCameraInWater != 0 && + strcmp(dComIfGp_getStartStageName(), "D_MN08D") != 0 && + strcmp(dComIfGp_getStartStageName(), "D_MN01A") != 0) + { + if (g_env_light.mColPatCurr == 0) { + uvar3 = envr_p->field_0x0[8]; + } else { + uvar3 = envr_p->field_0x0[9]; + } + } else if (strcmp(dComIfGp_getStartStageName(), "R_SP127") == 0) { + camera_class* camera_p = dComIfGp_getCamera(0); + + if (camera_p != NULL && camera_p->mLookat.mEye.y < 0.0f) { + uvar3 = envr_p->field_0x0[10]; + } + } + + if (uvar3 > 250) { + uvar3 = 0; + } + + stage_pselect_info_class* pselect_p = &g_env_light.mpDmPselect[uvar3]; + switch (*param_9) { + case 0: + *param_4 = pselect_p->mPalIdx[0]; + break; + case 1: + *param_4 = pselect_p->mPalIdx[1]; + break; + case 2: + *param_4 = pselect_p->mPalIdx[2]; + break; + case 3: + *param_4 = pselect_p->mPalIdx[3]; + break; + case 4: + *param_4 = pselect_p->mPalIdx[4]; + break; + case 5: + *param_4 = pselect_p->mPalIdx[5]; + break; + } + + switch (*param_10) { + case 0: + *param_5 = pselect_p->mPalIdx[0]; + break; + case 1: + *param_5 = pselect_p->mPalIdx[1]; + break; + case 2: + *param_5 = pselect_p->mPalIdx[2]; + break; + case 3: + *param_5 = pselect_p->mPalIdx[3]; + break; + case 4: + *param_5 = pselect_p->mPalIdx[4]; + break; + case 5: + *param_5 = pselect_p->mPalIdx[5]; + break; + } + + stage_envr_info_class* envr_p2 = &g_env_light.mpDmEnvr[*param_1]; + u32 tmp_2 = *param_2; + switch (tmp_2) { + case 0: + uvar3 = envr_p2->field_0x0[0]; + break; + case 1: + uvar3 = envr_p2->field_0x0[1]; + break; + case 2: + uvar3 = envr_p2->field_0x0[2]; + break; + case 3: + uvar3 = envr_p2->field_0x0[3]; + break; + case 4: + uvar3 = envr_p2->field_0x0[4]; + break; + case 5: + uvar3 = envr_p2->field_0x0[5]; + break; + case 6: + uvar3 = envr_p2->field_0x0[6]; + break; + case 7: + uvar3 = envr_p2->field_0x0[7]; + break; + default: + if (tmp_2 > 7 && tmp_2 < 64) { + uvar3 = envr_p2->field_0x0[tmp_2]; + } + break; + } + + if (uvar3 > 250) { + uvar3 = 0; + } + + stage_pselect_info_class* pselect_p2 = &g_env_light.mpDmPselect[uvar3]; + if (*param_0 != *param_1 || *param_2 != tmp_2) { + if (pselect_p2->mChangeRate < 0.033333335f) { + pselect_p2->mChangeRate = 0.033333335f; + } + + if (g_env_light.mColPatMode == 0) { + if (pselect_p2->mChangeRate > 0.0f) { + *param_11 += 0.033333335f / pselect_p2->mChangeRate; + } + + if (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0 && + *param_2 == *param_3) + { + *param_11 += 0.06666667f; + } + + if (*param_11 >= 1.0f) { + *param_0 = *param_1; + *param_2 = *param_3; + *param_11 = 1.0f; + } + } + } + + if (g_env_light.mCameraInWater != 0 && + strcmp(dComIfGp_getStartStageName(), "D_MN08D") != 0 && + strcmp(dComIfGp_getStartStageName(), "D_MN01A") != 0) + { + if (g_env_light.mColPatCurr == 0) { + uvar3 = envr_p2->field_0x0[8]; + } else { + uvar3 = envr_p2->field_0x0[9]; + } + } else if (strcmp(dComIfGp_getStartStageName(), "R_SP127") == 0) { + camera_class* camera_p = dComIfGp_getCamera(0); + + if (camera_p != NULL && camera_p->mLookat.mEye.y < 0.0f) { + uvar3 = envr_p2->field_0x0[10]; + } + } + + switch (*param_9) { + case 0: + *param_6 = pselect_p2->mPalIdx[0]; + break; + case 1: + *param_6 = pselect_p2->mPalIdx[1]; + break; + case 2: + *param_6 = pselect_p2->mPalIdx[2]; + break; + case 3: + *param_6 = pselect_p2->mPalIdx[3]; + break; + case 4: + *param_6 = pselect_p2->mPalIdx[4]; + break; + case 5: + *param_6 = pselect_p2->mPalIdx[5]; + break; + } + + switch (*param_10) { + case 0: + *param_7 = pselect_p->mPalIdx[0]; + break; + case 1: + *param_7 = pselect_p->mPalIdx[1]; + break; + case 2: + *param_7 = pselect_p->mPalIdx[2]; + break; + case 3: + *param_7 = pselect_p->mPalIdx[3]; + break; + case 4: + *param_7 = pselect_p->mPalIdx[4]; + break; + case 5: + *param_7 = pselect_p->mPalIdx[5]; + break; + } + } + } + + if (*param_4 > 250) { + *param_4 = 0; + } + + if (*param_6 > 250) { + *param_6 = 0; + } + + if (*param_5 > 250) { + *param_5 = 0; + } + + if (*param_7 > 250) { + *param_7 = 0; + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -2041,6 +2497,7 @@ asm void dScnKy_env_light_c::setLight_palno_get(u8* param_0, u8* param_1, u8* pa #include "asm/d/kankyo/d_kankyo/setLight_palno_get__18dScnKy_env_light_cFPUcPUcPUcPUcPUcPUcPUcPUcPfPiPiPfPUc.s" } #pragma pop +#endif /* 801A0340-801A040C 19AC80 00CC+00 3/3 0/0 0/0 .text * dKy_calc_color_set__FP11_GXColorS10P15color_RGB_classP15color_RGB_classP15color_RGB_classP15color_RGB_classff11_GXColorS10f @@ -2119,6 +2576,66 @@ asm void dScnKy_env_light_c::setLight_bg(dKy_tevstr_c* param_0, _GXColorS10* par } #pragma pop +/* void dScnKy_env_light_c::setLight_bg(dKy_tevstr_c* i_tevstr, _GXColorS10* param_1, + _GXColorS10* param_2, f32* param_3, f32* param_4) { + i_tevstr->mColpatPrev = g_env_light.mColPatPrev; + i_tevstr->mColpatCurr = g_env_light.mColPatCurr; + + if (i_tevstr->mColpatPrev != i_tevstr->mColpatCurr) { + i_tevstr->mColpatBlend = g_env_light.mColPatBlend; + } + + u8 sp9D; + u8 sp9F; + u8 sp9E; + u8 spA0; + f32 sp8C; + int sp90; + int sp94; + setLight_palno_get(&i_tevstr->mEnvrIdxPrev, &i_tevstr->mEnvrIdxCurr, &i_tevstr->mColpatPrev, + &i_tevstr->mColpatCurr, &sp9D, &sp9F, &sp9E, &spA0, &sp8C, &sp90, &sp94, + &i_tevstr->mColpatBlend, &i_tevstr->mInitTimer); + + stage_palette_info_class* palette_p = g_env_light.mpDmPalet; + + if (sp9D == 0xFF) { + for (int i = 0; i < 4; i++) { + param_1[i].r = 255; + param_1[i].g = 0; + param_1[i].b = 0; + } + } else { + for (int i = 0; i < 4; i++) { + GXColorS10 sp78; + sp78.r = mBgAddColAmb.r; + sp78.b = mBgAddColAmb.b; + + dKy_calc_color_set(¶m_1, &palette_p[sp9D].mK0Color[i], &palette_p[sp9E].mK0Color[i], + &palette_p[sp9F].mK0Color[i], &palette_p[spA0].mK0Color[i], sp8C, + i_tevstr->mColpatBlend, sp78, g_env_light.mColBgColRatio); + } + + if (daPy_py_c::checkNowWolfPowerUp()) { + dKy_WolfPowerup_BgAmbCol(param_1); + } + + param_1[3].a = 255; + param_1[2].a = 255; + param_1[1].a = 255; + param_1[0].a = 255; + + for (int i = 0; i < 4; i++) { + GXColorS10 sp80; + sp80.r = mBgAddColAmb.r; + sp80.b = mBgAddColAmb.b; + + dKy_calc_color_set(¶m_1, &palette_p[sp9D].mK0Color[i], &palette_p[sp9E].mK0Color[i], + &palette_p[sp9F].mK0Color[i], &palette_p[spA0].mK0Color[i], sp8C, + i_tevstr->mColpatBlend, sp80, g_env_light.mColBgColRatio); + } + } +} */ + /* 801A16C0-801A1D64 19C000 06A4+00 1/1 0/0 0/0 .text * setLight_actor__18dScnKy_env_light_cFP12dKy_tevstr_cP11_GXColorS10PfPf */ #pragma push @@ -2283,6 +2800,427 @@ SECTION_SDATA2 static f32 lit_7027 = 6.0f / 5.0f; /* 801A37C4-801A441C 19E104 0C58+00 2/1 14/14 515/515 .text * settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c */ +// almost, just some regalloc + literals +#ifdef NONMATCHING +void dScnKy_env_light_c::settingTevStruct(int i_tevstrType, cXyz* param_1, dKy_tevstr_c* i_tevstr) { + dScnKy_env_light_c* env_light = i_dKy_getEnvlight(); + u8 var_r30 = i_tevstr->mInitTimer; + + GXColorS10 sp30; + GXColorS10 K0_color; + + f32 fog_z_start; + f32 fog_z_end; + + cXyz spA4; + if (i_tevstr->mRoomNo < 0) { + i_tevstr->mRoomNo = dComIfGp_roomControl_getStayNo(); + } + + if (param_1 != NULL) { + spA4 = *param_1; + } else { + spA4.set(0.0f, 0.0f, 0.0f); + } + + if (i_tevstr != NULL && g_env_light.mActorLightEffect != 100) { + i_tevstr->field_0x374 = g_env_light.mActorLightEffect / 100.0f; + } + + i_tevstr->field_0x37a = i_tevstrType; + + if (i_tevstr->mInitType != 123 && i_tevstr->mInitType != 124) { + dKy_tevstr_init(i_tevstr, dComIfGp_roomControl_getStayNo(), 0xFF); + } + + i_tevstr->mInitType = 124; + mActorAmbience.a = 255; + + if (i_tevstrType == 14) { + camera_class* temp_r30 = dComIfGp_getCamera(0); + cXyz sp98; + i_tevstr->mLightMode = 0; + + if (i_tevstr->mRoomNo >= 0x80) { + i_tevstr->mEnvrIdxCurr = 0; + } else { + i_tevstr->mEnvrIdxCurr = i_tevstr->mRoomNo; + } + + if (!dKy_darkworld_check()) { + field_0x10f0.r = 24; + field_0x10f0.g = 24; + field_0x10f0.b = 24; + field_0x10f0.a = 255; + } else { + field_0x10f0.r = 55; + field_0x10f0.g = 55; + field_0x10f0.b = 77; + } + + K0_color.r = 255; + K0_color.g = 255; + K0_color.b = 255; + + fog_z_start = 30000.0f; + fog_z_end = 30000.0f; + dKyr_get_vectle_calc(&spA4, &temp_r30->mLookat.mEye, &sp98); + + for (int i = 0; i < 6; i++) { + J3DLightInfo& light_info = i_tevstr->field_0x074[i].getLightInfo(); + + if (i == 0) { + if (!dKy_darkworld_check()) { + light_info.mColor.r = 126; + light_info.mColor.g = 110; + light_info.mColor.b = 89; + } else { + light_info.mColor.r = 0; + light_info.mColor.g = 0; + light_info.mColor.b = 0; + } + } else if (i == 1) { + if (!dKy_darkworld_check()) { + light_info.mColor.r = 24; + light_info.mColor.g = 41; + light_info.mColor.b = 50; + } else { + light_info.mColor.r = 0; + light_info.mColor.g = 0; + light_info.mColor.b = 0; + } + } else { + light_info.mColor.r = 0; + light_info.mColor.g = 0; + light_info.mColor.b = 0; + } + + dKy_GXInitLightSpot(&light_info, 90.0f, 0); + dKy_GXInitLightDistAttn(&light_info, 100000.0f, 0.99999f, 3); + + light_info.mLightPosition.x = 0.0f; + light_info.mLightPosition.y = 0.0f; + light_info.mLightPosition.z = 0.0f; + + if (i == 0) { + light_info.mLightPosition.x = 500.0f; + light_info.mLightPosition.y = 500.0f; + light_info.mLightPosition.z = 500.0f; + } else { + light_info.mLightPosition.x = -500.0f; + light_info.mLightPosition.y = -500.0f; + light_info.mLightPosition.z = -500.0f; + } + + dKy_lightdir_set(0.0f, 0.0f, &light_info.mLightDirection); + + light_info.mLightDirection.x = -light_info.mLightDirection.x; + light_info.mLightDirection.y = -light_info.mLightDirection.y; + light_info.mLightDirection.z = -light_info.mLightDirection.z; + } + + MtxP view_mtx = j3dSys.getViewMtx(); + Vec sp8C; + Vec sp80; + + sp80.x = temp_r30->mLookat.mEye.x; + sp80.y = temp_r30->mLookat.mEye.y; + sp80.z = temp_r30->mLookat.mEye.z; + cMtx_multVec(view_mtx, &sp80, &sp8C); + + J3DLightInfo& light_info = i_tevstr->mLightObj.getLightInfo(); + light_info.mLightPosition = sp8C; + i_tevstr->field_0x32c = sp80; + i_tevstr->mLightPosWorld = sp80; + light_info.mLightDirection = g_env_light.field_0x1064; + + light_info.mColor.r = 0; + light_info.mColor.g = 0; + light_info.mColor.b = 0; + + light_info.mCosAtten.x = 1.0f; + light_info.mCosAtten.y = 0.0f; + light_info.mCosAtten.z = 0.0f; + + light_info.mDistAtten.x = 1.0f; + light_info.mDistAtten.y = 0.0f; + light_info.mDistAtten.z = 0.0f; + } else if (i_tevstrType == 12 || i_tevstrType == 13) { + camera_class* temp_r30_2 = dComIfGp_getCamera(0); + + i_tevstr->mFogColor.r = 0; + i_tevstr->mFogColor.g = 0; + i_tevstr->mFogColor.b = 0; + i_tevstr->mFogColor.a = 0; + + i_tevstr->field_0x360 = 0; + i_tevstr->field_0x361 = 0; + i_tevstr->field_0x362 = 0; + i_tevstr->field_0x363 = 0; + i_tevstr->mLightMode = 0; + + if (i_tevstr->mRoomNo >= 128) { + i_tevstr->mEnvrIdxCurr = 0; + } else { + i_tevstr->mEnvrIdxCurr = i_tevstr->mRoomNo; + } + + if (i_tevstrType == 12) { + field_0x10f0.r = 25; + field_0x10f0.g = 20; + field_0x10f0.b = 25; + } else { + field_0x10f0.r = 40; + field_0x10f0.g = 35; + field_0x10f0.b = 30; + } + + field_0x10f0.a = 0xFF; + + K0_color.r = 255; + K0_color.g = 255; + K0_color.b = 255; + + fog_z_start = 30000.0f; + fog_z_end = 30000.0f; + + for (int i = 0; i < 6; i++) { + J3DLightInfo& temp_r31 = i_tevstr->field_0x074[i].getLightInfo(); + + if (i == 0) { + if (i_tevstrType == 12) { + temp_r31.mLightPosition.x = -30000.0f; + temp_r31.mLightPosition.y = 18800.0f; + temp_r31.mLightPosition.z = 29000.0f; + temp_r31.mColor.r = 120; + temp_r31.mColor.g = 110; + temp_r31.mColor.b = 100; + } else { + temp_r31.mLightPosition.x = -37000.0f; + temp_r31.mLightPosition.y = 18800.0f; + temp_r31.mLightPosition.z = 500.0f; + temp_r31.mColor.r = 85; + temp_r31.mColor.g = 90; + temp_r31.mColor.b = 100; + } + } else if (i == 1) { + if (i_tevstrType == 12) { + temp_r31.mLightPosition.x = 14400.0f; + temp_r31.mLightPosition.y = 7500.0f; + temp_r31.mLightPosition.z = 3900.0f; + temp_r31.mColor.r = 30; + temp_r31.mColor.g = 45; + temp_r31.mColor.b = 30; + } else { + temp_r31.mLightPosition.x = 18000.0f; + temp_r31.mLightPosition.y = -6500.0f; + temp_r31.mLightPosition.z = -10000.0f; + temp_r31.mColor.r = 100; + temp_r31.mColor.g = 65; + temp_r31.mColor.b = 40; + } + } else { + temp_r31.mColor.r = 0; + temp_r31.mColor.g = 0; + temp_r31.mColor.b = 0; + } + + dKy_GXInitLightSpot(&temp_r31, 90.0f, 0); + dKy_GXInitLightDistAttn(&temp_r31, 100000.0f, 0.99999f, 3); + dKy_lightdir_set(0.0f, 0.0f, &temp_r31.mLightDirection); + + temp_r31.mLightDirection.x = -temp_r31.mLightDirection.x; + temp_r31.mLightDirection.y = -temp_r31.mLightDirection.y; + temp_r31.mLightDirection.z = -temp_r31.mLightDirection.z; + } + + MtxP view_mtx = j3dSys.getViewMtx(); + Vec sp74; + Vec sp68; + + sp68.x = temp_r30_2->mLookat.mEye.x; + sp68.y = temp_r30_2->mLookat.mEye.y; + sp68.z = temp_r30_2->mLookat.mEye.z; + + J3DLightInfo& light_info = i_tevstr->mLightObj.getLightInfo(); + cMtx_multVec(view_mtx, &sp68, &sp74); + + light_info.mLightPosition = sp74; + if (i_tevstrType == 13) { + i_tevstr->field_0x32c = sp68; + i_tevstr->mLightPosWorld = sp68; + } + + light_info.mLightDirection = g_env_light.field_0x1064; + + light_info.mColor.r = 0; + light_info.mColor.g = 0; + light_info.mColor.b = 0; + + light_info.mCosAtten.x = 1.0f; + light_info.mCosAtten.y = 0.0f; + light_info.mCosAtten.z = 0.0f; + + light_info.mDistAtten.x = 1.0f; + light_info.mDistAtten.y = 0.0f; + light_info.mDistAtten.z = 0.0f; + } else if (!(i_tevstrType & 0xF0)) { + i_tevstr->mLightMode = 1; + + sp30 = mActorAmbience; + K0_color = mFogColor; + + fog_z_start = mFogNear; + fog_z_end = mFogFar; + + if (i_tevstrType == 0 || i_tevstrType == 0 || i_tevstrType == 8 || i_tevstrType == 7 || + i_tevstrType == 1 || i_tevstrType == 2 || i_tevstrType == 3 || i_tevstrType == 5 || + i_tevstrType == 4 || i_tevstrType == 11) + { + settingTevStruct_colget_actor(param_1, i_tevstr, &sp30, &K0_color, &fog_z_start, + &fog_z_end); + } else if (i_tevstrType == 10 || i_tevstrType == 9) { + if (g_env_light.field_0x98c != (u8)dComIfGp_roomControl_getStayNo()) { + g_env_light.field_0x98c = dComIfGp_roomControl_getStayNo(); + mDoAud_setSceneName( + dComIfGp_getStartStageName(), dComIfGp_roomControl_getStayNo(), + dComIfG_play_c::getLayerNo_common(dComIfGp_getStartStageName(), + dComIfGp_roomControl_getStayNo(), + dComIfGp_getStartStageLayer())); + + if (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0) { + mDoAud_load2ndDynamicWave(); + } + } + var_r30 = g_env_light.mInitAnmTimer; + settingTevStruct_colget_player(i_tevstr); + settingTevStruct_colget_actor(param_1, i_tevstr, &sp30, &K0_color, &fog_z_start, + &fog_z_end); + } + + field_0x10f0.r = sp30.r; + field_0x10f0.g = sp30.g; + field_0x10f0.b = sp30.b; + field_0x10f0.a = 255; + + if (i_tevstrType != 11) { + settingTevStruct_plightcol_plus(param_1, i_tevstr, sp30, sp30, var_r30); + } + + if (i_tevstrType == 10 || i_tevstrType == 9) { + g_env_light.mPLightNearPos = i_tevstr->mLightPosWorld; + } + } else { + i_tevstr->mLightMode = 0; + if (i_tevstr->field_0x37a != 20) { + i_tevstr->field_0x374 = g_env_light.mPaletteTerrainLightEffect; + } else { + switch (i_tevstr->field_0x364) { + case 0: + i_tevstr->field_0x374 = 0.2f; + break; + case 1: + i_tevstr->field_0x374 = 0.3f; + break; + case 2: + i_tevstr->field_0x374 = 0.4f; + break; + case 3: + i_tevstr->field_0x374 = 0.6f; + break; + case 4: + i_tevstr->field_0x374 = 0.8f; + break; + case 5: + i_tevstr->field_0x374 = 0.9f; + break; + case 6: + i_tevstr->field_0x374 = 1.0f; + break; + case 7: + i_tevstr->field_0x374 = 1.2f; + break; + default: + i_tevstr->field_0x374 = 1.0f; + break; + } + } + + if (i_tevstr->mRoomNo >= 128) { + i_tevstr->mEnvrIdxCurr = 0; + } else { + i_tevstr->mEnvrIdxCurr = i_tevstr->mRoomNo; + } + + GXColorS10 spB0[4]; + setLight_bg(i_tevstr, spB0, &K0_color, &fog_z_start, &fog_z_end); + + field_0x10f0 = spB0[i_tevstrType & 3]; + + MtxP view_mtx = j3dSys.getViewMtx(); + Vec sp5C; + cXyz sp58; + bool var_r25_3 = 0; + sp58.z = 0.0f; + sp58.y = 0.0f; + sp58.x = 0.0f; + + int temp_r3_2 = dKy_light_influence_id(sp58, 0); + if (temp_r3_2 >= 0 && g_env_light.mPointLight[temp_r3_2]->mIndex < 0) { + var_r25_3 = 1; + } + + if (var_r25_3 == 1) { + sp58 = g_env_light.mPointLight[temp_r3_2]->mPosition; + J3DLightInfo& light_info = i_tevstr->mLightObj.getLightInfo(); + + cMtx_multVec(view_mtx, &sp58, &sp5C); + + light_info.mLightPosition = sp5C; + i_tevstr->field_0x32c = sp58; + light_info.mLightDirection = g_env_light.field_0x1064; + + light_info.mColor.a = g_env_light.mPointLight[temp_r3_2]->mColor.a; + light_info.mColor.r = g_env_light.mPointLight[temp_r3_2]->mColor.r; + light_info.mColor.g = g_env_light.mPointLight[temp_r3_2]->mColor.g; + light_info.mColor.b = g_env_light.mPointLight[temp_r3_2]->mColor.b; + dKy_GXInitLightSpot(&light_info, 90.0f, 0); + dKy_GXInitLightDistAttn(&light_info, g_env_light.mPointLight[temp_r3_2]->mPow * 0.001f, + 0.99999f, 3); + } else { + MtxP view_mtx = j3dSys.getViewMtx(); + J3DLightInfo& light_info = i_tevstr->mLightObj.getLightInfo(); + Vec sp44; + cMtx_multVec(view_mtx, &lightStatusData[0].field_0x0, &sp44); + + light_info.mLightPosition = sp44; + i_tevstr->field_0x32c = lightStatusData[0].field_0x0; + light_info.mLightDirection = g_env_light.field_0x1064; + + light_info.mColor.r = 0; + light_info.mColor.g = 0; + light_info.mColor.b = 0; + + light_info.mCosAtten.x = 0.0f; + light_info.mCosAtten.y = 0.0f; + light_info.mCosAtten.z = 0.0f; + + light_info.mDistAtten.x = 0.0f; + light_info.mDistAtten.y = 0.0f; + light_info.mDistAtten.z = 0.0f; + } + + i_tevstr->mLightPosWorld = g_env_light.mBaseLightInfluence.mPosition; + // i_tevstr->mLightPosWorld = env_light->mBaseLightInfluence.mPosition; + } + + field_0x10f0.a = 255; + i_tevstr->mColorC0 = field_0x10f0; + i_tevstr->mColorK0 = K0_color; + i_tevstr->mFogStartZ = fog_z_start; + i_tevstr->mFogEndZ = fog_z_end; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -2291,12 +3229,11 @@ asm void dScnKy_env_light_c::settingTevStruct(int param_0, cXyz* param_1, dKy_te #include "asm/d/kankyo/d_kankyo/settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c.s" } #pragma pop +#endif /* 801A441C-801A4420 19ED5C 0004+00 0/0 0/0 2/2 .text * setLightTevColorType__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c */ -void dScnKy_env_light_c::setLightTevColorType(J3DModelData* param_0, dKy_tevstr_c* param_1) { - /* empty function */ -} +void dScnKy_env_light_c::setLightTevColorType(J3DModelData* param_0, dKy_tevstr_c* param_1) {} /* ############################################################################################## */ /* 80453D90-80453D94 002390 0004+00 1/1 0/0 0/0 .sdata2 @7186 */ @@ -2331,36 +3268,85 @@ void J3DColorBlock::setAmbColor(u32 param_0, J3DGXColor const* param_1) { /* 801A4C10-801A4DA0 19F550 0190+00 1/1 0/0 0/0 .text * dKy_cloudshadow_scroll__FP12J3DModelDataP12dKy_tevstr_ci */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void dKy_cloudshadow_scroll(J3DModelData* param_0, dKy_tevstr_c* param_1, int param_2) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_cloudshadow_scroll__FP12J3DModelDataP12dKy_tevstr_ci.s" +static void dKy_cloudshadow_scroll(J3DModelData* i_modelData, dKy_tevstr_c* i_tevstr, int param_2) { + JUTNameTab* mat_nametbl = i_modelData->getMaterialName(); + + for (int i = i_modelData->getMaterialNum() - 1; i >= 0; i--) { + J3DMaterial* mat_p = i_modelData->getMaterialNodePointer(i); + + int tmp = param_2; + if (i_tevstr->field_0x378 != 0 && i_tevstr->field_0x378 == i) { + tmp = 2; + } + + setLightTevColorType_MAJI_sub(mat_p, i_tevstr, tmp); + + const char* mat_name = mat_nametbl->getName(i); + if ((mat_name[3] == 'M' && mat_name[4] == 'A' && mat_name[5] == '0' && + (mat_name[6] == '0' || mat_name[6] == '1')) || + (mat_name[5] == '1' && mat_name[6] == '6')) + { + if (mat_name[6] == '0') { + J3DGXColor k_color; + k_color.r = g_env_light.mFogDensity; + k_color.g = 0; + k_color.b = 0; + k_color.a = 0; + mat_p->setTevKColor(1, &k_color); + } + + if (mat_p->getTexGenBlock()->getTexMtx(1) != NULL) { + J3DTexMtxInfo* tex_mtx_inf = + &mat_p->getTexGenBlock()->getTexMtx(1)->getTexMtxInfo(); + + if (tex_mtx_inf != NULL && g_env_light.mpVrkumoPacket != NULL) { + tex_mtx_inf->mSRT.mTranslationX = g_env_light.mpVrkumoPacket->field_0x1150; + tex_mtx_inf->mSRT.mTranslationY = g_env_light.mpVrkumoPacket->field_0x1154; + } + } + } + } } -#pragma pop /* 801A4DA0-801A4E90 19F6E0 00F0+00 0/0 18/18 536/536 .text * setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dScnKy_env_light_c::setLightTevColorType_MAJI(J3DModelData* param_0, - dKy_tevstr_c* param_1) { - nofralloc -#include "asm/d/kankyo/d_kankyo/setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c.s" +void dScnKy_env_light_c::setLightTevColorType_MAJI(J3DModelData* i_modelData, + dKy_tevstr_c* i_tevstr) { + if (i_tevstr->mInitType != 124) { + if (i_tevstr->mInitType != 123) { + dKy_tevstr_init(i_tevstr, dComIfGp_roomControl_getStayNo(), 0xFF); + } + + settingTevStruct(11, NULL, i_tevstr); + } + + dKy_setLight_nowroom_actor(i_tevstr); + + int tmp; + if (i_tevstr->field_0x37a > 10 && i_tevstr->field_0x37a != 12 && i_tevstr->field_0x37a != 13) { + tmp = 0; + } else { + tmp = 1; + } + + if (i_tevstr->field_0x37a & 0x20) { + dKy_cloudshadow_scroll(i_modelData, i_tevstr, tmp); + } else { + for (int i = i_modelData->getMaterialNum() - 1; i >= 0; i--) { + setLightTevColorType_MAJI_sub(i_modelData->getMaterialNodePointer(i), i_tevstr, tmp); + } + } } -#pragma pop /* 801A4E90-801A4F24 19F7D0 0094+00 1/1 0/0 0/0 .text CalcTevColor__18dScnKy_env_light_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dScnKy_env_light_c::CalcTevColor() { - nofralloc -#include "asm/d/kankyo/d_kankyo/CalcTevColor__18dScnKy_env_light_cFv.s" +void dScnKy_env_light_c::CalcTevColor() { + fopAc_ac_c* player_p = dComIfGp_getPlayer(0); + + if (player_p != NULL) { + mPlayerEfLightIdx = dKy_eflight_influence_id(player_p->current.pos, 0); + mPlayerPLightIdx = dKy_light_influence_id(player_p->current.pos, 0); + } } -#pragma pop /* 801A4F24-801A4F64 19F864 0040+00 1/1 0/0 0/0 .text Sndpos__18dScnKy_env_light_cFv */ void dScnKy_env_light_c::Sndpos() { @@ -2385,14 +3371,10 @@ asm void dScnKy_env_light_c::Eflight_flush_proc() { /* ############################################################################################## */ /* 80450700-80450704 000180 0002+02 2/2 0/0 0/0 .sdata lightMask */ -SECTION_SDATA static u16 lightMask[1 + 1 /* padding */] = { - 0x0001, - /* padding */ - 0x0000, -}; +SECTION_SDATA static u16 lightMask = 0x0001; /* 80450704-80450708 -00001 0004+00 3/3 0/0 0/0 .sdata lightStatusPt */ -SECTION_SDATA static void* lightStatusPt = (void*)&lightStatusData; +SECTION_SDATA static LightStatus* lightStatusPt = lightStatusData; /* 80453D98-80453D9C 002398 0004+00 1/1 0/0 0/0 .sdata2 @7365 */ SECTION_SDATA2 static f32 lit_7365 = 67.5f; @@ -2472,42 +3454,38 @@ asm void dKy_undwater_filter_draw() { #pragma pop /* 801A5B6C-801A5B98 1A04AC 002C+00 1/0 0/0 0/0 .text dKy_Draw__FP17sub_kankyo__class */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void dKy_Draw(sub_kankyo__class* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_Draw__FP17sub_kankyo__class.s" +static int dKy_Draw(sub_kankyo__class* i_this) { + g_env_light.drawKankyo(); + return 1; } -#pragma pop /* 801A5B98-801A5BCC 1A04D8 0034+00 1/0 0/0 0/0 .text dKy_Execute__FP17sub_kankyo__class */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void dKy_Execute(sub_kankyo__class* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_Execute__FP17sub_kankyo__class.s" +static int dKy_Execute(sub_kankyo__class* i_this) { + g_env_light.exeKankyo(); + dKyw_wind_set(); + dKy_twilight_camelight_set(); + return 1; } -#pragma pop /* 801A5BCC-801A5BD4 1A050C 0008+00 1/0 0/0 0/0 .text dKy_IsDelete__FP17sub_kankyo__class */ -static bool dKy_IsDelete(sub_kankyo__class* param_0) { - return true; +static int dKy_IsDelete(sub_kankyo__class* i_this) { + return 1; } /* 801A5BD4-801A5C1C 1A0514 0048+00 1/0 0/0 0/0 .text dKy_Delete__FP17sub_kankyo__class */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void dKy_Delete(sub_kankyo__class* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_Delete__FP17sub_kankyo__class.s" +static int dKy_Delete(sub_kankyo__class* i_this) { + plight_init(); + mDoAud_mEnvse_resetScene(); + + if (g_env_light.field_0xf38 != NULL) { + mDoExt_destroySolidHeap(g_env_light.field_0xf38); + } + + return 1; } -#pragma pop /* ############################################################################################## */ /* 80394C6C-80394C6C 0212CC 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ @@ -2525,7 +3503,7 @@ SECTION_DEAD static char const* const stringBase_80394E5E = "colordata_tbl.dat"; /* 801A5C1C-801A5E54 1A055C 0238+00 1/0 0/0 0/0 .text dKy_Create__FPv */ // matches with literals #ifdef NONMATCHING -static int dKy_Create(void*) { +static int dKy_Create(void* i_this) { BOOL setNextTime = false; stage_envr_info_class* envr = dComIfGp_getStageEnvrInfo(); if (envr != NULL && dComIfGp_getStartStageRoomNo() != -1) { @@ -2604,6 +3582,34 @@ void dKy_setLight() { } /* 801A60E0-801A61F4 1A0A20 0114+00 2/2 0/0 0/0 .text dKy_GlobalLight_set__Fv */ +// matches with literals +#ifdef NONMATCHING +static void dKy_GlobalLight_set() { + MtxP view_mtx = j3dSys.getViewMtx(); + + for (int i = 0; i < 8; i++) { + LightStatus* light_status = &lightStatusData[i]; + + Vec light_pos; + cMtx_multVec(view_mtx, &light_status->field_0x0, &light_pos); + + GXLightObj light_obj; + GXInitLightPos(&light_obj, light_pos.x, light_pos.y, light_pos.z); + GXInitLightDir(&light_obj, light_status->mLightDir.x, light_status->mLightDir.y, + light_status->mLightDir.z); + GXInitLightColor(&light_obj, light_status->field_0x18); + + if (light_status->mRefDist <= 0.0f) { + light_status->mRefDist = 1.0E-6f; + } + + GXInitLightDistAttn(&light_obj, light_status->mRefDist, light_status->mRefBrightness, + light_status->mDistFn); + GXInitLightSpot(&light_obj, light_status->mCutoff, light_status->mSpotFn); + GXLoadLightObjImm(&light_obj, (GXLightID)lightMaskData[i]); + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -2612,6 +3618,7 @@ static asm void dKy_GlobalLight_set() { #include "asm/d/kankyo/d_kankyo/dKy_GlobalLight_set__Fv.s" } #pragma pop +#endif /* 801A61F4-801A6278 1A0B34 0084+00 3/3 0/0 0/0 .text * dKy_lightswitch_check__FP30stage_pure_lightvec_info_classc */ @@ -2997,7 +4004,8 @@ void dKy_SordFlush_set(cXyz param_0, int param_1) { dScnKy_env_light_c* light = i_dKy_getEnvlight(); if (!dKy_darkworld_check() && - (light->mThunderEff.mStateTimer >= 10 || light->mThunderEff.field_0x8 <= 0.0f)) { + (light->mThunderEff.mStateTimer >= 10 || light->mThunderEff.field_0x8 <= 0.0f)) + { if (g_env_light.mSwordLight.mState == 0) { g_env_light.mSwordLight.mState = 1; g_env_light.mSwordLight.mLightType = param_1; @@ -3120,7 +4128,7 @@ void dKy_setLight_mine(dKy_tevstr_c* p_tevstr) { } /* 801A88EC-801A8A34 1A322C 0148+00 2/2 5/5 11/11 .text dKy_tevstr_init__FP12dKy_tevstr_cScUc */ -// almost +// matches with literals #ifdef NONMATCHING void dKy_tevstr_init(dKy_tevstr_c* p_tevstr, s8 roomNo, u8 param_2) { memset(p_tevstr, 0, sizeof(dKy_tevstr_c)); @@ -3153,16 +4161,17 @@ void dKy_tevstr_init(dKy_tevstr_c* p_tevstr, s8 roomNo, u8 param_2) { p_tevstr->mLightObj.mInfo.mDistAtten.z = 0.0f; for (int i = 0; i < 6; i++) { - J3DLightObj* light = &p_tevstr->field_0x074[i]; + J3DLightObj* tev_light_p = &p_tevstr->field_0x074[i]; + LightStatus* light_data_p = &lightStatusData[i]; - lightStatusData[i].field_0x0 = light->mInfo.mLightPosition; - lightStatusData[i].field_0x18 = light->mInfo.mColor; - lightStatusData[i].field_0x1c.x = 1.0f; - lightStatusData[i].field_0x1c.y = 0.0f; - lightStatusData[i].field_0x1c.z = 0.0f; - lightStatusData[i].field_0x28.x = 1.0f; - lightStatusData[i].field_0x28.y = 0.0f; - lightStatusData[i].field_0x28.z = 0.0f; + tev_light_p->mInfo.mLightPosition = light_data_p->field_0x0; + tev_light_p->mInfo.mColor = light_data_p->field_0x18; + tev_light_p->mInfo.mCosAtten.x = 1.0f; + tev_light_p->mInfo.mCosAtten.y = 0.0f; + tev_light_p->mInfo.mCosAtten.z = 0.0f; + tev_light_p->mInfo.mDistAtten.x = 1.0f; + tev_light_p->mInfo.mDistAtten.y = 0.0f; + tev_light_p->mInfo.mDistAtten.z = 0.0f; } } #else @@ -3548,7 +4557,8 @@ u8 dKy_pol_sound_get(cBgS_PolyInfo const* p_poly) { int att0 = dComIfG_Bgsp().GetPolyAtt0(*p_poly); if (!strcmp(dComIfGp_getStartStageName(), "F_SP127") && g_env_light.field_0x12fe == 4 && - att0 == 4) { + att0 == 4) + { att0 = 13; } @@ -3577,7 +4587,8 @@ u8 dKy_pol_argument_get(cBgS_PolyInfo const* p_poly) { int att0 = dComIfG_Bgsp().GetPolyAtt0(*p_poly); if (!strcmp(dComIfGp_getStartStageName(), "F_SP127") && g_env_light.field_0x12fe == 4 && - att0 == 4) { + att0 == 4) + { att0 = 13; } @@ -3718,7 +4729,8 @@ bool dKy_SunMoon_Light_Check() { // stage is not City in the Sky, Hyrule Castle, or Hidden Skill area if (memcmp(dComIfGp_getStartStageName(), "D_MN07", 6) && memcmp(dComIfGp_getStartStageName(), "D_MN09", 6) && - strcmp(dComIfGp_getStartStageName(), "F_SP200")) { + strcmp(dComIfGp_getStartStageName(), "F_SP200")) + { check = true; } } @@ -3828,7 +4840,8 @@ static int dKy_F_SP121Check(char const* stageName, int roomNo, u8* out_darkLv, i // - Lanayru Field / Great Bridge of Hylia Path North (11) and South (12) // - Faron Field / Great Bridge of Hylia Path North (14) // - Lanayru Field / Outside Hidden Village Path (9) - else if (roomNo >= 9 && roomNo <= 14) { + else if (roomNo >= 9 && roomNo <= 14) + { if (out_darkLv != NULL) { *out_darkLv = LANAYRU; } @@ -3839,13 +4852,15 @@ static int dKy_F_SP121Check(char const* stageName, int roomNo, u8* out_darkLv, i // - Faron Field (6) // - Faron Field / Kakariko Gorge Path South (1) // - Faron Field / Great Bridge of Hylia Path South (15) - else { + else + { result = -1; } } // Faron Spring; No twilight during Rusl cutscene at very beginning of game. - else if (!strcmp(stageName, "F_SP108") && roomNo == 1 && dComIfGp_getStartStageLayer() == 13) { + else if (!strcmp(stageName, "F_SP108") && roomNo == 1 && dComIfGp_getStartStageLayer() == 13) + { result = -1; } @@ -3918,7 +4933,8 @@ BOOL dKy_darkworld_spot_check(char const* stageName, int roomNo) { for (int i = 0; i < 34; i++) { if (!strcmp(stageName, darkworldTblPtr->stageName) && - dKy_F_SP121Check(stageName, roomNo, NULL, i) >= 0) { + dKy_F_SP121Check(stageName, roomNo, NULL, i) >= 0) + { result = TRUE; break; } diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index 6699dbbe7f0..6cbf0a20020 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -14,15 +14,16 @@ #include "JSystem/JMath/JMath.h" #include "MSL_C/stdio.h" #include "MSL_C/string.h" -#include "SSystem/SComponent/c_xyz.h" #include "SSystem/SComponent/c_lib.h" +#include "SSystem/SComponent/c_xyz.h" #include "Z2AudioLib/Z2Creature.h" +#include "d/com/d_com_inf_game.h" +#include "d/kankyo/d_kankyo.h" #include "dol2asm.h" #include "dolphin/gx/GXDraw.h" #include "dolphin/mtx/mtx.h" #include "dolphin/os/OS.h" #include "dolphin/types.h" -#include "d/kankyo/d_kankyo.h" #include "global.h" #include "m_Do/m_Do_mtx.h" @@ -36,16 +37,8 @@ struct J3DDrawBuffer { /* 8032548C */ void entryImm(J3DPacket*, u16); }; -struct dDlst_list_c { - /* 800565EC */ void entryZSortXluDrawList(J3DDrawBuffer*, J3DPacket*, cXyz&); -}; - struct ResFONT {}; -struct JUtility { - struct TColor {}; -}; - struct JUTResFont { /* 802DEF94 */ JUTResFont(ResFONT const*, JKRHeap*); }; @@ -435,11 +428,9 @@ extern "C" extern u8 const j3dDefaultTevStageInfo[20]; extern "C" extern u8 const j3dDefaultIndTevStageInfo[12]; extern "C" extern void* __vt__9J3DPacket[5]; extern "C" extern void* __vt__8J3DModel[9]; -extern "C" extern u8 g_dComIfG_gameInfo[122384]; extern "C" u8 mCurrentMtx__6J3DSys[48]; extern "C" f32 mParentS__6J3DSys[3]; extern "C" u8 sGDLObj__17J3DDisplayListObj[16]; -extern "C" extern f32 G_CM3D_F_ABS_MIN[1 + 1 /* padding */]; extern "C" u8 sCurrentHeap__7JKRHeap[4]; extern "C" u8 sOldVcdVatCmd__8J3DShape[4]; extern "C" u8 mJoint__10J3DMtxCalc[4]; @@ -1532,7 +1523,8 @@ void mDoExt_modelUpdate(J3DModel* i_model) { J3DModelData* model_data = i_model->getModelData(); if (model_data->getMaterialNodePointer(0)->getSharedDisplayListObj() != NULL && - !model_data->isLocked()) { + !model_data->isLocked()) + { i_model->calc(); mDoExt_modelDiff(i_model); } else { @@ -1548,7 +1540,8 @@ void mDoExt_modelUpdateDL(J3DModel* i_model) { J3DModelData* model_data = i_model->getModelData(); if (model_data->getMaterialNodePointer(0)->getSharedDisplayListObj() != NULL && - !model_data->isLocked()) { + !model_data->isLocked()) + { i_model->calc(); mDoExt_modelDiff(i_model); } else { @@ -1566,7 +1559,8 @@ void mDoExt_modelEntryDL(J3DModel* i_model) { J3DModelData* model_data = i_model->getModelData(); if (model_data->getMaterialNodePointer(0)->getSharedDisplayListObj() != NULL && - !model_data->isLocked()) { + !model_data->isLocked()) + { mDoExt_modelDiff(i_model); } else { i_model->unlock(); @@ -1980,7 +1974,8 @@ asm void J3DTevStage::setTevStageInfo(J3DTevStageInfo const& param_0) { #pragma pop /* 8000E460-8000E464 008DA0 0004+00 0/0 3/3 0/0 .text __ct__13J3DGXColorS10Fv */ -J3DGXColorS10::J3DGXColorS10() { +// J3DGXColorS10::J3DGXColorS10() { +extern "C" void __ct__13J3DGXColorS10Fv() { /* empty function */ } @@ -2005,7 +2000,8 @@ asm J3DColorChan::J3DColorChan() { #pragma pop /* 8000E538-8000E53C 008E78 0004+00 0/0 3/3 0/0 .text __ct__10J3DGXColorFv */ -J3DGXColor::J3DGXColor() { +// J3DGXColor::J3DGXColor() { +extern "C" void __ct__10J3DGXColorFv() { /* empty function */ } @@ -2144,24 +2140,63 @@ asm void mDoExt_setupShareTexture(J3DModelData* i_modelData, J3DModelData* i_sha #pragma force_active on // MWCC ignores mapping of some japanese characters using the // byte 0x5C (ASCII '\'). This is why this string is hex-encoded. + // "ソリッドヒープちゃうがな!\n" // "This isn't a solid heap! \n" SECTION_DEAD static char const* const stringBase_803740FC = "\x83\x5C\x83\x8A\x83\x62\x83\x68\x83\x71\x81\x5B\x83\x76\x82\xBF\x82\xE1\x82\xA4\x82\xAA\x82" "\xC8\x81\x49\x0A"; -SECTION_DEAD static char const* const stringBase_80374118 = "%s.bti"; #pragma pop /* 8000EA80-8000ECC0 0093C0 0240+00 0/0 0/0 6/6 .text mDoExt_setupStageTexture__FP12J3DModelData */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void mDoExt_setupStageTexture(J3DModelData* param_0) { - nofralloc -#include "asm/m_Do/m_Do_ext/mDoExt_setupStageTexture__FP12J3DModelData.s" +void mDoExt_setupStageTexture(J3DModelData* i_modelData) { + J3DTexture* texture_p = i_modelData->getTexture(); + + if (texture_p != NULL) { + JUTNameTab* tex_name_p = i_modelData->getTextureName(); + if (tex_name_p != NULL) { + bool set_timg = false; + + for (u16 i = 0; i < texture_p->getNum(); i++) { + ResTIMG* img = texture_p->getResTIMG(i); + if (img->imageOffset == 0) { + char res_name[64]; + snprintf(res_name, sizeof(res_name), "%s.bti", tex_name_p->getName(i)); + + ResTIMG* timg = (ResTIMG*)dComIfG_getStageRes(res_name); + texture_p->setResTIMG(i, *timg); + set_timg = true; + } + } + + if (set_timg) { + j3dSys.setTexture(texture_p); + + for (u16 i = 0; i < i_modelData->getMaterialNum(); i++) { + J3DMaterial* mat_p = i_modelData->getMaterialNodePointer(i); + J3DTevBlock* block_p = mat_p->getTevBlock(); + + if (block_p != NULL) { + J3DDisplayListObj* dlObj_p = mat_p->getSharedDisplayListObj(); + + if (dlObj_p != NULL) { + BOOL state = OSDisableInterrupts(); + + GDInitGDLObj(&J3DDisplayListObj::sGDLObj, dlObj_p->getDisplayList(0), + dlObj_p->getDisplayListSize()); + GDSetCurrent(&J3DDisplayListObj::sGDLObj); + block_p->patchTexNoAndTexCoordScale(); + + OSRestoreInterrupts(state); + GDSetCurrent(NULL); + } + } + } + } + } + } } -#pragma pop /* ############################################################################################## */ /* 80450C20-80450C24 000120 0004+00 2/1 0/0 0/0 .sbss AssertHeap */ @@ -2724,9 +2759,9 @@ extern "C" asm void __dt__16mDoExt_McaMorfSOFv() { */ #ifdef NONMATCHING int mDoExt_McaMorfSO::create(J3DModelData* i_modelData, mDoExt_McaMorfCallBack1_c* param_1, - mDoExt_McaMorfCallBack2_c* param_2, J3DAnmTransform* param_3, - int param_4, f32 param_5, int param_6, int param_7, - Z2Creature* i_sound, u32 param_9, u32 param_10) { + mDoExt_McaMorfCallBack2_c* param_2, J3DAnmTransform* param_3, + int param_4, f32 param_5, int param_6, int param_7, + Z2Creature* i_sound, u32 param_9, u32 param_10) { mpModel = NULL; mpTransformInfo = NULL; mpQuat = NULL; @@ -2773,7 +2808,8 @@ int mDoExt_McaMorfSO::create(J3DModelData* i_modelData, mDoExt_McaMorfCallBack1_ for (int i = 0; i < modelData->getJointNum(); i++) { transInfo = &modelData->getJointNodePointer(i)->getTransformInfo(); - JMAEulerToQuat(transInfo->mRotation.x, transInfo->mRotation.y, transInfo->mRotation.z, quat); + JMAEulerToQuat(transInfo->mRotation.x, transInfo->mRotation.y, + transInfo->mRotation.z, quat); transInfo++; quat++; @@ -2804,9 +2840,9 @@ int mDoExt_McaMorfSO::create(J3DModelData* i_modelData, mDoExt_McaMorfCallBack1_ #pragma optimization_level 0 #pragma optimizewithasm off asm int mDoExt_McaMorfSO::create(J3DModelData* param_0, mDoExt_McaMorfCallBack1_c* param_1, - mDoExt_McaMorfCallBack2_c* param_2, J3DAnmTransform* param_3, - int param_4, f32 param_5, int param_6, int param_7, - Z2Creature* param_8, u32 param_9, u32 param_10) { + mDoExt_McaMorfCallBack2_c* param_2, J3DAnmTransform* param_3, + int param_4, f32 param_5, int param_6, int param_7, + Z2Creature* param_8, u32 param_9, u32 param_10) { nofralloc #include "asm/m_Do/m_Do_ext/func_800108F0.s" } @@ -3291,7 +3327,8 @@ void drawCube(MtxP mtx, cXyz* pos, const GXColor& color) { GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX8); GXSetNumChans(1); - GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, + GX_AF_NONE); GXSetNumTexGens(0); GXSetNumTevStages(1); GXSetTevColor(GX_TEVREG0, color); @@ -3328,14 +3365,9 @@ void drawCube(MtxP mtx, cXyz* pos, const GXColor& color) { void mDoExt_cubePacket::draw() { static cXyz l_pos[8] = { - cXyz(-1.0f, 1.0f, -1.0f), - cXyz(1.0f, 1.0f, -1.0f), - cXyz(-1.0f, 1.0f, 1.0f), - cXyz(1.0f, 1.0f, 1.0f), - cXyz(-1.0f, -1.0f, -1.0f), - cXyz(1.0f, -1.0f, -1.0f), - cXyz(-1.0f, -1.0f, 1.0f), - cXyz(1.0f, -1.0f, 1.0f), + cXyz(-1.0f, 1.0f, -1.0f), cXyz(1.0f, 1.0f, -1.0f), cXyz(-1.0f, 1.0f, 1.0f), + cXyz(1.0f, 1.0f, 1.0f), cXyz(-1.0f, -1.0f, -1.0f), cXyz(1.0f, -1.0f, -1.0f), + cXyz(-1.0f, -1.0f, 1.0f), cXyz(1.0f, -1.0f, 1.0f), }; mDoMtx_stack_c::transS(mPosition.x, mPosition.y, mPosition.z); @@ -3372,7 +3404,7 @@ void mDoExt_cylinderPacket::draw() { mDoMtx_stack_c::transM(mPosition.x, mPosition.y + mHeight * 0.5f, mPosition.z); mDoMtx_stack_c::scaleM(mRadius, mRadius * 0.5f, mRadius); mDoMtx_stack_c::XrotM(0x4000); - + GXLoadPosMtxImm(mDoMtx_stack_c::get(), 0); mDoMtx_stack_c::inverseTranspose(); @@ -3554,10 +3586,12 @@ J3DModel* mDoExt_J3DModel__create(J3DModelData* i_modelData, u32 modelFlag, u32 // Set up the model if (!model->entryModelData(i_modelData, modelFlag, 1)) { - if (modelFlag == J3DMdlFlag_Unk80000 && model->newDifferedDisplayList(differedDlistFlag)) { + if (modelFlag == J3DMdlFlag_Unk80000 && + model->newDifferedDisplayList(differedDlistFlag)) + { return NULL; } - + model->lock(); return model; }