diff --git a/.clangd b/.clangd index 6c7744b87..06db37783 100644 --- a/.clangd +++ b/.clangd @@ -10,7 +10,7 @@ CompileFlags: "-Wsometimes-uninitialized", "-Wlogical-op-parentheses", "-Wbitwise-op-parentheses", - "-Wunused-variable", + # "-Wunused-variable", # "-Wunused-but-set-variable", "-Wunused-parameter", "-Wunused-but-set-parameter", diff --git a/configure.py b/configure.py index bb64bf003..bd1f3bd67 100755 --- a/configure.py +++ b/configure.py @@ -409,7 +409,7 @@ config.libs = [ Object(NonMatching, "m_Do/m_Do_graphic.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "m_Do/m_Do_machine.cpp"), Object(Matching, "m_Do/m_Do_mtx.cpp"), - Object(NonMatching, "m_Do/m_Do_ext.cpp"), + Object(MatchingFor("D44J01"), "m_Do/m_Do_ext.cpp"), Object(Matching, "m_Do/m_Do_lib.cpp"), Object(Matching, "m_Do/m_Do_hostIO.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "m_Do/m_Do_Reset.cpp"), @@ -565,7 +565,7 @@ config.libs = [ Object(Matching, "d/d_bg_w_deform.cpp"), Object(Matching, "d/d_bg_w_hf.cpp"), Object(Matching, "d/d_bg_w_sv.cpp"), - Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/d_cc_d.cpp"), + Object(Matching, "d/d_cc_d.cpp"), Object(Matching, "d/d_cc_mass_s.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/d_cc_s.cpp"), Object(Matching, "d/d_cc_uty.cpp"), @@ -593,7 +593,7 @@ config.libs = [ Object(Matching, "d/actor/d_a_bomb.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/actor/d_a_bomb2.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/actor/d_a_boomerang.cpp"), - Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/actor/d_a_dai_item.cpp"), + Object(Matching, "d/actor/d_a_dai_item.cpp"), Object(Matching, "d/actor/d_a_demo00.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/actor/d_a_disappear.cpp"), Object(Matching, "d/actor/d_a_esa.cpp"), @@ -1232,7 +1232,7 @@ config.libs = [ [ Object(NonMatching, "dolphin/gx/GXInit.c", extra_cflags=["-opt nopeephole"]), Object(Matching, "dolphin/gx/GXFifo.c"), - Object(NonMatching, "dolphin/gx/GXAttr.c"), + Object(Matching, "dolphin/gx/GXAttr.c"), Object(NonMatching, "dolphin/gx/GXMisc.c"), Object(NonMatching, "dolphin/gx/GXGeometry.c"), Object(NonMatching, "dolphin/gx/GXFrameBuf.c"), @@ -1451,7 +1451,7 @@ config.libs = [ ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_lamp"), ActorRel(NonMatching, "d_a_lod_bg"), ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_lwood"), - ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_magma"), + ActorRel(Matching, "d_a_magma"), ActorRel(Matching, "d_a_majuu_flag"), ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_mdoor"), ActorRel(MatchingFor("D44J01"), "d_a_msw"), @@ -1471,7 +1471,7 @@ config.libs = [ ActorRel(Matching, "d_a_obj_hfuck1"), ActorRel(Matching, "d_a_obj_hole"), ActorRel(Matching, "d_a_obj_ice"), - ActorRel(NonMatching, "d_a_obj_ikada"), + ActorRel(Matching, "d_a_obj_ikada"), ActorRel(Matching, "d_a_obj_kanat"), ActorRel(Matching, "d_a_obj_leaves"), ActorRel(Matching, "d_a_obj_lpalm"), @@ -1653,7 +1653,7 @@ config.libs = [ ActorRel(Matching, "d_a_npc_ah"), ActorRel(NonMatching, "d_a_npc_aj1"), ActorRel(NonMatching, "d_a_npc_auction"), - ActorRel(NonMatching, "d_a_npc_ba1"), + ActorRel(Matching, "d_a_npc_ba1"), ActorRel(NonMatching, "d_a_npc_bj1"), ActorRel(Matching, "d_a_npc_bm1"), ActorRel(NonMatching, "d_a_npc_bmcon1"), @@ -1938,11 +1938,11 @@ config.progress_report_args = [ "--config preferredStringEncoding=shift_jis", ] -# Disable missing return type warnings for incomplete objects -for lib in config.libs: - for obj in lib["objects"]: - if not obj.completed: - obj.options["extra_clang_flags"].append("-Wno-return-type") +# # Disable missing return type warnings for incomplete objects +# for lib in config.libs: +# for obj in lib["objects"]: +# if not obj.completed: +# obj.options["extra_clang_flags"].append("-Wno-return-type") if args.mode == "configure": # Write build.ninja and objdiff.json diff --git a/include/JSystem/J2DGraph/J2DWindow.h b/include/JSystem/J2DGraph/J2DWindow.h index b98718455..7b28500cd 100644 --- a/include/JSystem/J2DGraph/J2DWindow.h +++ b/include/JSystem/J2DGraph/J2DWindow.h @@ -44,14 +44,10 @@ public: param_0.mBR = mColorBR; } const JUtility::TColor& getWhite() const { return mWhite; } - bool setBlack(JUtility::TColor black) { mBlack = black; return true; } - void setContentsColor(TContentsColor c) { - setContentsColor(c.mTL, c.mTR, c.mBL, c.mBR); - } - void setContentsColor(JUtility::TColor c) { - setContentsColor(c, c, c, c); - } - bool setWhite(JUtility::TColor white) { mWhite = white; return true; } + void setBlack(JUtility::TColor black) { mBlack = black; } + void setContentsColor(TContentsColor param_0) { setContentsColor(param_0.mTL, param_0.mTR, param_0.mBL, param_0.mBR); } + void setContentsColor(JUtility::TColor param_0) { setContentsColor(param_0, param_0, param_0, param_0); } + void setWhite(JUtility::TColor white) { mWhite = white; } public: /* 0x0CC */ JUTTexture* mpFrameTexture1; diff --git a/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/include/JSystem/J3DGraphAnimator/J3DAnimation.h index 1dc6b9ac9..cfb35d9bb 100644 --- a/include/JSystem/J3DGraphAnimator/J3DAnimation.h +++ b/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -430,7 +430,7 @@ public: } u16 getUpdateMaterialNum() const { return mTrackNum / 3; } JUTNameTab * getUpdateMaterialName() { return &mUpdateMaterialName; } - u16 getUpdateTexMtxID(u16 idx) const { + int getUpdateTexMtxID(u16 idx) const { J3D_ASSERT(1017, idx < (mTrackNum / 3), "Error : range over."); return mUpdateTexMtxID[idx]; } diff --git a/include/JSystem/J3DGraphAnimator/J3DJoint.h b/include/JSystem/J3DGraphAnimator/J3DJoint.h index eb98d6965..6f46ba1b1 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJoint.h +++ b/include/JSystem/J3DGraphAnimator/J3DJoint.h @@ -119,7 +119,6 @@ class J3DMtxCalcMayaAnm : public J3DMtxCalcMaya, public J3DMtxCalcAnm { public: J3DMtxCalcMayaAnm(J3DAnmTransform* pAnmTransform) : J3DMtxCalcMaya(), J3DMtxCalcAnm(pAnmTransform) {} - virtual ~J3DMtxCalcMayaAnm() {} virtual void calc(u16 jnt_no) { J3DMtxCalcAnm::calc(jnt_no); } }; diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index a5c1c5183..f3e588286 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -9,8 +9,18 @@ struct J3DGXColorS10 { J3DGXColorS10() {} - J3DGXColorS10(GXColorS10& other) { mColor = other; } - J3DGXColorS10(J3DGXColorS10& other) { mColor = other.mColor; } + J3DGXColorS10(GXColorS10& other) { + mColor.r = other.r; + mColor.g = other.g; + mColor.b = other.b; + mColor.a = other.a; + } + J3DGXColorS10(J3DGXColorS10& other) { + mColor.r = other.mColor.r; + mColor.g = other.mColor.g; + mColor.b = other.mColor.b; + mColor.a = other.mColor.a; + } J3DGXColorS10& operator=(const J3DGXColorS10& other) { mColor = other.mColor; return *this; @@ -25,8 +35,18 @@ struct J3DGXColorS10 { struct J3DGXColor { J3DGXColor() {} - J3DGXColor(GXColor& other) { mColor = other; } - J3DGXColor(J3DGXColor& other) { mColor = other.mColor; } + J3DGXColor(GXColor& other) { + mColor.r = other.r; + mColor.g = other.g; + mColor.b = other.b; + mColor.a = other.a; + } + J3DGXColor(J3DGXColor& other) { + mColor.r = other.mColor.r; + mColor.g = other.mColor.g; + mColor.b = other.mColor.b; + mColor.a = other.mColor.a; + } J3DGXColor& operator=(const J3DGXColor& other) { mColor = other.mColor; return *this; diff --git a/include/JSystem/J3DGraphBase/J3DSys.h b/include/JSystem/J3DGraphBase/J3DSys.h index 39e9ce208..62f141a57 100644 --- a/include/JSystem/J3DGraphBase/J3DSys.h +++ b/include/JSystem/J3DGraphBase/J3DSys.h @@ -12,9 +12,10 @@ enum J3DError { J3DErrType_OutOfMemory = 4, }; -enum J3DSysDrawBuffer { - /* 0x0 */ OPA_BUFFER, - /* 0x1 */ XLU_BUFFER +enum J3DSysDrawBuf { + /* 0x0 */ J3DSysDrawBuf_Opa, + /* 0x1 */ J3DSysDrawBuf_Xlu, + /* 0x2 */ J3DSysDrawBuf_MAX, }; class J3DMtxCalc; diff --git a/include/JSystem/JSystem.pch b/include/JSystem/JSystem.pch index 1c0c49b73..df12d1589 100644 --- a/include/JSystem/JSystem.pch +++ b/include/JSystem/JSystem.pch @@ -1,7 +1,7 @@ #ifndef JSYSTEM_PCH #define JSYSTEM_PCH -#include "JSystem/JSupport/JSUList.h" -#include "JSystem/J3DGraphBase/J3DShape.h" +#include "JSystem/JSupport/JSUList.h" // IWYU pragma: export +#include "JSystem/J3DGraphBase/J3DShape.h" // IWYU pragma: export #endif /* JSYSTEM_PCH */ diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index 0ed9dc136..db557c83f 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -380,9 +380,9 @@ public: cCcD_ObjCommonBase() { ct(); } virtual ~cCcD_ObjCommonBase() {} void ct() { - SetSPrm(0); - SetRPrm(0); - ClrObj(); + mSPrm = 0; + mRPrm = 0; + mHitObj = NULL; } void SetSPrm(u32 sprm) { mSPrm = sprm; } void SetRPrm(u32 rprm) { mRPrm = rprm; } diff --git a/include/SSystem/SComponent/c_m3d_g_cyl.h b/include/SSystem/SComponent/c_m3d_g_cyl.h index d9ce487da..23fb4b2db 100644 --- a/include/SSystem/SComponent/c_m3d_g_cyl.h +++ b/include/SSystem/SComponent/c_m3d_g_cyl.h @@ -35,14 +35,26 @@ public: void SetR(f32 r); #endif void Set(const cM3dGCylS & src) { +#if VERSION == VERSION_DEMO + mCenter = src.mCenter; + mRadius = src.mRadius; + mHeight = src.mHeight; +#else SetC(src.mCenter); SetR(src.mRadius); SetH(src.mHeight); +#endif } void Set(const cXyz& center, f32 radius, f32 height) { +#if VERSION == VERSION_DEMO + mCenter = center; + mRadius = radius; + mHeight = height; +#else SetC(center); SetR(radius); SetH(height); +#endif } bool cross(const cM3dGSph*, cXyz*) const; bool cross(const cM3dGCyl*, cXyz*) const; diff --git a/include/SSystem/SComponent/c_m3d_g_sph.h b/include/SSystem/SComponent/c_m3d_g_sph.h index dcc7d4151..9d8403f07 100644 --- a/include/SSystem/SComponent/c_m3d_g_sph.h +++ b/include/SSystem/SComponent/c_m3d_g_sph.h @@ -29,12 +29,22 @@ public: #endif void SetC(f32 x, f32 y, f32 z) { mCenter.x = x; mCenter.y = y; mCenter.z = z; } void Set(const cM3dGSphS & src) { +#if VERSION == VERSION_DEMO + mCenter = src.mCenter; + mRadius = src.mRadius; +#else SetC(src.mCenter); SetR(src.mRadius); +#endif } void Set(const cXyz& srcCenter, f32 srcRadius) { +#if VERSION == VERSION_DEMO + mCenter = srcCenter; + mRadius = srcRadius; +#else SetC(srcCenter); SetR(srcRadius); +#endif } bool Cross(const cM3dGCps* cps, cXyz* dst) const { return cM3d_Cross_CpsSph(*cps, *this, dst); diff --git a/include/d/actor/d_a_hmlif.h b/include/d/actor/d_a_hmlif.h index ebadedd07..9df9d0c22 100644 --- a/include/d/actor/d_a_hmlif.h +++ b/include/d/actor/d_a_hmlif.h @@ -23,7 +23,7 @@ public: void check_col(); void lift_smooth_move(); void lift_normal_move(); - BOOL check_path_point(cXyz, cXyz, cXyz, s8); + BOOL check_path_point(cXyz, cXyz, s8); void set_next_pnt(); BOOL setNextPath(); bool chkSwitchPathType(); diff --git a/include/d/actor/d_a_magma.h b/include/d/actor/d_a_magma.h index 681ecf0e1..30388ab2a 100644 --- a/include/d/actor/d_a_magma.h +++ b/include/d/actor/d_a_magma.h @@ -9,7 +9,7 @@ class daMagma_c : public fopAc_ac_c { public: inline ~daMagma_c(); inline cPhs_State create(); - inline s32 getPathNo() { return fopAcM_GetParam(this); } + inline s16 getPathNo() { return fopAcM_GetParam(this); } public: /* 0x290 */ request_of_phase_process_class mPhs; diff --git a/include/d/actor/d_a_movie_player.h b/include/d/actor/d_a_movie_player.h index 9bc90b21b..68a5da83d 100644 --- a/include/d/actor/d_a_movie_player.h +++ b/include/d/actor/d_a_movie_player.h @@ -6,9 +6,11 @@ #include "d/d_drawlist.h" #include "dolphin/dvd/dvd.h" +#if VERSION > VERSION_DEMO #ifdef __cplusplus extern "C" { #endif +#endif typedef u8 THPSample; typedef s16 THPCoeff; @@ -45,8 +47,10 @@ static void __THPInverseDCTY8(THPCoeff* in, u32 xPos); static void __THPGQRSetup(); static s32 __THPHuffDecodeTab(THPFileInfo* info, THPHuffmanTab* h); +#if VERSION > VERSION_DEMO #ifdef __cplusplus -} +} // extern "C" +#endif #endif class daMP_c : public fopAc_ac_c { @@ -63,7 +67,7 @@ public: public: /* 0x290 */ u32 (*mpGetMovieRestFrame)(); - /* 0x294 */ u32 (*mpSetPercentMovieVol)(f32); + /* 0x294 */ void (*mpSetPercentMovieVol)(f32); #if VERSION == VERSION_PAL /* 0x29C */ u32 (*mpTHPGetTotalFrame)(void); #endif diff --git a/include/d/actor/d_a_npc_ba1.h b/include/d/actor/d_a_npc_ba1.h index 2a10bd377..41152cbfa 100644 --- a/include/d/actor/d_a_npc_ba1.h +++ b/include/d/actor/d_a_npc_ba1.h @@ -1,63 +1,70 @@ #ifndef D_A_NPC_BA1_H #define D_A_NPC_BA1_H +#include "d/d_npc.h" #include "f_op/f_op_actor.h" class J3DNode; -class daNpc_Ba1_c : public fopAc_ac_c { +class daNpc_Ba1_c : public fopNpc_npc_c { public: + typedef BOOL (daNpc_Ba1_c::*ProcFunc)(void*); struct anm_prm_c { - + /* 0x00 */ s8 mAnmNum; + /* 0x01 */ s8 mBtpNum; + /* 0x02 */ s16 field_0x02; + /* 0x04 */ f32 mMorf; + /* 0x08 */ f32 mSpeed; + /* 0x0C */ int mLoopMode; }; - void holdEventOn() { mHoldEvent = 1; } + void holdEventOn() { mbHoldEvent = 1; } void nodeBa1Control(J3DNode*, J3DModel*); - void XyCheck_cB(int); - void XyEvent_cB(int); - void init_BA1_0(); - void init_BA1_1(); - void init_BA1_2(); - void init_BA1_3(); - void init_BA1_4(); - void createInit(); + bool XyCheck_cB(int); + s16 XyEvent_cB(int); + bool init_BA1_0(); + bool init_BA1_1(); + bool init_BA1_2(); + bool init_BA1_3(); + bool init_BA1_4(); + bool createInit(); void setMtx(bool); - void anmNum_toResID(int); - void btpNum_toResID(int); - void setBtp(bool, int); - void iniTexPttrnAnm(bool); + int anmNum_toResID(int); + int btpNum_toResID(int); + bool setBtp(bool, int); + bool iniTexPttrnAnm(bool); void plyTexPttrnAnm(); - void setAnm_tex(signed char); - void setAnm_anm(anm_prm_c*); + void setAnm_tex(s8); + BOOL setAnm_anm(anm_prm_c*); void setAnm_NUM(int, int); - void setAnm(); + bool setAnm(); void chg_anmTag(); void control_anmTag(); - void chg_anmAtr(unsigned char); + void chg_anmAtr(u8); void control_anmAtr(); void setAnm_ATR(int); - void anmAtr(unsigned short); + void anmAtr(u16); void eventOrder(); void checkOrder(); - void chk_talk(); - void chk_drct(float); - void chk_partsNotMove(); + bool chk_talk(); + bool chk_drct(f32); + bool chk_partsNotMove(); void lookBack(); - void next_msgStatus(unsigned long*); - void getMsg_BA1_0(); - void getMsg_BA1_1(); - void getMsg_BA1_3(); - void getMsg_BA1_4(); - void getMsg(); - void chkAttention(); + u16 next_msgStatus(u32*); + u32 getMsg_BA1_0(); + u32 getMsg_BA1_1(); + u32 getMsg_BA1_3(); + u32 getMsg_BA1_4(); + u32 getMsg(); + bool chkAttention(); void setAttention(bool); - void searchByID(fpc_ProcID); - void partner_srch_sub(void* (*)(void*, void*)); + fopAc_ac_c* searchByID(fpc_ProcID); + bool partner_srch_sub(fpcLyIt_JudgeFunc); void partner_srch(); - void check_useFairyArea(); - void checkCommandTalk(); - void charDecide(int); + bool check_useFairyArea(); + bool checkCommandTalk(); + bool charDecide(int); void eInit_SET_PLYER_GOL_(); void eInit_PLYER_INI_POS_(); void eInit_USE_FAIRY_END_(); @@ -66,61 +73,121 @@ public: void eInit_ACTOR_DRW_CONTROL_(int*, int*); void eInit_setEvTimer(int*); void eInit_CHK_FAIRY_(int*); - void eInit_prmFloat(float*, float); - void eInit_SET_EYE_OFF_(float*); - void eInit_EYE_OFF_ZRO_(float*); + f32 eInit_prmFloat(f32*, f32); + void eInit_SET_EYE_OFF_(f32*); + void eInit_EYE_OFF_ZRO_(f32*); void eInit_CHK_FAIRY_MOV_1(int*); void event_actionInit(int); - void eMove_MOV_POS_(); - void eMove_CHK_FAIRY_(); - void eMove_EYE_OFF_ZRO_(); - void eMove_CHK_FAIRY_MOV_1(); - void event_action(); + bool eMove_MOV_POS_(); + bool eMove_CHK_FAIRY_(); + bool eMove_EYE_OFF_ZRO_(); + bool eMove_CHK_FAIRY_MOV_1(); + bool event_action(); void cut_init_START_TALE1(int); - void cut_move_START_TALE1(); + bool cut_move_START_TALE1(); void privateCut(int); void endEvent(); - void isEventEntry(); + BOOL isEventEntry(); void event_proc(int); - void set_action(int (daNpc_Ba1_c::*)(void*), void*); - void setStt(signed char); - void wait_0(); - void wait_1(); - void talk_1(); - void talk_2(); - void wait_2(); - void wait_3(); - void ZZZwai(); - void wait_action1(void*); - void wait_action2(void*); - void demo_action1(void*); - void wait_action3(void*); - void wait_action4(void*); - void demo(); + BOOL set_action(int (daNpc_Ba1_c::*)(void*), void*); + void setStt(s8); + BOOL wait_0(); + BOOL wait_1(); + BOOL talk_1(); + BOOL talk_2(); + BOOL wait_2(); + BOOL wait_3(); + BOOL ZZZwai(); + BOOL wait_action1(void*); + BOOL wait_action2(void*); + BOOL demo_action1(void*); + BOOL wait_action3(void*); + BOOL wait_action4(void*); + bool demo(); void shadowDraw(); BOOL _draw(); BOOL _execute(); BOOL _delete(); cPhs_State _create(); - void create_Anm(); - void create_itm_Mdl(); - void CreateHeap(); + J3DModelData* create_Anm(); + bool create_itm_Mdl(); + BOOL CreateHeap(); public: - /* 0x290 */ u8 m290[0x7F8 - 0x290]; + /* 0x6C4 */ request_of_phase_process_class mPhs; + /* 0x6CC */ s8 m_hed_jnt_num; + /* 0x6CD */ s8 m_bbone_jnt_num; + /* 0x6CE */ s8 m_footL_jnt_num; + /* 0x6D0 */ J3DModel* mpClothModel; + /* 0x6D4 */ u32 mShadowID; + /* 0x6D8 */ J3DAnmTexPattern* m_hed_tex_pttrn; + /* 0x6DC */ mDoExt_btpAnm mHeadBtpAnm; + /* 0x6F0 */ u8 mBlinkFrame; + /* 0x6F2 */ s16 mBlinkTimer; + /* 0x6F4 */ ProcFunc mCurrProcFunc; + /* 0x700 */ u8 field_0x700[0x708 - 0x700]; + /* 0x708 */ dNpc_EventCut_c mEventCut; + /* 0x774 */ fpc_ProcID mPartnerProcID; + /* 0x778 */ cXyz mInitialPos; + /* 0x784 */ csXyz mInitialAngle; + /* 0x78A */ csXyz m78A; + /* 0x790 */ cXyz mTransformedEyePos; + /* 0x79C */ cXyz m79C; + /* 0x7A8 */ u8 field_0x7A8[0x7C0 - 0x7A8]; + /* 0x7C0 */ f32 mPrevMorfFrame; + /* 0x7C4 */ f32 mEyeOffset; + /* 0x7C8 */ f32 mEyeOffsetZero; + /* 0x7CC */ s16 mJointHeadY; + /* 0x7CE */ s16 mJointBackboneY; + /* 0x7D0 */ s16 mActorAngleY; + /* 0x7D2 */ s16 mEventIdTable[6]; + /* 0x7DE */ s16 mEventIdx; + /* 0x7E0 */ s16 mEvTimer; + /* 0x7E2 */ s16 mEvTimer2; + /* 0x7E4 */ u8 field_0x7E4[0x7E8 - 0x7E4]; + /* 0x7E8 */ s16 mLookAtMaxVel; + /* 0x7EA */ s16 mTargetYRot; + /* 0x7EC */ u8 field_0x7EC[0x7EE - 0x7EC]; + /* 0x7EE */ s8 mbMorfAnimStopped; + /* 0x7EF */ u8 m7EF; + /* 0x7F0 */ s8 m7F0; + /* 0x7F1 */ u8 mItemNo; #if VERSION > VERSION_JPN - /* 0x7F8 */ u8 m7F8; + /* 0x7F2 */ u8 m7F2; #endif - /* Offsets below are for USA/PAL */ - /* 0x7F9 */ u8 mHoldEvent; -}; - -class daNpc_Ba1_HIO_c { -public: - daNpc_Ba1_HIO_c(); - -public: - /* Place member variables here */ -}; + /* 0x7F3 */ u8 field_0x7F3[0x7F4 - 0x7F3]; + /* 0x7F4 */ bool mbInitGrandma0; + /* 0x7F5 */ bool m7F5; + /* 0x7F6 */ bool m7F6; + /* 0x7F7 */ bool m7F7; + /* 0x7F8 */ bool m7F8; + /* 0x7F9 */ bool mbHoldEvent; + /* 0x7FA */ bool m7FA; + /* 0x7FB */ bool m7FB; + /* 0x7FC */ bool mFairyUsed; + /* 0x7FD */ bool m7FD; + /* 0x7FE */ bool m7FE; + /* 0x7FF */ bool m7FF; + /* 0x800 */ bool mbRanExecute; + /* 0x804 */ BOOL mbSetEyePos; + /* 0x808 */ bool mbAttention; + /* 0x809 */ bool m809; + /* 0x80A */ bool mHeadOnlyFollow; + /* 0x80B */ bool mbInDemo; + /* 0x80C */ s8 mActionIndex; + /* 0x80D */ s8 mActNo; + /* 0x80E */ u8 m80E; + /* 0x80F */ u8 mMesgAnimeTagInfo; + /* 0x810 */ s8 mBtpNum; + /* 0x811 */ s8 mAnmNum; + /* 0x812 */ s8 m812; + /* 0x813 */ s8 mStatus; + /* 0x814 */ s8 mPrevStatus; + /* 0x815 */ s8 mLookBackState; + /* 0x816 */ s8 mType; + /* 0x817 */ s8 mSpecificType; + /* 0x818 */ s8 m818; + /* 0x819 */ s8 m819; +}; // Size: 0x81C #endif /* D_A_NPC_BA1_H */ diff --git a/include/d/actor/d_a_npc_fa1.h b/include/d/actor/d_a_npc_fa1.h index 2938d152e..28894b5e9 100644 --- a/include/d/actor/d_a_npc_fa1.h +++ b/include/d/actor/d_a_npc_fa1.h @@ -73,7 +73,7 @@ public: u8 getMode() { return mMode; } void setMode(u8 mode) { mMode = mode; } bool isLinkMode() { return mMode == Mode_PLAYER_MOVE_e; } - void isBabaMode() {} + bool isBabaMode() { return mMode == Mode_BOTTLE_BABA_MOVE_e; } u8 getSubMode() { return mSubMode; } void setSubMode(u8 submode) { mSubMode = submode; } diff --git a/include/d/actor/d_a_obj_ikada.h b/include/d/actor/d_a_obj_ikada.h index 7b1b556cb..5a4cc600e 100644 --- a/include/d/actor/d_a_obj_ikada.h +++ b/include/d/actor/d_a_obj_ikada.h @@ -10,7 +10,6 @@ #include "SSystem/SComponent/c_phase.h" #include "d/d_path.h" #include "d/d_lib.h" -#include "m_Do/m_Do_hostIO.h" class daObj_Ikada_c : public fopAc_ac_c { public: @@ -185,54 +184,4 @@ public: /* 0x1328 */ cXyz mInitPos; }; -class daObj_Ikada_HIO_c : public mDoHIO_entry_c { -public: - daObj_Ikada_HIO_c(); - virtual ~daObj_Ikada_HIO_c() {} - - void genMessage(JORMContext* ctx) {} - -public: - /* 0x04 */ u8 mbDebugDraw; - /* 0x05 */ u8 m05; - /* 0x06 */ u8 m06; - /* 0x07 */ u8 mbNoRotAnim; - /* 0x08 */ u8 m08; - /* 0x09 */ u8 m09[0x0C - 0x09]; - /* 0x0C */ Vec mFlagOffset; - /* 0x18 */ f32 mFlagScale; - /* 0x1C */ s16 m1C; - /* 0x1E */ s16 m1E; - /* 0x20 */ f32 m20; - /* 0x24 */ s16 m24; - /* 0x26 */ u8 m26[0x28 - 0x26]; - /* 0x28 */ f32 m28; - /* 0x2C */ f32 mShipOffsY_Attention; - /* 0x30 */ f32 mShipOffsY_Eye; - /* 0x34 */ f32 mTerryWaveOffsZ; - /* 0x38 */ f32 mTerryWaveOffsY; - /* 0x3C */ f32 mTerryTrackOffsZ; - /* 0x40 */ f32 mSvWaveOffsX; - /* 0x44 */ f32 mSvTrackOffsX; - /* 0x48 */ f32 mSvOffsX[4]; - /* 0x58 */ f32 mTrackIndTransY; - /* 0x5C */ f32 mTrackIndScaleY; - /* 0x60 */ f32 mSplashScaleMax; - /* 0x64 */ f32 mSplashMaxScaleTimer; - /* 0x68 */ f32 mWaveVelFade; - /* 0x6C */ f32 mTrackVel; - /* 0x70 */ f32 mWaveVelSpeed; - /* 0x74 */ f32 mWaveVelOffs; - /* 0x78 */ f32 mWaveMaxVelocity; - /* 0x7C */ Vec mWaveCollapsePos[2]; - /* 0x94 */ s16 m94; - /* 0x96 */ s16 mPlayerStopDistance; - /* 0x98 */ s16 m98; - /* 0x9A */ s16 m9A; - /* 0x9C */ f32 m9C; - /* 0xA0 */ f32 mVelocityTargetTerry1; - /* 0xA4 */ f32 mVelocityTargetTerry3; - /* 0xA8 */ f32 mA8; -}; // size = 0xAC - #endif /* D_A_OBJ_IKADA_H */ diff --git a/include/d/d_2dnumber.h b/include/d/d_2dnumber.h index 3195ab309..e69ad3ff8 100644 --- a/include/d/d_2dnumber.h +++ b/include/d/d_2dnumber.h @@ -83,6 +83,7 @@ public: class dDlst_2DOutFont_c { public: + dDlst_2DOutFont_c() { m20 = NULL; m18 = NULL; m2C = NULL; m74 = 0; } void setLeftUpPos(f32 x, f32 y) { mPosTopLeftX = x; mPosTopLeftY = y; } void initial(); @@ -107,9 +108,13 @@ public: /* 0x18 */ J2DPane* m18; /* 0x1C */ u8 m1C[0x20 - 0x1C]; /* 0x20 */ JUTFont* m20; - /* 0x24 */ u8 m24[0x30 - 0x24]; + /* 0x24 */ u8 m24[0x2C - 0x24]; + /* 0x2C */ JUTFont* m2C; /* 0x30 */ f32 mPosTopLeftX; /* 0x34 */ f32 mPosTopLeftY; -}; + /* 0x38 */ u8 m38[0x74 - 0x38]; + /* 0x74 */ u8 m74; + /* 0x75 */ u8 m75[0x150 - 0x75]; +}; // Size = 0x150 #endif /* D_2DNUMBER_H */ diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 3ddbc1567..11f36f73a 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -8,6 +8,7 @@ #include "d/d_drawlist.h" #include "d/d_event.h" #include "d/d_event_manager.h" +#include "d/d_item_data.h" #include "d/d_map.h" #include "d/d_particle.h" #include "d/d_resorce.h" diff --git a/include/d/d_drawlist.h b/include/d/d_drawlist.h index 58ed7da0b..61806f656 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -535,8 +535,8 @@ public: J3DDrawBuffer* getXluList() { return mpXluList; } J3DDrawBuffer* getXluListP1() { return mpXluListP1; } - void setXluDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, XLU_BUFFER); } - void setOpaDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, OPA_BUFFER); } + void setXluDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, J3DSysDrawBuf_Xlu); } + void setOpaDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, J3DSysDrawBuf_Opa); } void setOpaList() { setOpaDrawList(mpOpaList); } void setXluList() { setXluDrawList(mpXluList); } void setOpaListInvisible() { setOpaDrawList(mpOpaListInvisible); } diff --git a/include/d/d_lib.h b/include/d/d_lib.h index 89881b724..4ee0575f9 100644 --- a/include/d/d_lib.h +++ b/include/d/d_lib.h @@ -52,6 +52,9 @@ public: class CSTControl : public STControl { public: + CSTControl(s16 a, s16 b, s16 c, s16 d, f32 e = 0.9f, f32 f = 0.5f, s16 g = 0, s16 h = 0x2000) + : STControl(a, b, c, d, e, f, g, h) + {} virtual f32 getValueStick(); virtual s16 getAngleStick(); }; diff --git a/include/d/d_menu_base.h b/include/d/d_menu_base.h index 64dd5b0e6..98ebdcec5 100644 --- a/include/d/d_menu_base.h +++ b/include/d/d_menu_base.h @@ -5,13 +5,14 @@ class dMenu_base_c : public dDlst_base_c { public: - virtual void draw() {} + virtual ~dMenu_base_c() {} virtual void _create() {} virtual void _delete() {} virtual void _move() {} virtual void _draw() {} virtual bool _open() = 0; virtual bool _close() = 0; + virtual void draw() {} }; #endif //D_MENU_BASE_H diff --git a/include/d/d_menu_collect.h b/include/d/d_menu_collect.h index 132a9fee8..810d89084 100644 --- a/include/d/d_menu_collect.h +++ b/include/d/d_menu_collect.h @@ -20,6 +20,7 @@ class JUTFont; class dMenu_Collect_c : public dMenu_base_c { public: + ~dMenu_Collect_c() {} virtual void draw() { _draw(); } void alphaChange(fopMsgM_pane_class* pane, float alpha) { pane->mInitAlpha *= alpha; } @@ -32,15 +33,15 @@ public: void setQuitArchive(JKRArchive* arc) { mpSaveArc = arc; } void setFont(JUTFont* font, JUTFont* rfont) { - mFont = font; - mRFont = rfont; + mpFont = font; + mpRubyFont = rfont; } void setTactTexBuffer(void* ptr) { mTactTexBuffer = (ResTIMG*)ptr; } void setMapTexBuffer(void* ptr) { mMapTexBuffer = (ResTIMG*)ptr; } void setTriforceTexBuffer(int idx, void* ptr) { mTriforceTexBuffer[idx] = (ResTIMG*)ptr; } - void setSymbolTexBuffer(int idx, void* ptr) { mSymbolTexBuffer[idx] = ptr; } - void setItemTexBuffer(int idx, void* ptr) { mItemTexBuffer[idx] = ptr; } + void setSymbolTexBuffer(int idx, void* ptr) { mSymbolTexBuffer[idx] = (ResTIMG*)ptr; } + void setItemTexBuffer(int idx, void* ptr) { mItemTexBuffer[idx] = (ResTIMG*)ptr; } void setTextArea(char* name0, char* name1, char* note0, char* note1, char* dummy0, char* dummy1) { name[0] = name0; @@ -58,7 +59,7 @@ public: void initialize(); void cursorAnime(); int stickDirection(unsigned char); - int cursorMainMove(); + u8 cursorMainMove(); u8 noteCheck(); void noteInit(); void noteAppear(); @@ -176,16 +177,21 @@ private: /* 0x2464 */ JKRArchive* mpArc; /* 0x2468 */ JKRArchive* mpOptArc; /* 0x246C */ JKRArchive* mpSaveArc; - /* 0x2470 */ JUTFont* mFont; - /* 0x2474 */ JUTFont* mRFont; + /* 0x2470 */ JUTFont* mpFont; + /* 0x2474 */ JUTFont* mpRubyFont; /* 0x2478 */ J2DPane* m2478; /* 0x247C */ JPABaseEmitter* m247C[3]; /* 0x2488 */ J2DWindow::TContentsColor m2488; /* 0x2498 */ ResTIMG* mTactTexBuffer; /* 0x249C */ ResTIMG* mMapTexBuffer; /* 0x24A0 */ ResTIMG* mTriforceTexBuffer[8]; - /* 0x24C0 */ void* mSymbolTexBuffer[3]; - /* 0x24CC */ void* mItemTexBuffer[5]; + /* 0x24C0 */ ResTIMG* mSymbolTexBuffer[3]; + /* 0x24CC */ ResTIMG* mItemTexBuffer[5]; +#if VERSION == VERSION_PAL + /* 0x24E0 */ ResTIMG* mWordSaveTexBuffer; + /* 0x24E4 */ ResTIMG* mWordOptionTexBuffer; + /* 0x24E8 */ ResTIMG* mTitleCollectTexBuffer; +#endif /* 0x24E0 */ fopMsgM_msgDataProc_c mMsgProc; /* 0x2780 */ dMenu_Option_c* dMo_c; /* 0x2784 */ dMenu_save_c* dMs_c; @@ -197,12 +203,12 @@ private: /* 0x27B8 */ char* note[2]; /* 0x27C0 */ char* dummy[2]; /* 0x27C8 */ u8 m27C8[0x27DC - 0x27C8]; - /* 0x27DC */ u32 m27DC; + /* 0x27DC */ s32 m27DC; /* 0x27E0 */ s16 m27E0; /* 0x27E2 */ s16 mTimer; - /* 0x27E4 */ u16 m27E4; - /* 0x27E6 */ u16 m27E6; - /* 0x27E8 */ u16 m27E8; + /* 0x27E4 */ s16 m27E4; + /* 0x27E6 */ s16 m27E6; + /* 0x27E8 */ s16 m27E8; /* 0x27EA */ u8 m27EA; /* 0x27EB */ u8 m27EB; /* 0x27EC */ u8 mTriggerInfo; @@ -215,8 +221,6 @@ private: /* 0x27F3 */ u8 m27F3; }; // Size: 0x27F4 -STATIC_ASSERT(sizeof(dMenu_Collect_c) == 0x27F4); - class dMc_HIO_c : public JORReflexible { public: dMc_HIO_c(); diff --git a/include/d/d_menu_option.h b/include/d/d_menu_option.h index bcf7e6a40..93853bf6c 100644 --- a/include/d/d_menu_option.h +++ b/include/d/d_menu_option.h @@ -11,16 +11,19 @@ struct fopMsgM_pane_class; class JKRArchive; class JUTFont; -class dMenu_Option_c : public dDlst_base_c { +class dMenu_Option_c { public: + dMenu_Option_c() { } + virtual ~dMenu_Option_c() {} + void alphaChange(fopMsgM_pane_class*, f32) {} u8 getQuitStatus() { return mE40; } void setArchive(JKRArchive* archive) { mpArchive = archive; } - void setFont(JUTFont* font_1, JUTFont* font_2) { - mD2C = font_1; - mD30 = font_2; + void setFont(JUTFont* i_font, JUTFont* i_rubyFont) { + mpFont = i_font; + mpRubyFont = i_rubyFont; } void setTextArea(char* param_1, char* param_2, char* param_3, char* param_4) { mD38 = param_1; @@ -83,8 +86,8 @@ private: /* 0xC80 */ fopMsgM_pane_class mC80[2]; /* 0xCF0 */ fopMsgM_pane_class mCF0; /* 0xD28 */ JKRArchive* mpArchive; - /* 0xD2C */ JUTFont* mD2C; - /* 0xD30 */ JUTFont* mD30; + /* 0xD2C */ JUTFont* mpFont; + /* 0xD30 */ JUTFont* mpRubyFont; /* 0xD34 */ STControl* stick; /* 0xD38 */ char* mD38; /* 0xD3C */ char* mD3C; diff --git a/include/d/d_save_event_flag.inc b/include/d/d_save_event_flag.inc index 8297a0832..fd99336ce 100644 --- a/include/d/d_save_event_flag.inc +++ b/include/d/d_save_event_flag.inc @@ -45,12 +45,12 @@ public: /* 0x0502 */ UNK_0502 = 0x0502, /* 0x0501 */ UNK_0501 = 0x0501, /* 0x0640 */ UNK_0640 = 0x0640, - /* 0x0608 */ UNK_0608 = 0x0608, + /* 0x0608 */ UNK_0608 = 0x0608, // Set by an unused dialogue /* 0x0604 */ UNK_0604 = 0x0604, - /* 0x0602 */ UNK_0602 = 0x0602, - /* 0x0601 */ UNK_0601 = 0x0601, + /* 0x0602 */ UNK_0602 = 0x0602, // Grandma dialogue after sword obtained + /* 0x0601 */ UNK_0601 = 0x0601, // Grandma dialogue after Helmaroc cutscene (prologue) /* 0x0780 */ UNK_0780 = 0x0780, - /* 0x0740 */ UNK_0740 = 0x0740, + /* 0x0740 */ UNK_0740 = 0x0740, // Grandma dialogue after Aryll kidnapped /* 0x0720 */ UNK_0720 = 0x0720, /* 0x0710 */ UNK_0710 = 0x0710, /* 0x0704 */ UNK_0704 = 0x0704, @@ -317,7 +317,7 @@ public: /* 0x2901 */ UNK_2901 = 0x2901, /* 0x2A80 */ UNK_2A80 = 0x2A80, /* 0x2A40 */ UNK_2A40 = 0x2A40, - /* 0x2A20 */ UNK_2A20 = 0x2A20, + /* 0x2A20 */ GRANDMA_HEALED = 0x2A20, /* 0x2A10 */ UNK_2A10 = 0x2A10, /* 0x2A08 */ RODE_KORL = 0x2A08, /* 0x2A04 */ UNK_2A04 = 0x2A04, diff --git a/include/d/d_snap.h b/include/d/d_snap.h index 7c0b90106..d581e2f0e 100644 --- a/include/d/d_snap.h +++ b/include/d/d_snap.h @@ -79,7 +79,7 @@ enum { /* 0x47 */ DSNAP_TYPE_UNK47, /* 0x48 */ DSNAP_TYPE_UNK48, /* 0x49 */ DSNAP_TYPE_NPC_LS1, - /* 0x4A */ DSNAP_TYPE_UNK4A, + /* 0x4A */ DSNAP_TYPE_NPC_BA1, /* 0x4B */ DSNAP_TYPE_UNK4B, /* 0x4C */ DSNAP_TYPE_UNK4C, /* 0x4D */ DSNAP_TYPE_NPC_JI1, diff --git a/include/d/dolzel.pch b/include/d/dolzel.pch index 608cceab3..45a335ea3 100644 --- a/include/d/dolzel.pch +++ b/include/d/dolzel.pch @@ -29,8 +29,10 @@ #include "JSystem/JKernel/JKRFileFinder.h" // IWYU pragma: export #include "d/d_bg_s_lin_chk.h" // IWYU pragma: export #include "m_Do/m_Do_hostIO.h" // IWYU pragma: export +#include "m_Do/m_Do_graphic.h" // IWYU pragma: export #include "d/d_cc_uty.h" // IWYU pragma: export #include "d/d_magma.h" // IWYU pragma: export #include "d/d_mesg.h" // IWYU pragma: export +#include "d/d_menu_base.h" // IWYU pragma: export #endif /* DOLZEL_PCH */ diff --git a/include/dolphin/gx/GX.h b/include/dolphin/gx/GX.h index 3371092e0..7a5f7ea2b 100644 --- a/include/dolphin/gx/GX.h +++ b/include/dolphin/gx/GX.h @@ -42,6 +42,8 @@ extern "C" { (reg) = ((u32) (reg) & ~(((1 << (nbits)) - 1) << (shift))) | \ ((u32) (value) << (shift)); +#define GET_REG_FIELD(reg, size, shift) ((int)((reg) >> (shift)) & ((1 << (size)) - 1)) + #define SET_REG_FIELD(reg, size, shift, val) \ (reg) = ((u32)(reg) & ~(((1 << (size)) - 1) << (shift))) | ((u32)(val) << (shift)); \ diff --git a/include/dolphin/gx/GXAttr.h b/include/dolphin/gx/GXAttr.h index 9c4940990..6a2ea4568 100644 --- a/include/dolphin/gx/GXAttr.h +++ b/include/dolphin/gx/GXAttr.h @@ -36,6 +36,7 @@ void GXSetNumTexGens(u8 numTexGens); void GXGetVtxAttrFmtv(GXVtxFmt param_0, GXVtxAttrFmtList* param_1); void GXGetVtxAttrFmt(GXVtxFmt param_0, int param_1, GXCompCnt* param_2, GXCompType* param_3, u8* param_4); +void GXGetVtxDesc(GXAttr attr, GXAttrType* type); void GXGetVtxDescv(GXVtxDescList* attrPtr); static inline void GXSetTexCoordGen(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 mtx) { diff --git a/include/dolphin/thp.h b/include/dolphin/thp.h index 455afe6cc..ca0774919 100644 --- a/include/dolphin/thp.h +++ b/include/dolphin/thp.h @@ -28,7 +28,7 @@ typedef struct _THPComponent { THPCoeff predDC; } THPComponent; -typedef struct _THPFileInfo { +typedef struct _local_THPFileInfo { THPQuantTab quantTabs[3]; THPHuffmanTab huffmanTabs[4]; THPComponent components[3]; @@ -116,37 +116,6 @@ typedef struct THPHeader { #define THP_READ_BUFFER_COUNT 10 #define THP_TEXTURE_SET_COUNT 3 -static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag); -static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info); -static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); - -s32 __THPAudioGetNewSample(THPAudioDecodeInfo*); -void __THPAudioInitialize(THPAudioDecodeInfo*, u8*); - -static void __THPSetupBuffers(void); -static u8 __THPReadFrameHeader(void); -static u8 __THPReadScaneHeader(void); -static u8 __THPReadQuantizationTable(void); -static u8 __THPReadHuffmanTableSpecification(void); -static void __THPHuffGenerateSizeTable(void); -static void __THPHuffGenerateCodeTable(void); -static void __THPHuffGenerateDecoderTables(u8 tabIndex); -static void __THPRestartDefinition(void); -static void __THPPrepBitStream(void); -static void __THPDecompressYUV(void* tileY, void* tileU, void* tileV); -static void __THPGQRRestore(void); -static void __THPDecompressiMCURow512x448(void); -static void __THPDecompressiMCURow640x480(void); -static void __THPDecompressiMCURowNxN(void); -static void __THPInverseDCTNoYPos(THPCoeff* in, u32 xPos); -static void __THPHuffDecodeDCTCompY(THPFileInfo* info, THPCoeff* block); -static void __THPHuffDecodeDCTCompU(THPFileInfo* info, THPCoeff* block); -static void __THPHuffDecodeDCTCompV(THPFileInfo* info, THPCoeff* block); - -static void __THPInverseDCTY8(THPCoeff* in, u32 xPos); -static void __THPGQRSetup(); -static s32 __THPHuffDecodeTab(THPFileInfo* info, THPHuffmanTab* h); - #ifdef __cplusplus } #endif diff --git a/include/f_ap/f_ap_game.h b/include/f_ap/f_ap_game.h index c5d7c0995..a2d8390eb 100644 --- a/include/f_ap/f_ap_game.h +++ b/include/f_ap/f_ap_game.h @@ -17,7 +17,7 @@ public: public: /* 0x04 */ s8 mNo; - /* 0x05 */ u8 field_0x05; + /* 0x05 */ u8 mUsingHostIO; /* 0x06 */ u8 mDisplayMeter; /* 0x07 */ u8 mDisplayFlag; /* 0x08 */ u8 field_0x08; @@ -41,7 +41,7 @@ public: /* 0x1D */ u8 field_0x1d; /* 0x1E */ u8 field_0x1e; /* 0x1F */ u8 field_0x1f; - /* 0x20 */ JUtility::TColor field_0x20; + /* 0x20 */ JUtility::TColor mColor; /* 0x24 */ f32 mTriggerThreshLo; /* 0x28 */ f32 mTriggerThreshHi; /* 0x2C */ s16 mFbWidth; @@ -58,16 +58,16 @@ public: /* 0x39 */ u8 field_0x39; /* 0x3A */ u8 field_0x3a; /* 0x3B */ u8 field_0x3b; - /* 0x3C */ JUtility::TColor field_0x3c; - /* 0x40 */ JUtility::TColor field_0x40; - /* 0x44 */ JUtility::TColor field_0x44; - /* 0x48 */ JUtility::TColor field_0x48; - /* 0x4C */ u16 field_0x4c; - /* 0x4E */ u16 field_0x4e; - /* 0x50 */ u16 field_0x50; - /* 0x52 */ u16 field_0x52; - /* 0x54 */ u16 field_0x54; - /* 0x56 */ u8 field_0x56; + /* 0x3C */ JUtility::TColor mLetterTopColor; + /* 0x40 */ JUtility::TColor mLetterBottomColor; + /* 0x44 */ JUtility::TColor mLetterTopShadowColor; + /* 0x48 */ JUtility::TColor mLetterBottomShadowColor; + /* 0x4C */ u16 mLetterPositionX; + /* 0x4E */ u16 mLetterPositionY; + /* 0x50 */ u16 mLineSpacing; + /* 0x52 */ u16 mLetterSpacing; + /* 0x54 */ u16 mLetterFontSize; + /* 0x56 */ u8 mBackgroundAlpha; }; // Size: 0x58 extern fapGm_HIO_c g_HIO; diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index c01a4479c..0c048fce0 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -127,22 +127,6 @@ inline MtxP fopAcM_GetMtx(fopAc_ac_c* pActor) { return pActor->cullMtx; } -inline u32 fopAcM_CheckStatus(fopAc_ac_c* pActor, u32 status) { - return pActor->actor_status & status; -} - -inline u32 fopAcM_checkCarryNow(fopAc_ac_c* pActor) { - return pActor->actor_status & fopAcStts_CARRY_e; -} - -inline void fopAcM_ClearStatusMap(fopAc_ac_c* pActor) { - pActor->actor_status &= ~0x3F; -} - -inline bool fopAcM_checkHookCarryNow(fopAc_ac_c* pActor) { - return fopAcM_CheckStatus(pActor, fopAcStts_HOOK_CARRY_e); -} - inline u32 fopAcM_GetParam(void* pActor) { return fpcM_GetParam(pActor); } @@ -179,6 +163,10 @@ inline void fopAcM_SetGroup(fopAc_ac_c* pActor, u8 group) { pActor->group = group; } +inline u32 fopAcM_CheckStatus(fopAc_ac_c* pActor, u32 status) { + return pActor->actor_status & status; +} + inline void fopAcM_OnStatus(fopAc_ac_c* pActor, u32 flag) { pActor->actor_status |= flag; } @@ -187,6 +175,14 @@ inline void fopAcM_OffStatus(fopAc_ac_c* pActor, u32 flag) { pActor->actor_status &= ~flag; } +inline u32 fopAcM_checkCarryNow(fopAc_ac_c* pActor) { + return pActor->actor_status & fopAcStts_CARRY_e; +} + +inline bool fopAcM_checkHookCarryNow(fopAc_ac_c* pActor) { + return fopAcM_CheckStatus(pActor, fopAcStts_HOOK_CARRY_e); +} + inline BOOL fopAcM_CheckStatusMap(fopAc_ac_c* pActor, u32) { // TODO: This implementation probably isn't right, the u32 argument is likely used for something return (pActor->actor_status & fopAcStts_SHOWMAP_e) && (pActor->actor_status & 0x1F) == 0; @@ -196,6 +192,10 @@ inline void fopAcM_SetStatusMap(fopAc_ac_c* pActor, u32 flag) { pActor->actor_status = (pActor->actor_status & ~0x3F) | fopAcStts_SHOWMAP_e | flag; } +inline void fopAcM_ClearStatusMap(fopAc_ac_c* pActor) { + pActor->actor_status &= ~0x3F; +} + inline fopAc_ac_c* fopAcM_Search(fopAcIt_JudgeFunc func, void* param) { return (fopAc_ac_c*)fopAcIt_Judge(func, param); } diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index 7f767d11a..777024cd2 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -354,7 +354,9 @@ inline void mDoAud_tact_melodyPlay(s32 param_1) { mDoAud_zelAudio_c::getTact().melodyPlay(param_1); } -inline void mDoAud_tact_melodyStop() {} +inline void mDoAud_tact_melodyStop() { + mDoAud_zelAudio_c::getTact().melodyStop(); +} inline BOOL mDoAud_checkCbPracticePlay() { return mDoAud_zelAudio_c::getInterface()->checkCbPracticePlay(); diff --git a/include/m_Do/m_Do_mtx.h b/include/m_Do/m_Do_mtx.h index 4fdaf59f7..483c1eaa2 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -95,6 +95,10 @@ inline void cMtx_copy(CMtxP src, MtxP dst) { mDoMtx_copy(src, dst); } +inline void cMtx_trans(Mtx dst, f32 x, f32 y, f32 z) { + mDoMtx_trans(dst, x, y, z); +} + inline void cMtx_multVecArray(Mtx mtx, const Vec* src, Vec* dst, u32 count) { mDoMtx_multVecArray(mtx, src, dst, count); } diff --git a/src/d/actor/d_a_am.cpp b/src/d/actor/d_a_am.cpp index c72bebad5..33e77e58e 100644 --- a/src/d/actor/d_a_am.cpp +++ b/src/d/actor/d_a_am.cpp @@ -82,6 +82,7 @@ static BOOL nodeCallBack(J3DNode* node, int calcTiming) { case AM_JNT_EYE_e: cMtx_YrotM(*calc_mtx, i_this->mEyeRot.y); cMtx_XrotM(*calc_mtx, i_this->mEyeRot.x); + break; } if (jntNo >= AM_JNT_KOSI_e && jntNo <= AM_JNT_EYE_e) { diff --git a/src/d/actor/d_a_bmd.cpp b/src/d/actor/d_a_bmd.cpp index 7c46ce4ad..704e0c50b 100644 --- a/src/d/actor/d_a_bmd.cpp +++ b/src/d/actor/d_a_bmd.cpp @@ -2027,7 +2027,7 @@ static cPhs_State daBmd_Create(fopAc_ac_c* a_this) { i_this->mB71 = 1; } dKyw_pntwind_set(&i_this->mWindInfluence); - a_this->attention_info.distances[2] = 4; + a_this->attention_info.distances[fopAc_Attn_TYPE_BATTLE_e] = 4; daBmd_Execute(i_this); res = cPhs_COMPLEATE_e; } diff --git a/src/d/actor/d_a_bpw.cpp b/src/d/actor/d_a_bpw.cpp index ab9499fbc..73fc26769 100644 --- a/src/d/actor/d_a_bpw.cpp +++ b/src/d/actor/d_a_bpw.cpp @@ -4385,11 +4385,11 @@ void body_create_init(bpw_class* i_this) { fopAcM_SetMtx(actor, i_this->mpMorf->getModel()->getBaseTRMtx()); fopAcM_setCullSizeBox(actor, -300.0f, -300.0f, -300.0f, 300.0f, 300.0f, 300.0f); actor->attention_info.flags = fopAc_Attn_LOCKON_BATTLE_e; - actor->attention_info.distances[2] = 4; + actor->attention_info.distances[fopAc_Attn_TYPE_BATTLE_e] = 4; fopAcM_OnStatus(actor, fopAcStts_BOSS_e); i_this->mAcch.Set(fopAcM_GetPosition_p(actor), fopAcM_GetOldPosition_p(actor), actor, 1, &i_this->mAcchCir, fopAcM_GetSpeed_p(actor)); i_this->mStts.Init(0xfe, 1, actor); - actor->attention_info.distances[4] = 0x25; + actor->attention_info.distances[fopAc_Attn_TYPE_CARRY_e] = 0x25; fopAcM_OnStatus(actor, fopAcStts_UNK10000_e); i_this->mBodyCoSph.Set(body_co_sph_src); i_this->mBodyCoSph.SetStts(&i_this->mStts); diff --git a/src/d/actor/d_a_bwd.cpp b/src/d/actor/d_a_bwd.cpp index e9cb7df2e..b76a2bd46 100644 --- a/src/d/actor/d_a_bwd.cpp +++ b/src/d/actor/d_a_bwd.cpp @@ -2508,7 +2508,7 @@ static cPhs_State daBwd_Create(fopAc_ac_c* a_this) { } } a_this->attention_info.flags = fopAc_Attn_LOCKON_BATTLE_e; - a_this->attention_info.distances[2] = 0x22; + a_this->attention_info.distances[fopAc_Attn_TYPE_BATTLE_e] = 0x22; if (hio_set == 0) { i_this->m3C51 = 1; hio_set = 1; diff --git a/src/d/actor/d_a_dai.cpp b/src/d/actor/d_a_dai.cpp index 90520e811..759272efb 100644 --- a/src/d/actor/d_a_dai.cpp +++ b/src/d/actor/d_a_dai.cpp @@ -133,7 +133,6 @@ cPhs_State daDai_c::_create() { if (PVar3 != cPhs_COMPLEATE_e) { return PVar3; } - #else if (PVar2 != cPhs_COMPLEATE_e) { return PVar2; diff --git a/src/d/actor/d_a_dai_item.cpp b/src/d/actor/d_a_dai_item.cpp index ecce612c5..6004fce5f 100644 --- a/src/d/actor/d_a_dai_item.cpp +++ b/src/d/actor/d_a_dai_item.cpp @@ -202,8 +202,8 @@ bool daStandItem_c::_delete() { m698 = NULL; } - dComIfG_resDelete(&mPhsDai, m_arcname); - dComIfG_resDelete(&mPhsCloth, "Cloth"); + dComIfG_resDeleteDemo(&mPhsDai, m_arcname); + dComIfG_resDeleteDemo(&mPhsCloth, "Cloth"); return true; } @@ -215,7 +215,7 @@ static BOOL CheckCreateHeap(fopAc_ac_c* i_ac) { /* 800E37B8-800E3AF8 .text CreateHeap__13daStandItem_cFv */ BOOL daStandItem_c::CreateHeap() { J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(m_arcname, m_bmdidx[mItemType]); - JUT_ASSERT(0x239, modelData != NULL); + JUT_ASSERT(DEMO_SELECT(566, 569), modelData != NULL); if (mItemNo == dItemNo_SHOP_GURU_STATUE_e) { mpModel = mDoExt_J3DModel__create(modelData, 0x0, 0x11020203); @@ -228,7 +228,7 @@ BOOL daStandItem_c::CreateHeap() { if (m_bckidx[mItemType] != -1) { J3DAnmTransform* pbck = (J3DAnmTransform*)dComIfG_getObjectRes(m_arcname, m_bckidx[mItemType]); - JUT_ASSERT(0x250, pbck != NULL); + JUT_ASSERT(DEMO_SELECT(589, 592), pbck != NULL); mpBckAnm = new mDoExt_bckAnm(); static const u32 playmode[] = { @@ -297,6 +297,37 @@ BOOL daStandItem_c::CreateHeap() { return TRUE; } +#if VERSION == VERSION_DEMO +// Note: Retail moved this into d_com_static.cpp as daStandItem_c::daiItemNodeCallBack +static BOOL nodeCallBack(J3DNode* node, int calcTiming) { + if (calcTiming == J3DNodeCBCalcTiming_In) { + J3DJoint* joint = (J3DJoint*)node; + s32 jntNo = joint->getJntNo(); + J3DModel* model = j3dSys.getModel(); + void* userArea = (void*)model->getUserArea(); + if (userArea && fopAcM_IsActor(userArea) && fopAcM_GetName(userArea) == fpcNm_STANDITEM_e) { + daStandItem_c* i_this = (daStandItem_c*)userArea; + mDoMtx_stack_c::copy(model->getAnmMtx(jntNo)); + switch (i_this->getItemNo()) { + case dItemNo_PINWHEEL_e: + mDoMtx_stack_c::XrotM(i_this->m6B4); + break; + case dItemNo_FOUNTAIN_IDOL_e: + if (jntNo == FOBJ09_JNT_TUBOKO_BASE_e) { + mDoMtx_copy(mDoMtx_stack_c::get(), i_this->m630); + } else if (jntNo == FOBJ09_JNT_TUBOKO_HEAD_e) { + mDoMtx_copy(mDoMtx_stack_c::get(), i_this->m660); + } + break; + } + model->setAnmMtx(jntNo, mDoMtx_stack_c::get()); + cMtx_copy(mDoMtx_stack_c::get(), J3DSys::mCurrentMtx); + } + } + return TRUE; +} +#endif + /* 800E3AF8-800E3E94 .text CreateInit__13daStandItem_cFv */ void daStandItem_c::CreateInit() { fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); @@ -312,7 +343,9 @@ void daStandItem_c::CreateInit() { m6A4 = *dKyw_get_wind_vec(); m6A2 = cM_atan2s(m6A4.x, m6A4.z); set_mtx(); +#if VERSION > VERSION_DEMO mpModel->setUserArea(NULL); +#endif JUTNameTab* jointNameTab = mpModel->getModelData()->getJointName(); const char* jointName; @@ -323,7 +356,7 @@ void daStandItem_c::CreateInit() { for (i = 0; i < mpModel->getModelData()->getJointNum(); i++) { jointName = jointNameTab->getName(i); if (strcmp("top", jointName) == 0) { - mpModel->getModelData()->getJointNodePointer(i)->setCallBack(daiItemNodeCallBack); + mpModel->getModelData()->getJointNodePointer(i)->setCallBack(DEMO_SELECT(nodeCallBack, daiItemNodeCallBack)); break; } } @@ -336,7 +369,7 @@ void daStandItem_c::CreateInit() { for (i = 0; i < mpModel->getModelData()->getJointNum(); i++) { jointName = jointNameTab->getName(i); if (strcmp("tuboko_head", jointName) == 0 || strcmp("tuboko_base", jointName) == 0) - mpModel->getModelData()->getJointNodePointer(i)->setCallBack(daiItemNodeCallBack); + mpModel->getModelData()->getJointNodePointer(i)->setCallBack(DEMO_SELECT(nodeCallBack, daiItemNodeCallBack)); } mpModel->setUserArea((u32)this); mpModel->calc(); @@ -352,18 +385,20 @@ void daStandItem_c::CreateInit() { s16 stopMaxTime = m_stop_max_time[mItemType]; s16 r29 = (animMinTime + animMaxTime) / 2; s16 r28 = (animMaxTime - animMinTime) / 2; + s16 temp3 = (stopMinTime + stopMaxTime) / 2; s16 temp = (stopMaxTime - stopMinTime) / 2; mBckPlayTimer = 0; f32 temp2 = cM_rndFX(temp); - s16 temp3 = (stopMinTime + stopMaxTime) / 2; mBckStopTimer = temp3 + temp2; if (stopMaxTime == 0) { mBckPlayTimer = r29 + cM_rndFX(r28); } +#if VERSION > VERSION_DEMO m690 = NULL; m694 = NULL; m698 = NULL; +#endif #if VERSION > VERSION_JPN g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &tevStr); #endif @@ -376,6 +411,23 @@ cPhs_State daStandItem_c::_create() { mItemNo = fopAcM_GetParam(this); mItemType = convItemNo(mItemNo); +#if VERSION == VERSION_DEMO + cPhs_State rt; + cPhs_State cloth_rt; + rt = dComIfG_resLoad(&mPhsDai, m_arcname); + cloth_rt = dComIfG_resLoad(&mPhsCloth, "Cloth"); + + if (rt == cPhs_ERROR_e || cloth_rt == cPhs_ERROR_e) { + return cPhs_ERROR_e; + } + if (rt != cPhs_COMPLEATE_e) { + return rt; + } + // !@bug They meant to check cloth_rt here, instead they check rt a second time. + if (rt != cPhs_COMPLEATE_e) { + return cloth_rt; + } +#else cPhs_State rt = dComIfG_resLoad(&mPhsDai, m_arcname); if (rt != cPhs_COMPLEATE_e) return rt; @@ -383,6 +435,7 @@ cPhs_State daStandItem_c::_create() { cPhs_State cloth_rt = dComIfG_resLoad(&mPhsCloth, "Cloth"); if (cloth_rt != cPhs_COMPLEATE_e) return cloth_rt; +#endif if (rt == cPhs_COMPLEATE_e && cloth_rt == cPhs_COMPLEATE_e) { if (!fopAcM_entrySolidHeap(this, CheckCreateHeap, m_heapsize[mItemType])) @@ -509,7 +562,8 @@ bool daStandItem_c::actionFobj06() { m6C4 = 4.0f; } - m6B2 = m6C4 * 0x600; + int r0 = 0x600; + m6B2 = (f32)r0 * m6C4; cLib_addCalc(&m6C4, 0.0f, 0.08f, dKyw_get_wind_pow() + 0.3f, dKyw_get_wind_pow() + 0.1f); m6B4 += m6B2; return true; @@ -572,7 +626,10 @@ bool daStandItem_c::actionFobj09() { if (m694 == NULL) { m694 = dComIfGp_particle_set(dPa_name::ID_AK_SN_FOUNTAINFIGURE01, ¤t.pos, ¤t.angle, NULL, 0xFF, NULL, fopAcM_GetRoomNo(this), &tevStr.mColorK0); } - if (m698 == NULL) { +#if VERSION > VERSION_DEMO + if (m698 == NULL) +#endif + { m698 = dComIfGp_particle_set(dPa_name::ID_AK_SN_FOUNTAINFIGURE02, ¤t.pos, ¤t.angle); } if (m698) { @@ -627,8 +684,8 @@ void daStandItem_c::animTest() { } if (mBckSpeed == 0.0f || mBckPlayTimer == 0) { mpBckAnm->setPlaySpeed(0.0f); - s16 temp = (stopMaxTime - stopMinTime) / 2; s16 temp2 = (stopMinTime + stopMaxTime) / 2; + s16 temp = (stopMaxTime - stopMinTime) / 2; mBckStopTimer = temp2 + cM_rndFX(temp); } } else if (mBckStopTimer > 0) { @@ -637,8 +694,8 @@ void daStandItem_c::animTest() { mBckStopTimer = 1; } if (mBckStopTimer == 0) { - s16 temp = (animMaxTime - animMinTime) / 2; s16 temp2 = (animMinTime + animMaxTime) / 2; + s16 temp = (animMaxTime - animMinTime) / 2; mBckPlayTimer = temp2 + cM_rndFX(temp); mBckSpeed = 1.0f; if (mpBckAnm) { @@ -662,8 +719,8 @@ void daStandItem_c::animTestForOneTime() { if (mBckStopTimer == 0) { mpBckAnm->setPlaySpeed(1.0f); mpBckAnm->setFrame(0.0f); - s16 temp = (animMaxTime - animMinTime) / 2; s16 temp2 = (animMinTime + animMaxTime) / 2; + s16 temp = (animMaxTime - animMinTime) / 2; mBckPlayTimer = temp2 + cM_rndFX(temp); } } else if (mBckPlayTimer > 0) { @@ -672,8 +729,8 @@ void daStandItem_c::animTestForOneTime() { mpBckAnm->setPlaySpeed(1.0f); mpBckAnm->setFrame(0.0f); } else if (mBckPlayTimer == 0 && isStop) { - s16 temp = (stopMaxTime - stopMinTime) / 2; s16 temp2 = (stopMinTime + stopMaxTime) / 2; + s16 temp = (stopMaxTime - stopMinTime) / 2; mBckStopTimer = temp2 + cM_rndFX(temp); } else if (mBckPlayTimer == 0) { mBckPlayTimer = 1; @@ -754,13 +811,22 @@ void daStandItem_c::mode_drop() { bool daStandItem_c::_draw() { g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &tevStr); g_env_light.setLightTevColorType(mpModel, &tevStr); +#if VERSION == VERSION_DEMO + if (mpBckAnm != NULL) + mpBckAnm->entry(mpModel->getModelData()); + if (mItemNo == dItemNo_PINWHEEL_e) + mDoExt_bckAnmRemove(mpModel->getModelData()); +#else if (mItemNo == dItemNo_PINWHEEL_e) mDoExt_bckAnmRemove(mpModel->getModelData()); else if (mpBckAnm != NULL) mpBckAnm->entry(mpModel->getModelData()); +#endif - if (mItemNo == dItemNo_SHOP_GURU_STATUE_e) - dDlst_texSpecmapST(&eyePos, &tevStr, mpModel->getModelData(), 1.0f); + if (mItemNo == dItemNo_SHOP_GURU_STATUE_e) { + f32 scale = 1.0f; + dDlst_texSpecmapST(&eyePos, &tevStr, mpModel->getModelData(), scale); + } mDoExt_modelUpdateDL(mpModel); if (mpCloth != NULL) diff --git a/src/d/actor/d_a_daiocta_eye.cpp b/src/d/actor/d_a_daiocta_eye.cpp index b7cb9b9ab..2db7c1400 100644 --- a/src/d/actor/d_a_daiocta_eye.cpp +++ b/src/d/actor/d_a_daiocta_eye.cpp @@ -174,7 +174,7 @@ BOOL daDaiocta_Eye_c::_createHeap() { } /* 000004E4-00000510 .text coHit_CB__FP10fopAc_ac_cP12dCcD_GObjInfP10fopAc_ac_cP12dCcD_GObjInf */ -void coHit_CB(fopAc_ac_c* i_this, dCcD_GObjInf*, fopAc_ac_c* i_actor, dCcD_GObjInf*) { +static void coHit_CB(fopAc_ac_c* i_this, dCcD_GObjInf*, fopAc_ac_c* i_actor, dCcD_GObjInf*) { if(i_actor) { ((daDaiocta_Eye_c *)i_this)->_coHit(i_actor); } diff --git a/src/d/actor/d_a_fallrock.cpp b/src/d/actor/d_a_fallrock.cpp index 204339402..b99304c3d 100644 --- a/src/d/actor/d_a_fallrock.cpp +++ b/src/d/actor/d_a_fallrock.cpp @@ -105,7 +105,7 @@ BOOL daFallRock_c::execute() { fopAcM_posMoveF(this, mStts.GetCCMoveP()); field_0x29C.CrrPos(*dComIfG_Bgsp()); - field_0x610 = fabs(speed.y) + (f64)field_0x610; + field_0x610 = fabs(speed.y) + field_0x610; if (field_0x610 > m_falllen) { if (deleted == FALSE) { deleted = fopAcM_delete(this); diff --git a/src/d/actor/d_a_fm.cpp b/src/d/actor/d_a_fm.cpp index 69d493ae0..aa5e9e6af 100644 --- a/src/d/actor/d_a_fm.cpp +++ b/src/d/actor/d_a_fm.cpp @@ -526,7 +526,7 @@ bool daFm_c::jntHitCreateHeap() { } /* 00000A30-00000A6C .text pathMove_CB__FP4cXyzP4cXyzP4cXyzPv */ -BOOL pathMove_CB(cXyz* param_1, cXyz* param_2, cXyz* param_3, void* i_this) { +static BOOL pathMove_CB(cXyz* param_1, cXyz* param_2, cXyz* param_3, void* i_this) { return ((daFm_c*)i_this)->_pathMove(param_1, param_2, param_3 ); } @@ -551,7 +551,7 @@ BOOL daFm_c::_pathMove(cXyz* param_1, cXyz* param_2, cXyz* param_3) { } /* 00000D40-00000D6C .text searchNearOtherActor_CB__FPvPv */ -void* searchNearOtherActor_CB(void* param_1, void* param_2) { +static void* searchNearOtherActor_CB(void* param_1, void* param_2) { return ((daFm_c*)param_2)->searchNearOtherActor((fopAc_ac_c*)param_1); } diff --git a/src/d/actor/d_a_gy_ctrl.cpp b/src/d/actor/d_a_gy_ctrl.cpp index e39778795..bac95efa8 100644 --- a/src/d/actor/d_a_gy_ctrl.cpp +++ b/src/d/actor/d_a_gy_ctrl.cpp @@ -62,7 +62,7 @@ daGy_Ctrl_HIO_c::daGy_Ctrl_HIO_c() { } /* 000001B8-000001E4 .text searchNearActor_CB__FPvPv */ -void* searchNearActor_CB(void* arg0, void* arg1) { +static void* searchNearActor_CB(void* arg0, void* arg1) { return ((daGy_Ctrl_c*)arg1)->searchNearActor((fopAc_ac_c*)arg0); } diff --git a/src/d/actor/d_a_hmlif.cpp b/src/d/actor/d_a_hmlif.cpp index ea2ba404c..49fbdaa09 100644 --- a/src/d/actor/d_a_hmlif.cpp +++ b/src/d/actor/d_a_hmlif.cpp @@ -416,7 +416,9 @@ void daHmlif_c::lift_normal_move() { cLib_addCalcPos2(¤t.pos, m450, 1.0f, fopAcM_GetSpeedF(this)); } -BOOL daHmlif_c::check_path_point(cXyz, cXyz, cXyz, s8) { +BOOL daHmlif_c::check_path_point(cXyz, cXyz, s8) { + // Unused stripped function + return FALSE; } /* 00001270-00001410 .text set_next_pnt__9daHmlif_cFv */ diff --git a/src/d/actor/d_a_magma.cpp b/src/d/actor/d_a_magma.cpp index edecfc569..94cae3930 100644 --- a/src/d/actor/d_a_magma.cpp +++ b/src/d/actor/d_a_magma.cpp @@ -10,11 +10,11 @@ #include "d/d_magma.h" daMagma_c::~daMagma_c() { - dComIfG_resDelete(&mPhs, "Magma"); + dComIfG_resDeleteDemo(&mPhs, "Magma"); } cPhs_State daMagma_c::create() { - fopAcM_ct(this, daMagma_c); + fopAcM_ct_Retail(this, daMagma_c); cPhs_State result = dComIfG_resLoad(&mPhs, "Magma"); if (result != cPhs_COMPLEATE_e) { @@ -25,7 +25,7 @@ cPhs_State daMagma_c::create() { dComIfGp_getMagma()->newFloor( current.pos, scale, - current.roomNo, + fopAcM_GetRoomNo(this), getPathNo() ); } diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index b5282b97a..abf611ebb 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -62,68 +62,72 @@ static const f64 __THPAANScaleFactor[8] = { #define THPROUNDUP(a, b) ((((s32)(a)) + ((s32)(b)-1L)) / ((s32)(b))) -daMP_Player_c daMP_ActivePlayer; +static daMP_Player_c daMP_ActivePlayer; -BOOL daMP_ReadThreadCreated; -OSMessageQueue daMP_FreeReadBufferQueue; -OSMessageQueue daMP_ReadedBufferQueue; -OSMessageQueue daMP_ReadedBufferQueue2; -OSMessage daMP_FreeReadBufferMessage[10]; -OSMessage daMP_ReadedBufferMessage[10]; -OSMessage daMP_ReadedBufferMessage2[10]; -OSThread daMP_ReadThread; -u8 daMP_ReadThreadStack[0x1000]; +static BOOL daMP_ReadThreadCreated; +static OSMessageQueue daMP_FreeReadBufferQueue; +static OSMessageQueue daMP_ReadedBufferQueue; +static OSMessageQueue daMP_ReadedBufferQueue2; +static OSMessage daMP_FreeReadBufferMessage[10]; +static OSMessage daMP_ReadedBufferMessage[10]; +static OSMessage daMP_ReadedBufferMessage2[10]; +static OSThread daMP_ReadThread; +static u8 daMP_ReadThreadStack[0x1000]; -BOOL daMP_VideoDecodeThreadCreated; -OSThread daMP_VideoDecodeThread; -u8 daMP_VideoDecodeThreadStack[0x64000]; +static BOOL daMP_VideoDecodeThreadCreated; +static OSThread daMP_VideoDecodeThread; +static u8 daMP_VideoDecodeThreadStack[0x64000]; -OSMessageQueue daMP_FreeTextureSetQueue; -OSMessageQueue daMP_DecodedTextureSetQueue; -OSMessage daMP_FreeTextureSetMessage[3]; -OSMessage daMP_DecodedTextureSetMessage[3]; +static OSMessageQueue daMP_FreeTextureSetQueue; +static OSMessageQueue daMP_DecodedTextureSetQueue; +static OSMessage daMP_FreeTextureSetMessage[3]; +static OSMessage daMP_DecodedTextureSetMessage[3]; -BOOL daMP_First; +static BOOL daMP_First; -BOOL daMP_AudioDecodeThreadCreated; -OSThread daMP_AudioDecodeThread; -u8 daMP_AudioDecodeThreadStack[0x64000]; -OSMessageQueue daMP_FreeAudioBufferQueue; -OSMessageQueue daMP_DecodedAudioBufferQueue; -OSMessage daMP_FreeAudioBufferMessage[3]; -OSMessage daMP_DecodedAudioBufferMessage[3]; +static BOOL daMP_AudioDecodeThreadCreated; +static OSThread daMP_AudioDecodeThread; +static u8 daMP_AudioDecodeThreadStack[0x64000]; +static OSMessageQueue daMP_FreeAudioBufferQueue; +static OSMessageQueue daMP_DecodedAudioBufferQueue; +static OSMessage daMP_FreeAudioBufferMessage[3]; +static OSMessage daMP_DecodedAudioBufferMessage[3]; -BOOL daMP_Initialized; -u32 daMP_WorkBuffer[16] ALIGN_DECL(32); -OSMessageQueue daMP_PrepareReadyQueue; -OSMessageQueue daMP_UsedTextureSetQueue; -OSMessage daMP_PrepareReadyMessage; -OSMessage daMP_UsedTextureSetMessage[3]; -VIRetraceCallback daMP_OldVIPostCallback; +static BOOL daMP_Initialized; +static u32 daMP_WorkBuffer[16] ALIGN_DECL(32); +static OSMessageQueue daMP_PrepareReadyQueue; +static OSMessageQueue daMP_UsedTextureSetQueue; +static OSMessage daMP_PrepareReadyMessage; +static OSMessage daMP_UsedTextureSetMessage[3]; +static VIRetraceCallback daMP_OldVIPostCallback; -u32 daMP_SoundBufferIndex; -u32 daMP_OldAIDCallback; +static u32 daMP_SoundBufferIndex; +static u32 daMP_OldAIDCallback; -void* daMP_LastAudioBuffer; -void* daMP_CurAudioBuffer; -s32 daMP_AudioSystem; -s16 daMP_SoundBuffer[2][0x460] ALIGN_DECL(32); +static void* daMP_LastAudioBuffer; +static void* daMP_CurAudioBuffer; +static s32 daMP_AudioSystem; +static s16 daMP_SoundBuffer[2][0x460] ALIGN_DECL(32); -THPVideoInfo daMP_videoInfo; -THPAudioInfo daMP_audioInfo; -u32 daMP_DrawPosX; -u32 daMP_DrawPosY; -void* daMP_buffer; +static THPVideoInfo daMP_videoInfo; +static THPAudioInfo daMP_audioInfo; +static u32 daMP_DrawPosX; +static u32 daMP_DrawPosY; +static void* daMP_buffer; +#if VERSION > VERSION_DEMO BOOL daMP_Fail_alloc; u16 daMP_backup_FrameRate; u8 daMP_backup_vfilter[7]; +#endif daMP_Dlst_base_c daMP_c_Dlst_base; +#if VERSION > VERSION_DEMO #ifdef __cplusplus extern "C" { #endif +#endif /* 000000EC-00000584 .text THPAudioDecode */ static u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag) { @@ -2618,8 +2622,10 @@ static BOOL THPInit() { return TRUE; } +#if VERSION > VERSION_DEMO #ifdef __cplusplus -} +} // extern "C" +#endif #endif /* 00003208-0000323C .text daMP_PopReadedBuffer__Fv */ @@ -4150,8 +4156,7 @@ static u32 daMP_Get_MovieRestFrame() { } /* 000062F0-00006370 .text daMP_Set_PercentMovieVolume__Ff */ -static u32 daMP_Set_PercentMovieVolume(f32 volume) { - /* Nonmatching - regalloc */ +static void daMP_Set_PercentMovieVolume(f32 volume) { #if VERSION > VERSION_DEMO if (!daMP_Fail_alloc) #endif diff --git a/src/d/actor/d_a_npc_aj1.cpp b/src/d/actor/d_a_npc_aj1.cpp index 43d6c9f29..8eacaaac7 100644 --- a/src/d/actor/d_a_npc_aj1.cpp +++ b/src/d/actor/d_a_npc_aj1.cpp @@ -37,7 +37,7 @@ static BOOL CheckCreateHeap(fopAc_ac_c*) { } /* 0000044C-0000046C .text daNpc_Aj1_XyCheck_CB__FPvi */ -void daNpc_Aj1_XyCheck_CB(void*, int) { +static void daNpc_Aj1_XyCheck_CB(void*, int) { /* Nonmatching */ } diff --git a/src/d/actor/d_a_npc_ba1.cpp b/src/d/actor/d_a_npc_ba1.cpp index cf37081c4..8eb3bb896 100644 --- a/src/d/actor/d_a_npc_ba1.cpp +++ b/src/d/actor/d_a_npc_ba1.cpp @@ -1,499 +1,2078 @@ /** - * d_a_npc_ba1.cpp - * NPC - Link's Grandma - */ +* d_a_npc_ba1.cpp +* NPC - Link's Grandma +*/ #include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_npc_ba1.h" +#include "d/actor/d_a_npc_fa1.h" +#include "d/actor/d_a_player.h" +#include "d/d_letter.h" +#include "d/d_snap.h" +#include "res/Object/Ba.h" + +class daNpc_Ba1_HIO_c : public mDoHIO_entry_c { +public: + struct hio_prm_c { + /* 0x00 */ s16 mMaxHeadX; + /* 0x02 */ s16 mMaxHeadY; + /* 0x04 */ s16 mMinHeadX; + /* 0x06 */ s16 mMinHeadY; + /* 0x08 */ s16 mMaxBackboneX; + /* 0x0A */ s16 mMaxBackboneY; + /* 0x0C */ s16 mMinBackboneX; + /* 0x0E */ s16 mMinBackboneY; + /* 0x10 */ s16 mMaxTurnStep; + /* 0x12 */ s16 mCalcAngleTarget; + /* 0x14 */ f32 mAttPosOffsetY; + /* 0x18 */ u8 m18; + /* 0x1C */ f32 m1C; + /* 0x20 */ f32 m20; + }; // Size: 0x2C + + daNpc_Ba1_HIO_c(); + virtual ~daNpc_Ba1_HIO_c() {}; + + void genMessage(JORMContext* ctx) {} + +public: + /* 0x04 */ s8 mNo; + /* 0x05 */ s8 field_0x5; + /* 0x06 */ s8 field_0x6; + /* 0x07 */ s8 field_0x7; + /* 0x08 */ int field_0x8; + /* 0x0C */ hio_prm_c mPrmTbl; + +}; /* 000000EC-00000150 .text __ct__15daNpc_Ba1_HIO_cFv */ daNpc_Ba1_HIO_c::daNpc_Ba1_HIO_c() { - /* Nonmatching */ + static hio_prm_c a_prm_tbl = { + /* mMaxHeadX */ 0x1554, + /* mMaxHeadY */ 0x2000, + /* mMinHeadX */ 0xEC78, + /* mMinHeadY */ 0xE000, + /* mMaxBackboneX */ 0x0000, + /* mMaxBackboneY */ 0x1000, + /* mMinBackboneX */ 0X0000, + /* mMinBackboneY */ 0xF000, + /* mMaxTurnStep */ 0x0400, + /* mCalcAngleTarget */ 0x0400, + /* mAttPosOffsetY */ 115.0f, + /* m18 */ 0.0f, + /* m1C. */ 500.0f, + /* m20 */ 300.0f, + }; + memcpy(&mPrmTbl, &a_prm_tbl, sizeof(hio_prm_c)); + mNo = -1; + field_0x8 = -1; } + +static daNpc_Ba1_HIO_c l_HIO; +static fopAc_ac_c* l_check_inf[20]; +static int l_check_wrk; + + /* 00000198-00000210 .text searchActor_Fa__FPvPv */ -void searchActor_Fa(void*, void*) { - /* Nonmatching */ +static void* searchActor_Fa(void* i_param_1, void *) { + if(l_check_wrk < 0x14 && fopAcM_IsActor(i_param_1) && fopAcM_GetName(i_param_1) == fpcNm_NPC_FA1_e){ + l_check_inf[l_check_wrk] =(fopAc_ac_c*)i_param_1; + l_check_wrk += 1; + } + return NULL; } /* 00000210-0000025C .text nodeCallBack_Ba1__FP7J3DNodei */ -static BOOL nodeCallBack_Ba1(J3DNode*, int) { - /* Nonmatching */ +static BOOL nodeCallBack_Ba1(J3DNode* i_param_1, int i_param_2) { + if(i_param_2 == 0){ + if(j3dSys.getModel()->getUserArea() != NULL){ + reinterpret_cast(j3dSys.getModel()->getUserArea())->nodeBa1Control(i_param_1,j3dSys.getModel()); + } + } + return TRUE; } /* 0000025C-000003AC .text nodeBa1Control__11daNpc_Ba1_cFP7J3DNodeP8J3DModel */ -void daNpc_Ba1_c::nodeBa1Control(J3DNode*, J3DModel*) { - /* Nonmatching */ +void daNpc_Ba1_c::nodeBa1Control(J3DNode* i_node, J3DModel* i_model) { + + static cXyz a_eye_pos_off(20.0f, -16.0f, 0.0f); + s32 jointIdx = ((J3DJoint*)(i_node))->getJntNo(); + mDoMtx_stack_c::copy(i_model->getAnmMtx(jointIdx)); + if(jointIdx == m_hed_jnt_num){ + mDoMtx_stack_c::YrotM(-m_jnt.getHead_y()); + mDoMtx_stack_c::ZrotM(-m_jnt.getHead_x()); + mDoMtx_stack_c::multVec(&a_eye_pos_off, &mTransformedEyePos); + } + if(jointIdx == m_bbone_jnt_num) { + mDoMtx_stack_c::XrotM(m_jnt.getBackbone_y()); + mDoMtx_stack_c::ZrotM(m_jnt.getBackbone_x()); + } + cMtx_copy(mDoMtx_stack_c::get(),j3dSys.mCurrentMtx); + i_model->setAnmMtx(jointIdx,mDoMtx_stack_c::get()); } /* 000003E8-00000408 .text daNpc_Ba1_XyCheck_cB__FPvi */ -void daNpc_Ba1_XyCheck_cB(void*, int) { - /* Nonmatching */ +static bool daNpc_Ba1_XyCheck_cB(void* i_this, int i_itemBtn) { + return static_cast(i_this)->XyCheck_cB(i_itemBtn); } /* 00000408-00000428 .text XyCheck_cB__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::XyCheck_cB(int) { - /* Nonmatching */ +bool daNpc_Ba1_c::XyCheck_cB(int i_itemBtn) { + if (dComIfGp_getSelectItem(i_itemBtn) == dItemNo_FAIRY_BOTTLE_e) { + return TRUE; + } + return FALSE; } /* 00000428-00000448 .text daNpc_Ba1_XyEvent_cB__FPvi */ -void daNpc_Ba1_XyEvent_cB(void*, int) { - /* Nonmatching */ +static s16 daNpc_Ba1_XyEvent_cB(void* i_this, int param_1) { + return static_cast(i_this)->XyEvent_cB(param_1); } /* 00000448-00000450 .text XyEvent_cB__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::XyEvent_cB(int) { - /* Nonmatching */ +s16 daNpc_Ba1_c::XyEvent_cB(int param_1) { + UNUSED(param_1); + return mEventIdTable[0]; } +static char* l_evn_tbl[] = { + "Use_Fairy", + "Ba1_Get_Itm", + "Ganbaru", + "tale_1", + "None", + "tale_2", +}; + /* 00000450-000004F8 .text init_BA1_0__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::init_BA1_0() { - /* Nonmatching */ +bool daNpc_Ba1_c::init_BA1_0() { + if(!dComIfGs_isEventBit(dSv_event_flag_c::UNK_0520) && !dComIfGs_isEventBit(dSv_event_flag_c::UNK_0001)) { + set_action(&daNpc_Ba1_c::wait_action1, NULL); + mpClothModel = 0; + return true; + } else { + return false; + } } /* 000004F8-000005F4 .text init_BA1_1__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::init_BA1_1() { - /* Nonmatching */ +bool daNpc_Ba1_c::init_BA1_1() { + bool ret = !dComIfGs_isEventBit(dSv_event_flag_c::UNK_0520); + if(!ret) { + return ret; + } + ret = dComIfGs_isEventBit(dSv_event_flag_c::UNK_0001); + if(ret) { + if(dComIfGs_checkCollect(1)) { + current.pos.set(-290.f, 0.f, 110.f); + current.angle.y = 0; + } + set_action(&daNpc_Ba1_c::wait_action2, NULL); + fopAcM_OffStatus(this, fopAcStts_NOCULLEXEC_e); + mpClothModel = 0; + } + + return ret; } /* 000005F4-00000648 .text init_BA1_2__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::init_BA1_2() { - /* Nonmatching */ +bool daNpc_Ba1_c::init_BA1_2() { + mpClothModel = 0; + set_action(&daNpc_Ba1_c::demo_action1, NULL); + return true; } /* 00000648-00000734 .text init_BA1_3__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::init_BA1_3() { - /* Nonmatching */ +bool daNpc_Ba1_c::init_BA1_3() { + bool ret = dComIfGs_isEventBit(dSv_event_flag_c::UNK_0520); + if(!ret) { + return ret; + } + ret = !dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED); + if(ret) { + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 0x1B; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0x1C; + fopAcM_OffStatus(this, fopAcStts_CULL_e | fopAcStts_NOCULLEXEC_e); + set_action(&daNpc_Ba1_c::wait_action3, NULL); + gravity = 0.f; + eventInfo.setXyCheckCB((dEvt_info_c::CallbackFunc)&daNpc_Ba1_XyCheck_cB); + eventInfo.setXyEventCB(&daNpc_Ba1_XyEvent_cB); + } + + return ret; } /* 00000734-000007E8 .text init_BA1_4__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::init_BA1_4() { - /* Nonmatching */ +bool daNpc_Ba1_c::init_BA1_4() { + bool ret = dComIfGs_isEventBit(dSv_event_flag_c::UNK_0520); + if(!ret) { + return ret; + } + ret = dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED); + if(ret) { + mpClothModel = 0; + set_action(&daNpc_Ba1_c::wait_action4, NULL); + } + + return ret; } /* 000007E8-000009DC .text createInit__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::createInit() { - /* Nonmatching */ +bool daNpc_Ba1_c::createInit() { + for(int i = 0; i < 6; i++){ + mEventIdTable[i] = dComIfGp_evmng_getEventIdx(l_evn_tbl[i]); + } + attention_info.flags = fopAc_Attn_LOCKON_TALK_e | fopAc_Attn_ACTION_SPEAK_e; + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 171; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 171; + gravity = -4.5; + m79C = current.pos; + mEventCut.setActorInfo2("Ba1", this); + mAnmNum = 10; + bool init_success; + switch (mSpecificType) { + case 0: + init_success = init_BA1_0(); + break; + case 1: + init_success = init_BA1_1(); + break; + case 2: + init_success = init_BA1_2(); + break; + case 3: + init_success = init_BA1_3(); + break; + case 4: + init_success = init_BA1_4(); + break; + default: + init_success = false; + break; + } + if (init_success) { + m78A = current.angle; + shape_angle = m78A; + } else { + return false; + } +#if VERSION > VERSION_JPN + m7F2 = dComIfGs_getEventReg(dSv_event_flag_c::UNK_A60F); +#endif + mStts.Init(0xFF,0xFF,this); + mCyl.SetStts(&mStts); + mCyl.Set(dNpc_cyl_src); + mpMorf->setMorf(0.0f); + setMtx(true); + return true; + } /* 000009DC-00000B44 .text setMtx__11daNpc_Ba1_cFb */ -void daNpc_Ba1_c::setMtx(bool) { - /* Nonmatching */ +void daNpc_Ba1_c::setMtx(bool param_1) { + if(!mbInDemo) { + plyTexPttrnAnm(); + mbMorfAnimStopped = mpMorf->play(&eyePos, 0, 0); + if(mpMorf->getFrame() < mPrevMorfFrame){ + mbMorfAnimStopped = true; + } + mPrevMorfFrame = mpMorf->getFrame(); + if (mSpecificType != 3) { + mObjAcch.CrrPos(*dComIfG_Bgsp()); + } + } + tevStr.mRoomNo = dComIfG_Bgsp()->GetRoomId(mObjAcch.m_gnd); + tevStr.mEnvrIdxOverride = dComIfG_Bgsp()->GetPolyColor(mObjAcch.m_gnd); + + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::YrotM(m78A.y); + + mpMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); + mpMorf->calc(); + + if (mpClothModel != NULL) { + mpClothModel->setBaseTRMtx(mpMorf->getModel()->getAnmMtx(m_footL_jnt_num)); + mpClothModel->calc(); + } + setAttention(param_1); } /* 00000B44-00000B58 .text anmNum_toResID__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::anmNum_toResID(int) { - /* Nonmatching */ +int daNpc_Ba1_c::anmNum_toResID(int param_1) { + static const int a_bck_resID_tbl[] = { + dRes_ID_BA_BCK_WAIT01_e, + dRes_ID_BA_BCK_TALK01_e, + dRes_ID_BA_BCK_TALK02_e, + dRes_ID_BA_BCK_TALK03_e, + dRes_ID_BA_BCK_HOLD_e, + dRes_ID_BA_BCK_WAIT02_e, + dRes_ID_BA_BCK_TALK04_e, + dRes_ID_BA_BCK_SLEEP_e, + dRes_ID_BA_BCK_05_BA_CUT8_WAIT_e, + dRes_ID_BA_BCK_GETUP_e, + }; + return a_bck_resID_tbl[param_1]; + } /* 00000B58-00000B6C .text btpNum_toResID__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::btpNum_toResID(int) { - /* Nonmatching */ +int daNpc_Ba1_c::btpNum_toResID(int param_1) { + static const int a_btp_resID_tbl[] = { + dRes_ID_BA_BTP_MABA01_e, + dRes_ID_BA_BTP_BA_T01_e, + dRes_ID_BA_BTP_BA_T02_e, + dRes_ID_BA_BTP_BA_T03_e, + dRes_ID_BA_BTP_BA_T04_e, + dRes_ID_BA_BTP_BA_T05_e, + dRes_ID_BA_BTP_BA_T06_e, + dRes_ID_BA_BTP_BA_T07_e, + dRes_ID_BA_BTP_BA_T08_e, + dRes_ID_BA_BTP_BA_T09_e, + dRes_ID_BA_BTP_BA_T10_e, + dRes_ID_BA_BTP_BA_WAKE_e, + }; + return a_btp_resID_tbl[param_1]; } /* 00000B6C-00000C7C .text setBtp__11daNpc_Ba1_cFbi */ -void daNpc_Ba1_c::setBtp(bool, int) { - /* Nonmatching */ +bool daNpc_Ba1_c::setBtp(bool i_param_1, int i_btp_num) { + J3DModelData* model_data = mpMorf->getModel()->getModelData(); + int res_id = btpNum_toResID(i_btp_num); + m_hed_tex_pttrn = reinterpret_cast(dComIfG_getObjectIDRes("Ba",res_id)); + JUT_ASSERT(VERSION_SELECT(567, 567, 569, 569), m_hed_tex_pttrn != NULL); + + int iVar1 = mHeadBtpAnm.init(model_data,m_hed_tex_pttrn,1,2,1.0f,0,-1,i_param_1,0); + bool o_retval = iVar1 == 1; + if(o_retval){ + mBlinkFrame = 0; + mBlinkTimer = 0; + } + return o_retval; } /* 00000C7C-00000CA4 .text iniTexPttrnAnm__11daNpc_Ba1_cFb */ -void daNpc_Ba1_c::iniTexPttrnAnm(bool) { - /* Nonmatching */ +bool daNpc_Ba1_c::iniTexPttrnAnm(bool i_param_1) { + return setBtp(i_param_1, mBtpNum); } /* 00000CA4-00000D50 .text plyTexPttrnAnm__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::plyTexPttrnAnm() { - /* Nonmatching */ + if(mBtpNum != 0 || !cLib_calcTimer(&mBlinkTimer)){ + mBlinkFrame += 1; + if(mBlinkFrame >= m_hed_tex_pttrn->getFrameMax()){ + if(mBtpNum != 0){ + mBlinkFrame = m_hed_tex_pttrn->getFrameMax(); + }else{ + mBlinkTimer = cM_rndF(60.0f) + 30.0f; + mBlinkFrame = 0; + } + } + } } /* 00000D50-00000D8C .text setAnm_tex__11daNpc_Ba1_cFSc */ -void daNpc_Ba1_c::setAnm_tex(signed char) { - /* Nonmatching */ +void daNpc_Ba1_c::setAnm_tex(s8 i_btp_num) { + if(mBtpNum != i_btp_num){ + mBtpNum = i_btp_num; + iniTexPttrnAnm(true); + } } /* 00000D8C-00000E34 .text setAnm_anm__11daNpc_Ba1_cFPQ211daNpc_Ba1_c9anm_prm_c */ -void daNpc_Ba1_c::setAnm_anm(daNpc_Ba1_c::anm_prm_c*) { - /* Nonmatching */ +BOOL daNpc_Ba1_c::setAnm_anm(daNpc_Ba1_c::anm_prm_c* i_anmPrmP) { + if(mAnmNum == i_anmPrmP->mAnmNum){ + return TRUE; + } + mAnmNum = i_anmPrmP->mAnmNum; + dNpc_setAnmIDRes( + mpMorf, + i_anmPrmP->mLoopMode, + i_anmPrmP->mMorf, + i_anmPrmP->mSpeed, + anmNum_toResID(mAnmNum), + -1, + "Ba" + ); + mPrevMorfFrame = 0; + m7EF = 0; + mbMorfAnimStopped = 0; + return TRUE; } /* 00000E34-00000EA0 .text setAnm_NUM__11daNpc_Ba1_cFii */ -void daNpc_Ba1_c::setAnm_NUM(int, int) { - /* Nonmatching */ +void daNpc_Ba1_c::setAnm_NUM(int i_param_1, int i_param_2) { + static anm_prm_c a_anm_prm_tbl[11] = { + {0, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {1, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {2, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {3, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {4, 0, 0, 8, 1, J3DFrameCtrl::EMode_NONE}, + {5, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {6, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {7, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {8, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {9, 0xB, 0, 8, 1, J3DFrameCtrl::EMode_NONE}, + {0, 9, 0, 0, 1, J3DFrameCtrl::EMode_LOOP}, + }; + if(i_param_2 != 0){ + setAnm_tex(a_anm_prm_tbl[i_param_1].mBtpNum); + } + setAnm_anm(&a_anm_prm_tbl[i_param_1]); } /* 00000EA0-00000F20 .text setAnm__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::setAnm() { - /* Nonmatching */ +bool daNpc_Ba1_c::setAnm() { + static anm_prm_c a_anm_prm_tbl[8] = { + {-1, -1, 0, 0, 0, -1}, + {0, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {-1, -1, 0, 0, 0, -1}, + {0, 2, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {7, 7, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {-1, -1, 0, 0, 0, -1}, + {0, 9, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {0, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + }; + if(a_anm_prm_tbl[mStatus].mBtpNum >= 0){ + setAnm_tex(a_anm_prm_tbl[mStatus].mBtpNum); + } + if(a_anm_prm_tbl[mStatus].mAnmNum >= 0){ + setAnm_anm(&a_anm_prm_tbl[mStatus]); + } + return true; } /* 00000F20-00000F24 .text chg_anmTag__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::chg_anmTag() { - /* Nonmatching */ -} +void daNpc_Ba1_c::chg_anmTag() {} /* 00000F24-00000F28 .text control_anmTag__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::control_anmTag() { - /* Nonmatching */ -} +void daNpc_Ba1_c::control_anmTag() {} /* 00000F28-00000F6C .text chg_anmAtr__11daNpc_Ba1_cFUc */ -void daNpc_Ba1_c::chg_anmAtr(unsigned char) { - /* Nonmatching */ +void daNpc_Ba1_c::chg_anmAtr(u8 i_param_1) { + if ((i_param_1 >= 0x15) || (i_param_1 == m80E)) { + return; + } + m80E = i_param_1; + setAnm_ATR(1); } /* 00000F6C-00000FA4 .text control_anmAtr__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::control_anmAtr() { - /* Nonmatching */ + switch(m80E) { + case 5: + case 6: + switch (mLookBackState) { + case 1: + break; + default: + mLookBackState = 1; + m_jnt.setTrn(); + break; + } + break; + case 7: + case 8: + default: + return; + } } /* 00000FA4-0000100C .text setAnm_ATR__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::setAnm_ATR(int) { - /* Nonmatching */ +void daNpc_Ba1_c::setAnm_ATR(int i_param_1) { + static anm_prm_c a_anm_prm_tbl[21] = { + {0, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {1, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {2, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {3, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {0, 1, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {2, 2, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {1, 3, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {3, 2, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {2, 3, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {2,4, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {2, 6, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {3, 5, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {3, 6, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {7, 7, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {6, 8, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {6, 1, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {5, 0XA, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {5, 1, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {5, 9, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {5, 0, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + {0, 8, 0, 8, 1, J3DFrameCtrl::EMode_LOOP}, + }; + if (i_param_1 != 0) { + setAnm_tex(a_anm_prm_tbl[m80E].mBtpNum); + } + setAnm_anm(&a_anm_prm_tbl[m80E]); + } /* 0000100C-000010D0 .text anmAtr__11daNpc_Ba1_cFUs */ -void daNpc_Ba1_c::anmAtr(unsigned short) { - /* Nonmatching */ +void daNpc_Ba1_c::anmAtr(u16 i_param_1) { + u32 mesgAnimeTagInfo; + switch(i_param_1) { + case 6: + if (m819 == 0) { + m80E = 0xFF; + chg_anmAtr(dComIfGp_getMesgAnimeAttrInfo()); + m819++; + } + mesgAnimeTagInfo = dComIfGp_getMesgAnimeTagInfo(); + dComIfGp_clearMesgAnimeTagInfo(); + if(mesgAnimeTagInfo != 0xFF && mMesgAnimeTagInfo != mesgAnimeTagInfo){ + mMesgAnimeTagInfo = mesgAnimeTagInfo; + chg_anmTag(); + } + break; + case 0xE: + m819 = 0; + break; + default: + break; + } + control_anmTag(); + control_anmAtr(); } /* 000010D0-000011A0 .text eventOrder__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::eventOrder() { - /* Nonmatching */ + s8 condition = m812; + if(condition == 1 || condition == 2){ + eventInfo.onCondition(dEvtCnd_CANTALK_e); + if(mSpecificType == 3 && !dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED)){ + eventInfo.onCondition(dEvtCnd_CANTALKITEM_e); + } + if(m812 == 1){ + fopAcM_orderSpeakEvent(this); + } + }else if(condition >= 3){ + mEventIdx = condition - 3; + fopAcM_orderOtherEventId(this,mEventIdTable[mEventIdx]); + } } /* 000011A0-0000123C .text checkOrder__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::checkOrder() { - /* Nonmatching */ + if(eventInfo.checkCommandDemoAccrpt()){ + if(dComIfGp_evmng_startCheck(mEventIdTable[mEventIdx])){ + m812 = 0; + } + }else if(checkCommandTalk() && (m812 == 1 || m812 == 2)){ + m812 = 0; + m809 = true; + } } /* 0000123C-000012E8 .text chk_talk__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::chk_talk() { - /* Nonmatching */ +bool daNpc_Ba1_c::chk_talk() { + bool ret = true; + mItemNo = 0xFF; + if(dComIfGp_event_chkTalkXY()){ + if(dComIfGp_evmng_ChkPresentEnd()){ + mItemNo = dComIfGp_event_getPreItemNo(); + + } else { + ret = false; + } + mItemNo = dComIfGp_event_getPreItemNo(); + + } + + return ret; } /* 000012E8-0000137C .text chk_drct__11daNpc_Ba1_cFf */ -void daNpc_Ba1_c::chk_drct(float) { - /* Nonmatching */ +bool daNpc_Ba1_c::chk_drct(f32 i_param_1) { + s16 target = cLib_targetAngleY( + ¤t.pos, + &dComIfGp_getPlayer(0)->current.pos + ) - current.angle.y; + int cmp = abs(target); + return cmp < cM_deg2s(i_param_1); } /* 0000137C-000013BC .text chk_partsNotMove__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::chk_partsNotMove() { - /* Nonmatching */ +bool daNpc_Ba1_c::chk_partsNotMove() { + return mJointHeadY == m_jnt.getHead_y() && + mJointBackboneY == m_jnt.getBackbone_y() && + mActorAngleY == current.angle.y; } /* 000013BC-0000155C .text lookBack__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::lookBack() { - /* Nonmatching */ + cXyz dstPos; + cXyz* dstPos_p; + cXyz src_pos; + s16 desiredYrot; + mJointHeadY = m_jnt.getHead_y(); + mJointBackboneY = m_jnt.getBackbone_y(); + mActorAngleY = current.angle.y; + src_pos.x = current.pos.x; + src_pos.y = current.pos.y; + src_pos.z = current.pos.z; + src_pos.y = eyePos.y; + dstPos.set(0.0f,0.0f,0.0f); + dstPos_p = NULL; + desiredYrot = current.angle.y; + bool headOnlyFollow = mHeadOnlyFollow; + + switch(mLookBackState){ + case 1: + dstPos = dNpc_playerEyePos(-20.0f); + dstPos_p = &dstPos; + src_pos.x = current.pos.x; + src_pos.y = current.pos.y; + src_pos.z = current.pos.z; + src_pos.y = eyePos.y; + break; + case 2: + dstPos.set(m79C); + dstPos_p = &dstPos; + src_pos.x = current.pos.x; + src_pos.y = current.pos.y; + src_pos.z = current.pos.z; + src_pos.y = eyePos.y; + break; + case 3: + desiredYrot = mTargetYRot; + break; + } + cLib_addCalcAngleS2(&mLookAtMaxVel,l_HIO.mPrmTbl.mCalcAngleTarget,4,0x800); + if(!m_jnt.trnChk()){ + mLookAtMaxVel = 0; + } + m_jnt.lookAtTarget(¤t.angle.y,dstPos_p,src_pos,desiredYrot,mLookAtMaxVel,headOnlyFollow); } /* 0000155C-000016C8 .text next_msgStatus__11daNpc_Ba1_cFPUl */ -void daNpc_Ba1_c::next_msgStatus(unsigned long*) { - /* Nonmatching */ +u16 daNpc_Ba1_c::next_msgStatus(u32* i_msg_no) { + u16 ret = 0xF; + switch(*i_msg_no) { + case 0x7EB: + *i_msg_no = 0x7EC; + break; + case 0x7EF: + *i_msg_no = 0x7F0; + break; + case 0x7F3: + *i_msg_no = 0x7F4; + break; + case 0x7F4: + neverGotSoup: + if(dComIfGs_checkEmptyBottle()) { + *i_msg_no = 0x7F5; + } else { + *i_msg_no = 0x7F9; + } + break; + case 0x7F6: + *i_msg_no = 0x7F7; + break; + case 0x7FB: + case 0x7FC: + case 0x7FD: + case 0x7FA: + if(dComIfGs_isGetBottleItem(dItemNo_SOUP_BOTTLE_e)) { + if(!dComIfGs_checkEmptyBottle()) { + *i_msg_no = 0x803; + } + else if(dComIfGs_checkBottle(dItemNo_SOUP_BOTTLE_e)) { + *i_msg_no = 0x7FE; + } else { + *i_msg_no = 0x7FF; + } + break; + } + goto neverGotSoup; + case 0x7FF: + switch(mpCurrMsg->mSelectNum) { + case 0: + *i_msg_no = 0x800; + break; + case 1: + *i_msg_no = 0x802; + break; + } + break; + default: + ret = 0x10; + break; + } + return ret; } /* 000016C8-00001738 .text getMsg_BA1_0__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::getMsg_BA1_0() { - /* Nonmatching */ +u32 daNpc_Ba1_c::getMsg_BA1_0() { + if (m7FA) { + return 0x7d8; + } + if (mbHoldEvent) { + return dComIfGs_isEventBit(dSv_event_flag_c::UNK_0608) ? 0x7e7 : 0x7e6; + } + return m7FB ? 0x7e5 : 0x7e4; } /* 00001738-00001818 .text getMsg_BA1_1__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::getMsg_BA1_1() { - /* Nonmatching */ +u32 daNpc_Ba1_c::getMsg_BA1_1() { + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_0E20)) { + if (dComIfGs_checkCollect(1)) { + return 0x80b; + } + return dComIfGs_isEventBit(dSv_event_flag_c::UNK_0740) ? 0x7ee : 0x7ef; + + } + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_0780)) { + return 0x7ed; + } + if (dComIfGs_checkCollect(0)) { + return dComIfGs_isEventBit(dSv_event_flag_c::UNK_0602) ? 0x7ea : 0x7eb; + } + return dComIfGs_isEventBit(dSv_event_flag_c::UNK_0601) ? 0x7e9 : 0x7e8; + } /* 00001818-00001908 .text getMsg_BA1_3__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::getMsg_BA1_3() { - /* Nonmatching */ +u32 daNpc_Ba1_c::getMsg_BA1_3() { + if (m7F0) { + if (dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED)) { + return 0x801; + } + return 0x7f6; + } + + if (dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED)) { + +#if VERSION > VERSION_JPN + dComIfGs_setEventReg(dSv_event_flag_c::UNK_A60F, 0); + if(m7F2 >= 3) +#else + if(dComIfGs_getEventReg(dSv_event_flag_c::UNK_A60F) >= 3) +#endif + { + if (m7FA) { + return 0x7fd; + } + m7FA = true; + return 0x7fc; + } + if (m7FA) { + return 0x7fa; + } + m7FA = true; + return 0x7fb; + } + return 0x7f1; } /* 00001908-00001928 .text getMsg_BA1_4__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::getMsg_BA1_4() { - /* Nonmatching */ +u32 daNpc_Ba1_c::getMsg_BA1_4() { + return getMsg_BA1_3(); } /* 00001928-000019AC .text getMsg__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::getMsg() { - /* Nonmatching */ +u32 daNpc_Ba1_c::getMsg() { + u32 ret = 0; + switch ((mSpecificType)) { + case 0: + ret = getMsg_BA1_0(); + break; + case 1: + ret = getMsg_BA1_1(); + break; + case 3: + ret = getMsg_BA1_3(); + break; + case 4: + ret = getMsg_BA1_4(); + break; + } + return ret; } /* 000019AC-00001A2C .text chkAttention__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::chkAttention() { - /* Nonmatching */ +bool daNpc_Ba1_c::chkAttention() { + dAttention_c& attention = dComIfGp_getAttention(); + if (attention.LockonTruth()) { + return this == attention.LockonTarget(0); + } + return this == attention.ActionTarget(0); } /* 00001A2C-00001A94 .text setAttention__11daNpc_Ba1_cFb */ -void daNpc_Ba1_c::setAttention(bool) { - /* Nonmatching */ +void daNpc_Ba1_c::setAttention(bool i_setEyePos) { + + f32 offset = l_HIO.mPrmTbl.mAttPosOffsetY; + attention_info.position.set( + current.pos.x, + current.pos.y + offset, + current.pos.z + ); + + + if (!mbSetEyePos && !i_setEyePos) { + return; + } + + eyePos.set( + mTransformedEyePos.x, + mTransformedEyePos.y, + mTransformedEyePos.z + ); + eyePos.y += mEyeOffset; } /* 00001A94-00001AC8 .text searchByID__11daNpc_Ba1_cFUi */ -void daNpc_Ba1_c::searchByID(fpc_ProcID) { - /* Nonmatching */ +fopAc_ac_c* daNpc_Ba1_c::searchByID(fpc_ProcID i_procID) { + fopAc_ac_c* o_actor = NULL; + fopAcM_SearchByID(i_procID,&o_actor); + return o_actor; } /* 00001AC8-00001B78 .text partner_srch_sub__11daNpc_Ba1_cFPFPvPv_Pv */ -void daNpc_Ba1_c::partner_srch_sub(void* (*)(void*, void*)) { - /* Nonmatching */ +bool daNpc_Ba1_c::partner_srch_sub(fpcLyIt_JudgeFunc i_searchFunc) { + bool o_retval = false; + mPartnerProcID = -1; + l_check_wrk = 0; + for(int i = 0; i < 20; i++){ + l_check_inf[i] = 0; + } + fpcM_Search(i_searchFunc,this); + if(l_check_wrk != 0){ + mPartnerProcID = fopAcM_GetID(l_check_inf[0]); + o_retval = true; + } + return o_retval; } /* 00001B78-00001B90 .text partner_srch__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::partner_srch() { - /* Nonmatching */ + if (m818 == 1) { +#if VERSION == VERSION_DEMO + bool found_partner = 1; + if(found_partner) { + m818++; + } +#else + m818++; +#endif + } } /* 00001B90-00001CA8 .text check_useFairyArea__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::check_useFairyArea() { - /* Nonmatching */ +bool daNpc_Ba1_c::check_useFairyArea() { + bool ret; + f32 mag = std::sqrtf((dComIfGp_getPlayer(0)->current.pos - current.pos).abs2XZ()); + ret = FALSE; + if ( + std::abs(dComIfGp_getPlayer(0)->current.pos.y - current.pos.y) < 100.0f + && mag < l_HIO.mPrmTbl.m1C + ) { + ret = TRUE; + } + return ret; } /* 00001CA8-00001CF8 .text checkCommandTalk__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::checkCommandTalk() { - /* Nonmatching */ +bool daNpc_Ba1_c::checkCommandTalk() { + bool ret; + ret = false; + + if (eventInfo.checkCommandTalk()) { + ret = dComIfGp_event_chkTalkXY() == 0; + } + return ret; } /* 00001CF8-00001D7C .text charDecide__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::charDecide(int) { - /* Nonmatching */ +bool daNpc_Ba1_c::charDecide(int i_param_1) { + mType = 0; + mSpecificType = -1; + switch (i_param_1) { + case 0: + mSpecificType = 0; + break; + case 1: + mSpecificType = 1; + break; + case 2: + mSpecificType = 2; + break; + case 3: + mSpecificType = 3; + break; + case 4: + mSpecificType = 4; + break; + default: + return false; + } + return true; } /* 00001D7C-00001E10 .text eInit_SET_PLYER_GOL___11daNpc_Ba1_cFv */ void daNpc_Ba1_c::eInit_SET_PLYER_GOL_() { - /* Nonmatching */ + cXyz tmp, target; + tmp.set(0, 0, 50); + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::YrotM(current.angle.y); + mDoMtx_stack_c::multVec(&tmp, &target); + dComIfGp_evmng_setGoal(&target); } /* 00001E10-00001ECC .text eInit_PLYER_INI_POS___11daNpc_Ba1_cFv */ void daNpc_Ba1_c::eInit_PLYER_INI_POS_() { - /* Nonmatching */ + daPy_py_c* player = daPy_getPlayerActorClass(); + cXyz tmp, target; + tmp.set(0, 0, 180); + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::YrotM(current.angle.y); + mDoMtx_stack_c::multVec(&tmp, &target); + player->setPlayerPosAndAngle( + &target, + cLib_targetAngleY(&target, ¤t.pos) + ); } /* 00001ECC-00001EE8 .text eInit_USE_FAIRY_END___11daNpc_Ba1_cFv */ void daNpc_Ba1_c::eInit_USE_FAIRY_END_() { - /* Nonmatching */ + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 0x5B; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0x59; + mFairyUsed = true; + } /* 00001EE8-00001F04 .text eInit_MOV_POS___11daNpc_Ba1_cFv */ void daNpc_Ba1_c::eInit_MOV_POS_() { - /* Nonmatching */ + m7F5 = true; + mpClothModel = NULL; + m7F7 = true; + m7FE = true; } /* 00001F04-00001F48 .text eInit_SET_PLYER_TRN_ANG___11daNpc_Ba1_cFv */ void daNpc_Ba1_c::eInit_SET_PLYER_TRN_ANG_() { - /* Nonmatching */ -} + daPy_py_c* player = daPy_getPlayerActorClass(); + player->mDemo.setMoveAngle( + cLib_targetAngleY( + &dComIfGp_getPlayer(0)->current.pos, + ¤t.pos) + ); + } /* 00001F48-000020AC .text eInit_ACTOR_DRW_CONTROL___11daNpc_Ba1_cFPiPi */ -void daNpc_Ba1_c::eInit_ACTOR_DRW_CONTROL_(int*, int*) { - /* Nonmatching */ +void daNpc_Ba1_c::eInit_ACTOR_DRW_CONTROL_(int* i_param_1, int* i_param_2) { + if(i_param_1 != NULL) { + daPy_py_c* player = daPy_getPlayerActorClass(); + switch (*i_param_1) { + case 0: + player->onNoResetFlg0(daPy_py_c::daPyFlg0_NO_DRAW); + break; + case 1: + player->offNoResetFlg0(daPy_py_c::daPyFlg0_NO_DRAW); + break; + } + + } + if(i_param_2 != NULL) { + cXyz tmp; + switch (*i_param_2) { + case 0: + m7F7 = 1; + break; + case 1: + m7F7 = 0; + break; + case 2: + setAnm_NUM( 10, 1); + m7F7 = 1; + return; + case 3: + current.angle.y = cLib_targetAngleY(¤t.pos, &dComIfGp_getPlayer(0)->current.pos); + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 0xAB; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0xAB; + tmp.set(0, 0, 90); + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::YrotM(current.angle.y); + mDoMtx_stack_c::multVec(&tmp, ¤t.pos); + m7F7 = 0; + break; + } + } } /* 000020AC-000020C8 .text eInit_setEvTimer__11daNpc_Ba1_cFPi */ -void daNpc_Ba1_c::eInit_setEvTimer(int*) { - /* Nonmatching */ +void daNpc_Ba1_c::eInit_setEvTimer(int* i_param_1) { + mEvTimer = 0; + if (i_param_1 != NULL) { + mEvTimer = *i_param_1; + } } /* 000020C8-000020E8 .text eInit_CHK_FAIRY___11daNpc_Ba1_cFPi */ -void daNpc_Ba1_c::eInit_CHK_FAIRY_(int*) { - /* Nonmatching */ +void daNpc_Ba1_c::eInit_CHK_FAIRY_(int* i_param_1) { + eInit_setEvTimer(i_param_1); } /* 000020E8-000020F8 .text eInit_prmFloat__11daNpc_Ba1_cFPff */ -void daNpc_Ba1_c::eInit_prmFloat(float*, float) { - /* Nonmatching */ +f32 daNpc_Ba1_c::eInit_prmFloat(f32* i_param_1, f32 i_param_2) { + if (i_param_1 != NULL) { + return *i_param_1; + } + return i_param_2; } /* 000020F8-00002130 .text eInit_SET_EYE_OFF___11daNpc_Ba1_cFPf */ -void daNpc_Ba1_c::eInit_SET_EYE_OFF_(float*) { - /* Nonmatching */ +void daNpc_Ba1_c::eInit_SET_EYE_OFF_(f32* i_param_1) { + mEyeOffset = eInit_prmFloat(i_param_1, 0.0f); } /* 00002130-00002168 .text eInit_EYE_OFF_ZRO___11daNpc_Ba1_cFPf */ -void daNpc_Ba1_c::eInit_EYE_OFF_ZRO_(float*) { - /* Nonmatching */ +void daNpc_Ba1_c::eInit_EYE_OFF_ZRO_(f32* i_param_1) { + mEyeOffsetZero = eInit_prmFloat(i_param_1, 0.0f); } /* 00002168-00002188 .text eInit_CHK_FAIRY_MOV_1__11daNpc_Ba1_cFPi */ -void daNpc_Ba1_c::eInit_CHK_FAIRY_MOV_1(int*) { - /* Nonmatching */ +void daNpc_Ba1_c::eInit_CHK_FAIRY_MOV_1(int* i_param_1) { + eInit_setEvTimer(i_param_1); } /* 00002188-00002358 .text event_actionInit__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::event_actionInit(int) { - /* Nonmatching */ +void daNpc_Ba1_c::event_actionInit(int i_staff_idx) { + int *act_no_p; + int *prm_0_p; + int *prm_1_p; + int *timer_p; + f32 *atten_p; + f32 *speed_p; + act_no_p = dComIfGp_evmng_getMyIntegerP(i_staff_idx,"ActNo"); + prm_0_p = dComIfGp_evmng_getMyIntegerP(i_staff_idx,"prm_0"); + prm_1_p = dComIfGp_evmng_getMyIntegerP(i_staff_idx,"prm_1"); + timer_p = dComIfGp_evmng_getMyIntegerP(i_staff_idx,"Timer"); + atten_p = dComIfGp_evmng_getMyFloatP(i_staff_idx,"Atten"); + speed_p = dComIfGp_evmng_getMyFloatP(i_staff_idx,"Speed"); + if (act_no_p != NULL) { + mActNo = *act_no_p; + switch (mActNo) { + case 0: + setAnm_NUM(9, 1); + break; + case 1: + eInit_SET_PLYER_GOL_(); + break; + case 2: + eInit_PLYER_INI_POS_(); + break; + case 3: + eInit_USE_FAIRY_END_(); + break; + case 4: + eInit_MOV_POS_(); + break; + case 5: + eInit_SET_PLYER_TRN_ANG_(); + break; + case 6: + eInit_ACTOR_DRW_CONTROL_(prm_0_p,prm_1_p); + break; + case 7: + eInit_CHK_FAIRY_(timer_p); + break; + case 8: + eInit_SET_EYE_OFF_(atten_p); + break; + case 9: + eInit_EYE_OFF_ZRO_(speed_p); + break; + case 10: + eInit_CHK_FAIRY_MOV_1(timer_p); + break; + } + } } /* 00002358-00002518 .text eMove_MOV_POS___11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::eMove_MOV_POS_() { - /* Nonmatching */ +bool daNpc_Ba1_c::eMove_MOV_POS_() { + bool ret; + cXyz temp; + + temp.set(503, 0, -91); + if(cLib_calcTimer(&mEvTimer)) { + return FALSE; + } + if((int)mEyeOffset != 0) { + cLib_chaseF(&mEyeOffset, 0.0f, 2.0f); + return FALSE; + + } + f32 mag = std::sqrtf((temp - current.pos).abs2XZ()); + ret = mag < 4.0f; + m78A.y = cLib_targetAngleY(¤t.pos, &dComIfGp_getPlayer(0)->current.pos); + m7F5 = true; + if(ret != 0) { + current.angle.y = m78A.y; + m7F5 = false; + speedF = 0.0; + mEyeOffset = 0.0; + } else { + cLib_addCalcAngleS( + ¤t.angle.y, + cLib_targetAngleY(¤t.pos, &temp), + 4, + 0x400, + 0 + ); + cLib_chaseF(&speedF, 4.0f, 0.4f); + } + return ret; } /* 00002518-00002574 .text eMove_CHK_FAIRY___11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::eMove_CHK_FAIRY_() { - /* Nonmatching */ +bool daNpc_Ba1_c::eMove_CHK_FAIRY_() { + if(cLib_calcTimer(&mEvTimer) == 0) { + return !partner_srch_sub(searchActor_Fa); + } + return false; } /* 00002574-00002608 .text eMove_EYE_OFF_ZRO___11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::eMove_EYE_OFF_ZRO_() { - /* Nonmatching */ +bool daNpc_Ba1_c::eMove_EYE_OFF_ZRO_() { + bool ret; + + ret = (int) mEyeOffsetZero == 0; + + if (ret) { + mEyeOffset = 0.0; + } else { + cLib_chaseF(&mEyeOffset,0.0,mEyeOffsetZero); + ret = (int) mEyeOffset == 0; + if (ret) { + mEyeOffset = 0.0; + } + } + return ret; } /* 00002608-0000269C .text eMove_CHK_FAIRY_MOV_1__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::eMove_CHK_FAIRY_MOV_1() { - /* Nonmatching */ +bool daNpc_Ba1_c::eMove_CHK_FAIRY_MOV_1() { + bool ret = false; + if(!cLib_calcTimer(&mEvTimer)) { + if(partner_srch_sub(searchActor_Fa)) { + daNpc_Fa1_c * actor_fa; + actor_fa = (daNpc_Fa1_c*) searchByID(mPartnerProcID); + if(actor_fa != NULL) { + ret = actor_fa->isBabaMode() ? true : false; + } + } + } + if(ret) { + eInit_PLYER_INI_POS_(); + } + return ret; } /* 0000269C-00002704 .text event_action__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::event_action() { - /* Nonmatching */ +bool daNpc_Ba1_c::event_action() { + bool ret; + switch(mActNo) { + case 4: + ret = eMove_MOV_POS_(); + break; + case 7: + ret = eMove_CHK_FAIRY_(); + break; + case 9: + ret = eMove_EYE_OFF_ZRO_(); + break; + case 10: + ret = eMove_CHK_FAIRY_MOV_1(); + break; + case 1: + case 2: + case 3: + case 5: + case 6: + case 8: + case 0: + default: + ret = true; + break; + } + return ret; } /* 00002704-00002764 .text cut_init_START_TALE1__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::cut_init_START_TALE1(int) { - /* Nonmatching */ +void daNpc_Ba1_c::cut_init_START_TALE1(int i_staff_idx) { + int *timer_p; + timer_p = dComIfGp_evmng_getMyIntegerP(i_staff_idx,"Timer"); + mEvTimer = 0; + if(timer_p != NULL) { + mEvTimer = *timer_p; + } } /* 00002764-00002820 .text cut_move_START_TALE1__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::cut_move_START_TALE1() { - /* Nonmatching */ +bool daNpc_Ba1_c::cut_move_START_TALE1() { + if(cLib_calcTimer(&mEvTimer) == 0) { + if(dComIfGs_getClearCount() != 0) { + dComIfGp_setNextStage( + "LinkRM", + 202, + 0, + 8, + 0.0, + 0, + 1, + 0 + ); + } else { + dComIfGp_setNextStage( + "LinkRM", + 200, + 0, + 8, + 0.0, + 0, + 1, + 0 + ); + + } + } + return mEvTimer == 0; } /* 00002820-00002948 .text privateCut__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::privateCut(int) { - /* Nonmatching */ +void daNpc_Ba1_c::privateCut(int i_staff_idx) { + static char* a_cut_tbl[] = { + "ACTION", + "START_TALE1", + }; + enum { + ACT_ACTION, + ACT_START_TALE1, + }; + + if(i_staff_idx == -1) { + return; + } + + mActionIndex = dComIfGp_evmng_getMyActIdx(i_staff_idx,a_cut_tbl,ARRAY_SIZE(a_cut_tbl),TRUE,0); + if (mActionIndex == -1) { + dComIfGp_evmng_cutEnd(i_staff_idx); + } else { + if (dComIfGp_evmng_getIsAddvance(i_staff_idx)) { + switch(mActionIndex){ + case ACT_ACTION: + event_actionInit(i_staff_idx); + break; + case ACT_START_TALE1: + cut_init_START_TALE1(i_staff_idx); + break; + } + } + bool endCut; + switch (mActionIndex) { + case ACT_ACTION: + endCut = event_action(); + break; + case ACT_START_TALE1: + endCut = cut_move_START_TALE1(); + break; + default: + endCut = true; + break; + } + if(endCut) { + dComIfGp_evmng_cutEnd(i_staff_idx); + } + } } /* 00002948-00002968 .text endEvent__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::endEvent() { - /* Nonmatching */ + dComIfGp_event_reset(); + m80E = 0xFF; } /* 00002968-000029A0 .text isEventEntry__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::isEventEntry() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::isEventEntry() { + return dComIfGp_evmng_getMyStaffId(mEventCut.getActorName(),NULL); + } /* 000029A0-00002B50 .text event_proc__11daNpc_Ba1_cFi */ -void daNpc_Ba1_c::event_proc(int) { - /* Nonmatching */ +void daNpc_Ba1_c::event_proc(int i_staff_idx) { + if (dComIfGp_evmng_endCheck(mEventIdTable[mEventIdx])) { + switch(mEventIdx){ + case 0: + break; + case 1: + if(dComIfGs_checkBottle(dItemNo_HALF_SOUP_BOTTLE_e)) { + dComIfGs_setBottleItemIn(dItemNo_HALF_SOUP_BOTTLE_e, dItemNo_SOUP_BOTTLE_e); + } else { + dComIfGs_setEmptyBottleItemIn(dItemNo_SOUP_BOTTLE_e); + } + if(dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED)) { + m812 = 1; + m7F0 = 1; + } else { + m812 = 5; + } + break; + case 2: + dLetter_send(0x9D03); + dComIfGs_onEventBit(dSv_event_flag_c::GRANDMA_HEALED); + set_action(&daNpc_Ba1_c::wait_action4, NULL); + mInitialPos = current.pos; + mInitialAngle = current.angle; + m7FE = 0; + break; + case 3: + break; + } + endEvent(); + return; + } + else { + if (!mEventCut.cutProc()) { + privateCut(i_staff_idx); + } + lookBack(); + } } /* 00002B50-00002BFC .text set_action__11daNpc_Ba1_cFM11daNpc_Ba1_cFPCvPvPv_iPv */ -void daNpc_Ba1_c::set_action(int (daNpc_Ba1_c::*)(void*), void*) { - /* Nonmatching */ +BOOL daNpc_Ba1_c::set_action(ProcFunc i_newProcFunc, void* i_argsP) { + if (mCurrProcFunc != i_newProcFunc) { + if (mCurrProcFunc) { + m818 = 9; + (this->*mCurrProcFunc)(i_argsP); + } + mCurrProcFunc = i_newProcFunc; + m818 = 0; + (this->*mCurrProcFunc)(i_argsP); + } + return TRUE; } /* 00002BFC-00002CA8 .text setStt__11daNpc_Ba1_cFSc */ -void daNpc_Ba1_c::setStt(signed char) { - /* Nonmatching */ +void daNpc_Ba1_c::setStt(s8 i_status) { + s8 temp = mStatus; + mEvTimer2 = 0; + mStatus = i_status; + switch(mStatus) { + case 2: +#if VERSION <= VERSION_JPN + dComIfGs_setEventReg(dSv_event_flag_c::UNK_A60F, 0); +#endif + m80E = 0xFF; + if(mAnmNum != 4) { + mLookBackState = 1; + m_jnt.setTrn(); + } + mPrevStatus = temp; + return; + case 0: + break; + case 5: + m80E = 0xFF; + mPrevStatus = temp; + return; + case 1: + case 3: + case 4: + case 6: + case 7: + mHeadOnlyFollow = true; + break; + } + + setAnm(); + } /* 00002CA8-00002E30 .text wait_0__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::wait_0() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::wait_0() { + cLib_addCalcAngleS( + ¤t.angle.y, + mInitialAngle.y, + 4, + 0x800, + 0 + ); + if(m812 == 1 || m812 >= 3) { + return TRUE; + } + m812 = 0; + if(!dComIfGs_isTmpBit(dSv_event_flag_c::UNK_0310)) { + f32 dist = std::sqrtf((dComIfGp_getPlayer(0)->current.pos - current.pos).abs2XZ()); + if( + std::fabsf(dComIfGp_getPlayer(0)->current.pos.y - current.pos.y) < 100.0f + && dist < l_HIO.mPrmTbl.m20 + ) { + dComIfGs_onTmpBit(dSv_event_flag_c::UNK_0310); + m812 = 6; + } + } + return TRUE; } /* 00002E30-00002F70 .text wait_1__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::wait_1() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::wait_1() { + cLib_addCalcAngleS( + ¤t.angle.y, + mInitialAngle.y, + 4, + 0x800, + 0 + ); + if(m812 == 1 || m812 >= 3) { + return TRUE; + } + if (m809) { + if (chk_talk()) { + setStt(2); + mHeadOnlyFollow = false; + } + return TRUE; + } + else if (mbHoldEvent) { + setAnm_NUM(4,1); + m812 = 1; + mLookBackState = 0; + mTargetYRot = current.angle.y + -0x638e; + } + else { + m812 = 2; + if (mbAttention != 0) { + mEvTimer2 = 60; + } + if (cLib_calcTimer(&mEvTimer2) && chk_drct(61.0)) { + mLookBackState = 1; + } + else { + mLookBackState = 3; + mTargetYRot = (mInitialAngle).y; + m_jnt.setTrn(); + } + } + + return TRUE; } /* 00002F70-00003110 .text talk_1__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::talk_1() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::talk_1() { + u8 ret; + + ret = chk_partsNotMove(); + if (mAnmNum == 4) { + cLib_addCalcAngleS( + ¤t.angle.y, + mTargetYRot, + 2, + 0x1000, + 1); + if(!mbMorfAnimStopped) { + return TRUE; + } + } + talk(1); + if (mpCurrMsg != NULL) { + switch(mpCurrMsg->mStatus) { + case fopMsgStts_MSG_TYPING_e: + case fopMsgStts_BOX_OPENING_e: + break; + case fopMsgStts_MSG_DESTROYED_e: + switch (mCurrMsgNo) { + case 0x7e4: + m7FB = true; + break; + case 0x7e6: + // Unused + dComIfGs_onEventBit(dSv_event_flag_c::UNK_0608); + break; + case 0x7e8: + // After Helmaroc cutscene (prologue) + dComIfGs_onEventBit(dSv_event_flag_c::UNK_0601); + break; + case 0x7ec: + // Sword got + dComIfGs_onEventBit(dSv_event_flag_c::UNK_0602); + break; + case 0x7f0: + // Aryll kidnapped + dComIfGs_onEventBit(dSv_event_flag_c::UNK_0740); + break; + case 0x800: + if (mCurrMsgNo != 0x7f9) { + m812 = 4; + } + mFairyUsed = false; + break; + case 0x801: + m7F0 = 0; + break; + } + mItemNo = 0xff; + m809 = false; + setStt(mPrevStatus); + mEvTimer2 = 60; + endEvent(); + mbHoldEvent = false; + } + } + return ret; } /* 00003110-00003130 .text talk_2__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::talk_2() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::talk_2() { + return talk_1(); } /* 00003130-00003348 .text wait_2__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::wait_2() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::wait_2() { + cLib_addCalcAngleS( + ¤t.angle.y, + mInitialAngle.y, + 4, + 0x800, + 0 + ); + if(m812 == 1 || m812 >= 3) { + return TRUE; + } + if (m809) { + if (m7FF) { + dComIfGp_setNextStage("LinkRM",201,0,9,0.0,0,1,0); + return TRUE; + } + + if (chk_talk()) { + setStt(2); + mHeadOnlyFollow = false; + } + return TRUE; + } else if (!dComIfGs_checkCollect(1) && dComIfGs_isEventBit(dSv_event_flag_c::UNK_3202)) { + current.pos.x = -290.0; + current.pos.y = 0.0; + current.pos.z = 110.0; + current.angle.y = -0x8000; + mInitialPos.set(current.pos); + + mInitialAngle = current.angle; + if ((dComIfGp_getPlayer(0)->current.pos.y - current.pos.y) < 1.0f) { + m812 = 1; + m7FF = 1; + } + mLookBackState = 3; + mTargetYRot = mInitialAngle.y; + m_jnt.setTrn(); + return TRUE; + } + m812 = 2; + if (mbAttention) { + mEvTimer2 = 60; + } + if (cLib_calcTimer(&mEvTimer2) && chk_drct(61.0)) { + mLookBackState = 1; + } else { + mLookBackState = 3; + mTargetYRot = mInitialAngle.y; + m_jnt.setTrn(); + } + return TRUE; } /* 00003348-00003368 .text wait_3__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::wait_3() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::wait_3() { + return wait_2(); } /* 00003368-000034AC .text ZZZwai__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::ZZZwai() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::ZZZwai() { + if(m812 == 1 || m812 >= 3) { + return TRUE; + } + if (mFairyUsed) { + mFairyUsed = false; + m812 = 4; + return TRUE; + } + if (m809) { + if (chk_talk()) { + setStt(5); + } + return TRUE; + } + + if (dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED)) { + m812 = 2; + if (mbAttention) { + mEvTimer2 = 60; + } + if (cLib_calcTimer(&mEvTimer2) && chk_drct(61.0)) { + mLookBackState = 1; + } else { + mLookBackState = 3; + mTargetYRot = mInitialAngle.y; + m_jnt.setTrn(); + } + } + else { + m812 = 0; + if (check_useFairyArea()) { + m812 = 2; + } + } + return TRUE; } /* 000034AC-0000363C .text wait_action1__11daNpc_Ba1_cFPv */ -void daNpc_Ba1_c::wait_action1(void*) { - /* Nonmatching */ +BOOL daNpc_Ba1_c::wait_action1(void*) { + switch(m818) { + case 0: + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_2A80)) { + m7FA = dComIfGs_isTmpBit(dSv_event_tmp_flag_c::UNK_0310); + + if (m7FA) { + dComIfGs_offTmpBit(dSv_event_tmp_flag_c::UNK_0310); + } + setStt(1); + m818++; + } + else { + if (dComIfGs_isTmpBit(dSv_event_tmp_flag_c::UNK_0310)) { + setStt(1); + m818++; + } + else { + setStt(7); + m818++; + } + } + break; + case 1: + case 2: + case 3: + mbAttention = chkAttention(); + switch(mStatus) { + case 7: + mbSetEyePos = wait_0(); + break; + case 1: + mbSetEyePos = wait_1(); + break; + case 2: + mbSetEyePos = talk_1(); + break; + } + lookBack(); + default: + case 9: + break; + + + } + return TRUE; + } /* 0000363C-000036F8 .text wait_action2__11daNpc_Ba1_cFPv */ -void daNpc_Ba1_c::wait_action2(void*) { - /* Nonmatching */ -} +BOOL daNpc_Ba1_c::wait_action2(void*) { + switch(m818) { + case 0: + setStt(3); + m818++; + break; + case 1: + case 2: + case 3: + mbAttention = chkAttention(); + switch(mStatus) { + case 3: + mbSetEyePos =wait_2(); + break; + case 2: + mbSetEyePos = talk_1(); + break; + } + lookBack(); + break; + default: + case 9: + break; + } + return TRUE; + } /* 000036F8-00003730 .text demo_action1__11daNpc_Ba1_cFPv */ -void daNpc_Ba1_c::demo_action1(void*) { - /* Nonmatching */ +BOOL daNpc_Ba1_c::demo_action1(void*) { + switch (m818) { + case 9: + break; + case 0: + m818++; + case 1: + case 2: + case 3: + break; + } + return TRUE; } /* 00003730-000037EC .text wait_action3__11daNpc_Ba1_cFPv */ -void daNpc_Ba1_c::wait_action3(void*) { - /* Nonmatching */ +BOOL daNpc_Ba1_c::wait_action3(void*) { + switch(m818) { + case 0: + setStt(4); + m818++; + break; + case 1: + case 2: + case 3: + mbAttention = chkAttention(); + switch(mStatus) { + case 4: + mbSetEyePos = ZZZwai(); + break; + case 5: + mbSetEyePos =talk_2(); + break; + } + lookBack(); + break; + default: + case 9: + break; + } + return TRUE; } /* 000037EC-000038A8 .text wait_action4__11daNpc_Ba1_cFPv */ -void daNpc_Ba1_c::wait_action4(void*) { - /* Nonmatching */ +BOOL daNpc_Ba1_c::wait_action4(void*) { + switch(m818) { + case 0: + setStt(6); + m818++; + break; + case 1: + case 2: + case 3: + mbAttention = chkAttention(); + switch(mStatus) { + case 6: + mbSetEyePos = wait_3(); + break; + case 2: + mbSetEyePos =talk_1(); + break; + } + lookBack(); + break; + default: + case 9: + break; + } + return TRUE; } /* 000038A8-00003A18 .text demo__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::demo() { - /* Nonmatching */ +bool daNpc_Ba1_c::demo() { + if(demoActorID == 0){ + if(mbInDemo != 0){ + mbInDemo = 0; + } + }else{ + mbInDemo = 1; + dDemo_actor_c* demo_actor = dComIfGp_demo_getActor(demoActorID); + if(m_hed_tex_pttrn){ + mBlinkFrame += 1; + if (mBlinkFrame >= m_hed_tex_pttrn->getFrameMax()) { + mBlinkFrame = m_hed_tex_pttrn->getFrameMax(); + } + } + J3DAnmTexPattern* demopattern = demo_actor->getP_BtpData("Ba"); + if(demopattern){ + m_hed_tex_pttrn = demopattern; + if(mHeadBtpAnm.init(mpMorf->getModel()->getModelData(),m_hed_tex_pttrn,1,2,1.0f,0,-1,true,FALSE)){ + mBtpNum = dRes_ID_BA_BTP_BA_T02_e; + mBlinkFrame = 0; + } + } + dDemo_setDemoData(this,0x6A, mpMorf,"Ba"); + m78A.x = current.angle.x; + m78A.y = current.angle.y; + m78A.z = current.angle.z; + + shape_angle.x = m78A.x; + shape_angle.y = m78A.y; + shape_angle.z = m78A.z; + + } + return mbInDemo; } /* 00003A18-00003AA8 .text shadowDraw__11daNpc_Ba1_cFv */ void daNpc_Ba1_c::shadowDraw() { - /* Nonmatching */ + cXyz temp(current.pos.x,current.pos.y + 150.0f, current.pos.z); + + mShadowID = dComIfGd_setShadow( + mShadowID, + 1, + mpMorf->getModel(), + &temp, + 800.0f, + 40.0f, + current.pos.y, + mObjAcch.GetGroundH(), + mObjAcch.m_gnd, + &tevStr, + 0, + 1.0, + dDlst_shadowControl_c::getSimpleTex() + ); + +} + +static void dummy() { + const GXColor dummy1 = { 0xFF, 0x00, 0x00, 0x80 }; + const GXColor dummy2 = { 0x00, 0x00, 0xFF, 0x80 }; + const GXColor dummy3 = { 0xFF, 0xFF, 0x00, 0x80 }; + const GXColor dummy4 = { 0xFF, 0xFF, 0x00, 0x80 }; } /* 00003AA8-00003C0C .text _draw__11daNpc_Ba1_cFv */ BOOL daNpc_Ba1_c::_draw() { - /* Nonmatching */ + + J3DModel* morf_model = mpMorf->getModel(); + J3DModelData* model_data = morf_model->getModelData(); + + if(mbInitGrandma0 || m7F7) { + return TRUE; + } + + g_env_light.settingTevStruct(TEV_TYPE_ACTOR,¤t.pos,&tevStr); + g_env_light.setLightTevColorType(morf_model,&tevStr); + + mHeadBtpAnm.entry(model_data,mBlinkFrame); + mpMorf->entryDL(); + mHeadBtpAnm.remove(model_data); + if(mpClothModel != NULL) { + g_env_light.setLightTevColorType(mpClothModel, &tevStr); + mDoExt_modelEntryDL(mpClothModel); + } + shadowDraw(); + dSnap_RegistFig(DSNAP_TYPE_NPC_BA1, this, 1.0f, 1.0f, 1.0f); + + if(l_HIO.mPrmTbl.m18 != 0){ + cXyz somevec; + if(mSpecificType == 0) { + somevec = current.pos; + somevec.y = eyePos.y; + } + if(mSpecificType == 3) { + somevec = current.pos; + somevec.y = eyePos.y; + } + + } + return TRUE; } /* 00003C0C-00003E1C .text _execute__11daNpc_Ba1_cFv */ BOOL daNpc_Ba1_c::_execute() { - /* Nonmatching */ + if(!mbRanExecute) { + mInitialPos = current.pos; + mInitialAngle = current.angle; + mbRanExecute = true; + } + m_jnt.setParam(l_HIO.mPrmTbl.mMaxBackboneX ,l_HIO.mPrmTbl.mMaxBackboneY, + l_HIO.mPrmTbl.mMinBackboneX,l_HIO.mPrmTbl.mMinBackboneY, + l_HIO.mPrmTbl.mMaxHeadX,l_HIO.mPrmTbl.mMaxHeadY, + l_HIO.mPrmTbl.mMinHeadX,l_HIO.mPrmTbl.mMinHeadY, + l_HIO.mPrmTbl.mMaxTurnStep); + if(mbInitGrandma0 && demoActorID == 0) { + return TRUE; + } + m7F6 = false; + mbInitGrandma0 = false; + partner_srch(); + checkOrder(); + if(!demo()) { + s32 cond = -1; + if(dComIfGp_event_runCheck() && checkCommandTalk() == false){ + cond = isEventEntry(); + } + if(cond >= 0){ + mbSetEyePos = 1; + event_proc(cond); + }else{ + (this->*mCurrProcFunc)(NULL); + } + if(!m7F6) { + fopAcM_posMoveF(this, mStts.GetCCMoveP()); + } + if(!m7F5) { + m78A = current.angle; + shape_angle = m78A; + } + } + eventOrder(); + setMtx(false); + + if(!mbInDemo && !m7FE){ + f32 radius = 50; + f32 height = 110.0; + if(m7FD) { + radius = 30; + } + setCollision( + radius, + height + ); + } + + return TRUE; } /* 00003E1C-00003E78 .text _delete__11daNpc_Ba1_cFv */ BOOL daNpc_Ba1_c::_delete() { - /* Nonmatching */ + dComIfG_resDelete(&mPhs,"Ba"); +#if VERSION > VERSION_DEMO + if(heap != NULL && mpMorf != NULL) +#else + if(mpMorf != NULL) +#endif + { + mpMorf->stopZelAnime(); + } +#if VERSION == VERSION_DEMO + l_HIO.removeHIO(); +#endif + return TRUE; + } /* 00003E78-00003E98 .text CheckCreateHeap__FP10fopAc_ac_c */ -static BOOL CheckCreateHeap(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL CheckCreateHeap(fopAc_ac_c* i_this) { + return static_cast(i_this)->CreateHeap(); } /* 00003E98-00003FB8 .text _create__11daNpc_Ba1_cFv */ cPhs_State daNpc_Ba1_c::_create() { - /* Nonmatching */ + static int a_size_tbl[] = { + 0x272E0 + }; + + fopAcM_ct_Retail(this, daNpc_Ba1_c); + cPhs_State state = dComIfG_resLoad(&mPhs,"Ba"); + if(state != cPhs_COMPLEATE_e) { + return state; + } + u32 tmp = fopAcM_GetParam(this) & 0xFF; + if(!charDecide(tmp)) { + return cPhs_ERROR_e; + } + #if VERSION == VERSION_DEMO + l_HIO.entryHIO("おばあちゃん"); + fopAcM_ct(this, daNpc_Ba1_c); + #endif + if(!fopAcM_entrySolidHeap(this,CheckCreateHeap,a_size_tbl[mType])){ + return cPhs_ERROR_e; + } + fopAcM_SetMtx(this,mpMorf->getModel()->getBaseTRMtx()); + fopAcM_setCullSizeBox(this,-50.0,-20.0,-50.0,50.0,120.0,50.0); + if(!createInit()){ + return cPhs_ERROR_e; + } + + return state; } /* 000043E8-00004658 .text create_Anm__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::create_Anm() { - /* Nonmatching */ +J3DModelData* daNpc_Ba1_c::create_Anm() { + J3DModelData* a_mdl_dat = (J3DModelData*)dComIfG_getObjectIDRes("Ba",dRes_ID_BA_BDL_BA_e); + JUT_ASSERT(VERSION_SELECT(2828, 2827, 2828, 2828), a_mdl_dat != NULL); + mpMorf = new mDoExt_McaMorf( + a_mdl_dat, + NULL, + NULL, + (J3DAnmTransform*)dComIfG_getObjectIDRes( + "Ba", + dRes_ID_BA_BCK_WAIT01_e + ), + J3DFrameCtrl::EMode_LOOP, + 1.0f, + 0, + -1, + 1, + NULL, + 0x80000, + 0x11020022 + ); + if(mpMorf == NULL ){ + return NULL; + } + if(mpMorf->getModel() == NULL){ + mpMorf = NULL; + return NULL; + } + + m_hed_jnt_num = a_mdl_dat->getJointName()->getIndex("head"); + JUT_ASSERT(VERSION_SELECT(2848, 2847, 2848, 2848), m_hed_jnt_num >= 0); + m_bbone_jnt_num = a_mdl_dat->getJointName()->getIndex("backbone"); + JUT_ASSERT(VERSION_SELECT(2851, 2850, 2851, 2851), m_bbone_jnt_num >= 0); + m_footL_jnt_num = a_mdl_dat->getJointName()->getIndex("footL"); + JUT_ASSERT(VERSION_SELECT(2854, 2853, 2854, 2854), m_footL_jnt_num >= 0); + + return a_mdl_dat; } /* 00004658-00004714 .text create_itm_Mdl__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::create_itm_Mdl() { - /* Nonmatching */ +bool daNpc_Ba1_c::create_itm_Mdl() { + mpClothModel = NULL; + J3DModelData* a_mdl_dat = (J3DModelData*)dComIfG_getObjectIDRes("Ba",dRes_ID_BA_BDL_BA_CLOTH_e); + JUT_ASSERT(VERSION_SELECT(2872, 2871, 2872, 2872), a_mdl_dat != NULL); + mpClothModel = mDoExt_J3DModel__create(a_mdl_dat,0x80000,0x11000002); + return true; } /* 00004714-0000485C .text CreateHeap__11daNpc_Ba1_cFv */ -void daNpc_Ba1_c::CreateHeap() { - /* Nonmatching */ +BOOL daNpc_Ba1_c::CreateHeap() { + J3DModelData* anm_model = create_Anm(); + if(!anm_model) { + return FALSE; + } + mBtpNum = 1; + if(!iniTexPttrnAnm(false)) { + mpMorf = NULL; + return FALSE; + } + if(create_itm_Mdl()) { + for(u16 i = 0; i < anm_model->getJointNum(); i++){ + if((i == m_hed_jnt_num) ||( i == m_bbone_jnt_num)){ + mpMorf->getModel()->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack_Ba1); + } + } + mpMorf->getModel()->setUserArea((u32)this); + mAcchCir.SetWall(30.0f,50.0f); + mObjAcch.Set( + fopAcM_GetPosition_p(this), + fopAcM_GetOldPosition_p(this), + this, + 1, + &mAcchCir, + fopAcM_GetSpeed_p(this), + NULL, + NULL + ); + return TRUE; + } + mpMorf = NULL; + return FALSE; } /* 0000485C-0000487C .text daNpc_Ba1_Create__FP10fopAc_ac_c */ diff --git a/src/d/actor/d_a_npc_bm1.cpp b/src/d/actor/d_a_npc_bm1.cpp index 8738b1b10..dfe7116a9 100644 --- a/src/d/actor/d_a_npc_bm1.cpp +++ b/src/d/actor/d_a_npc_bm1.cpp @@ -52,8 +52,9 @@ public: class daNpc_Bm1_HIO_c : public mDoHIO_entry_c { public: daNpc_Bm1_HIO_c(); - virtual ~daNpc_Bm1_HIO_c() {}; - void genMessage(JORMContext* ctx); + virtual ~daNpc_Bm1_HIO_c() {} + + void genMessage(JORMContext* ctx) {} public: /* 0x04 */ s8 m4; @@ -687,8 +688,8 @@ bool daNpc_Bm1_c::createInit() { mEventIdTable[i] = dComIfGp_evmng_getEventIdx(l_evn_tbl[i]); } attention_info.flags = fopAc_Attn_LOCKON_TALK_e | fopAc_Attn_ACTION_SPEAK_e; - attention_info.distances[1] = a_att_dis_TBL[mType][0]; - attention_info.distances[3] = a_att_dis_TBL[mType][1]; + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = a_att_dis_TBL[mType][0]; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = a_att_dis_TBL[mType][1]; gravity = -4.5; m82C = current.pos; s32 iVar5 = 0xFF; @@ -2940,6 +2941,7 @@ void daNpc_Bm1_c::privateCut(int arg0) { break; case 1: cut_init_360_TRN(arg0); + break; } } bool cVar3; diff --git a/src/d/actor/d_a_npc_km1.cpp b/src/d/actor/d_a_npc_km1.cpp index 050046389..706593fa7 100644 --- a/src/d/actor/d_a_npc_km1.cpp +++ b/src/d/actor/d_a_npc_km1.cpp @@ -473,6 +473,7 @@ void daNpc_Km1_c::privateCut() { switch(field_0x7C9){ case 0: event_actionInit(staffIdx); + break; } } bool bVar1; diff --git a/src/d/actor/d_a_npc_p1.cpp b/src/d/actor/d_a_npc_p1.cpp index 12c8f94c8..2cba33326 100644 --- a/src/d/actor/d_a_npc_p1.cpp +++ b/src/d/actor/d_a_npc_p1.cpp @@ -900,13 +900,13 @@ BOOL daNpc_P1_c::privateCut() { switch (actIdx) { case 2: evn_setAnm_init(staffIdx); - break; case 3: mHeadAnm.swing_vertical_init(2, 0x1000, 0x800, 1); break; case 4: evn_talk_init(staffIdx); + break; } } switch (actIdx) { @@ -1043,8 +1043,8 @@ cPhs_State daNpc_P1_c::_create() { mKajiTimer = 300; if (mType == TYPE_P1B_e) { - attention_info.distances[1] = 0xAA; - attention_info.distances[3] = 0xAA; + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 0xAA; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0xAA; u8 type = mParam; if (mParam == 1) { if (dComIfGp_getStartStagePoint() == 0 || dComIfGp_getStartStagePoint() == 2) { @@ -1064,8 +1064,8 @@ cPhs_State daNpc_P1_c::_create() { setAction(&daNpc_P1_c::normalAction, NULL, 0); } } else if (mType == TYPE_P1C_e) { - attention_info.distances[1] = 0xAA; - attention_info.distances[3] = 0xAA; + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 0xAA; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0xAA; if (!dComIfGs_isEventBit(0x820) && !dComIfGs_isEventBit(dSv_event_flag_c::UNK_0808)) { current.pos.x -= cM_scos(current.angle.y) * 40.0f; current.pos.z += cM_ssin(current.angle.y) * 40.0f; @@ -1076,8 +1076,8 @@ cPhs_State daNpc_P1_c::_create() { } mCyl.SetR(100.0f); } else { - attention_info.distances[1] = 0xAB; - attention_info.distances[3] = 0xAB; + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 0xAB; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0xAB; if (m671 != 0) { setAnm(9, 0.0f); mCyl.SetR(REG10_F(5) + 90.0f); diff --git a/src/d/actor/d_a_npc_rsh1.cpp b/src/d/actor/d_a_npc_rsh1.cpp index 77200d3fc..b65580c80 100644 --- a/src/d/actor/d_a_npc_rsh1.cpp +++ b/src/d/actor/d_a_npc_rsh1.cpp @@ -940,7 +940,7 @@ BOOL daNpc_Rsh1_c::CreateInit() { mActorAngle = current.angle; attention_info.flags = fopAc_Attn_LOCKON_TALK_e | fopAc_Attn_ACTION_SPEAK_e; attention_info.distances[fopAc_Attn_TYPE_BATTLE_e] = 173; - attention_info.distances[8] = 173; // Bug? + attention_info.distances[8] = 173; // !@bug: There is no distances[8], this overwrites the first byte of position.x gravity = -30.0f; switch (m95E) { diff --git a/src/d/actor/d_a_npc_so.cpp b/src/d/actor/d_a_npc_so.cpp index a8c244bf8..81077e0e6 100644 --- a/src/d/actor/d_a_npc_so.cpp +++ b/src/d/actor/d_a_npc_so.cpp @@ -12,7 +12,7 @@ daNpc_So_HIO_c::daNpc_So_HIO_c() { } /* 000002A4-000002D0 .text searchEsa_CB__FPvPv */ -void searchEsa_CB(void*, void*) { +static void searchEsa_CB(void*, void*) { /* Nonmatching */ } @@ -32,7 +32,7 @@ void daNpc_So_c::_nodeControl(J3DNode*, J3DModel*) { } /* 000004B0-000004DC .text searchTagSo_CB__FPvPv */ -void searchTagSo_CB(void*, void*) { +static void searchTagSo_CB(void*, void*) { /* Nonmatching */ } @@ -42,7 +42,7 @@ void daNpc_So_c::_searchTagSo(fopAc_ac_c*) { } /* 0000054C-00000578 .text searchMinigameTagSo_CB__FPvPv */ -void searchMinigameTagSo_CB(void*, void*) { +static void searchMinigameTagSo_CB(void*, void*) { /* Nonmatching */ } diff --git a/src/d/actor/d_a_npc_tc_cut.inc b/src/d/actor/d_a_npc_tc_cut.inc index 43ea9bc21..92d7f5849 100644 --- a/src/d/actor/d_a_npc_tc_cut.inc +++ b/src/d/actor/d_a_npc_tc_cut.inc @@ -83,6 +83,7 @@ void daNpc_Tc_c::cutProc() { break; case 8: cutPayProc(staffIdx); + break; } } } diff --git a/src/d/actor/d_a_obj_ikada.cpp b/src/d/actor/d_a_obj_ikada.cpp index 37332c36f..75b4480b8 100644 --- a/src/d/actor/d_a_obj_ikada.cpp +++ b/src/d/actor/d_a_obj_ikada.cpp @@ -20,6 +20,57 @@ #include "f_op/f_op_actor_mng.h" #include "f_op/f_op_kankyo_mng.h" +class daObj_Ikada_HIO_c : public mDoHIO_entry_c { +public: + daObj_Ikada_HIO_c(); + virtual ~daObj_Ikada_HIO_c() {} + + void genMessage(JORMContext* ctx) {} + +public: + /* 0x04 */ u8 mbDebugDraw; + /* 0x05 */ u8 m05; + /* 0x06 */ u8 m06; + /* 0x07 */ u8 mbNoRotAnim; + /* 0x08 */ u8 m08; + /* 0x09 */ u8 m09[0x0C - 0x09]; + /* 0x0C */ cXyz mFlagOffset; + /* 0x18 */ f32 mFlagScale; + /* 0x1C */ s16 m1C; + /* 0x1E */ s16 m1E; + /* 0x20 */ f32 m20; + /* 0x24 */ s16 m24; + /* 0x26 */ u8 m26[0x28 - 0x26]; + /* 0x28 */ f32 m28; + /* 0x2C */ f32 mShipOffsY_Attention; + /* 0x30 */ f32 mShipOffsY_Eye; + /* 0x34 */ f32 mTerryWaveOffsZ; + /* 0x38 */ f32 mTerryWaveOffsY; + /* 0x3C */ f32 mTerryTrackOffsZ; + /* 0x40 */ f32 mSvWaveOffsX; + /* 0x44 */ f32 mSvTrackOffsX; + /* 0x48 */ f32 mSvOffsX[4]; + /* 0x58 */ f32 mTrackIndTransY; + /* 0x5C */ f32 mTrackIndScaleY; + /* 0x60 */ f32 mSplashScaleMax; + /* 0x64 */ f32 mSplashMaxScaleTimer; + /* 0x68 */ f32 mWaveVelFade; + /* 0x6C */ f32 mTrackVel; + /* 0x70 */ f32 mWaveVelSpeed; + /* 0x74 */ f32 mWaveVelOffs; + /* 0x78 */ f32 mWaveMaxVelocity; + /* 0x7C */ cXyz mWaveCollapsePos0; + /* 0x88 */ cXyz mWaveCollapsePos1; + /* 0x94 */ s16 m94; + /* 0x96 */ s16 mPlayerStopDistance; + /* 0x98 */ s16 m98; + /* 0x9A */ s16 m9A; + /* 0x9C */ f32 m9C; + /* 0xA0 */ f32 mVelocityTargetTerry1; + /* 0xA4 */ f32 mVelocityTargetTerry3; + /* 0xA8 */ f32 mA8; +}; // size = 0xAC + cXyz daObj_Ikada_c::m_rope_base_vec(0.0f, -10.0f, 0.0f); cXyz daObj_Ikada_c::m_crane_offset(200.0f, -340.0f, 0.0f); static daObj_Ikada_HIO_c l_HIO; @@ -94,12 +145,12 @@ daObj_Ikada_HIO_c::daObj_Ikada_HIO_c() { mWaveVelSpeed = 2.0f; mWaveMaxVelocity = 15.0f; mWaveVelOffs = 0.0f; - mWaveCollapsePos[0].x = -80.0f; - mWaveCollapsePos[0].y = -50.0f; - mWaveCollapsePos[0].z = -150.0f; - mWaveCollapsePos[1].x = -40.0f; - mWaveCollapsePos[1].y = -100.0f; - mWaveCollapsePos[1].z = -350.0f; + mWaveCollapsePos0.x = -80.0f; + mWaveCollapsePos0.y = -50.0f; + mWaveCollapsePos0.z = -150.0f; + mWaveCollapsePos1.x = -40.0f; + mWaveCollapsePos1.y = -100.0f; + mWaveCollapsePos1.z = -350.0f; m94 = 3000; mPlayerStopDistance = 6000; m98 = 1000; @@ -127,7 +178,7 @@ void daObj_Ikada_c::_nodeControl(J3DNode* node, J3DModel* model) { J3DJoint* joint = (J3DJoint*)node; s32 jntNo = joint->getJntNo(); mDoMtx_stack_c::copy(model->getAnmMtx(jntNo)); - mDoMtx_stack_c::ZXYrotM(mJointRot[jntNo].x, mJointRot[jntNo].y, mJointRot[jntNo].z); + mDoMtx_stack_c::ZXYrotM(mJointRot[jntNo]); if (jntNo == VSVSP_JNT_SV_CREAN_e) { mDoMtx_stack_c::XrotM(m115A + m115E * (REG12_S(5) + 5) * cM_ssin(m115C)); } @@ -136,7 +187,7 @@ void daObj_Ikada_c::_nodeControl(J3DNode* node, J3DModel* model) { } /* 00000458-00000494 .text pathMove_CB__FP4cXyzP4cXyzP4cXyzPv */ -BOOL pathMove_CB(cXyz* arg1, cXyz* arg2, cXyz* arg3, void* v_this) { +static BOOL pathMove_CB(cXyz* arg1, cXyz* arg2, cXyz* arg3, void* v_this) { return ((daObj_Ikada_c*)v_this)->_pathMove(arg1, arg2, arg3); } @@ -179,7 +230,7 @@ BOOL daObj_Ikada_c::_pathMove(cXyz* arg1, cXyz* arg2, cXyz* arg3) { } /* 000007A0-000007C8 .text ride_CB__FP4dBgWP10fopAc_ac_cP10fopAc_ac_c */ -void ride_CB(dBgW*, fopAc_ac_c* ac1, fopAc_ac_c* ac2) { +static void ride_CB(dBgW*, fopAc_ac_c* ac1, fopAc_ac_c* ac2) { ((daObj_Ikada_c*)ac1)->_ride(ac2); } @@ -347,8 +398,7 @@ void daObj_Ikada_c::createWave() { JPABaseEmitter* emitter = mTrackCallBack.getEmitter(); if (emitter != NULL) { JGeometry::TVec3 scale = (Vec){1.0f, 1.0f, 1.0f}; - emitter->setGlobalDynamicsScale(scale); - emitter->setGlobalParticleScale(scale); + emitter->setGlobalScale(scale); } } } @@ -391,14 +441,14 @@ void daObj_Ikada_c::setWave() { mWaveRCallback.setPitch(l_HIO.mWaveVelOffs + 1.0f); mWaveLCallback.setPitch(1.0f - l_HIO.mWaveVelOffs); - cXyz sp2C = l_HIO.mWaveCollapsePos[0]; - cXyz sp20 = l_HIO.mWaveCollapsePos[1]; - cXyz sp14 = l_HIO.mWaveCollapsePos[0]; - cXyz sp08 = l_HIO.mWaveCollapsePos[1]; + cXyz sp2C = l_HIO.mWaveCollapsePos0; + cXyz sp20 = l_HIO.mWaveCollapsePos1; + cXyz sp14 = sp2C; + cXyz sp08 = sp20; mWaveRCallback.setAnchor(&sp2C, &sp20); - sp14.x = (f32)(f64)sp14.x * -1.0f; - sp08.x = (f32)(f64)sp08.x * -1.0f; + sp14.x *= -1.0f; + sp08.x *= -1.0f; mWaveLCallback.setAnchor(&sp14, &sp08); mWaveRCallback.setMaxDisSpeed(l_HIO.mWaveVelSpeed); @@ -464,7 +514,7 @@ void daObj_Ikada_c::setRopePos() { spBC = *pcVar6; mDoMtx_stack_c::copy(mpModel->getAnmMtx(VSVSP_JNT_SV_CREAN_e)); - mDoMtx_stack_c::transM(m_crane_offset.x, m_crane_offset.y, m_crane_offset.z); + mDoMtx_stack_c::transM(m_crane_offset); mDoMtx_stack_c::multVecZero(pcVar6); if (mCurMode == 1) { @@ -514,7 +564,7 @@ void daObj_Ikada_c::setRopePos() { iVar4 = 0; } else { mDoMtx_stack_c::copy(mpModel->getAnmMtx(VSVSP_JNT_SV_CREAN_e)); - mDoMtx_stack_c::transM(m_crane_offset.x, m_crane_offset.y, m_crane_offset.z); + mDoMtx_stack_c::transM(m_crane_offset); cMtx_copy(mDoMtx_stack_c::get(), ropeEndMtx); spA4.set(pcVar7->x - ropeEndMtx[0][3], pcVar7->y - ropeEndMtx[1][3], pcVar7->z - ropeEndMtx[2][3]); iVar3 = 0; @@ -632,7 +682,7 @@ void daObj_Ikada_c::setMtx() { mDoMtx_stack_c::copy(mpModel->getBaseTRMtx()); mDoMtx_stack_c::multVec(&sp24, &mFirePos); - mDoMtx_stack_c::transM(sp24.x, sp24.y, sp24.z); + mDoMtx_stack_c::transM(sp24); mDoMtx_stack_c::YrotM(mLightRotY); mDoMtx_stack_c::XrotM(mLightRotX); mDoMtx_stack_c::scaleM(mLightPower, mLightPower, mLightPower); @@ -1203,22 +1253,25 @@ bool daObj_Ikada_c::_execute() { return false; } -const u32 unused_5617[] = { - 0xFFFF0080, - 0xFF80, - 0xFF80, - 0xFF000080, - 0xFF000080, - 0xFF80, - 0xFF000080, - 0xFF000080, - 0xFF000080, -}; - /* 00003CA0-00003CD4 .text debugDraw__13daObj_Ikada_cFv */ void daObj_Ikada_c::debugDraw() { cXyz sp08 = current.pos; sp08.y += 20.0f; + // Unused colors, needed for the .rodata section to match. + GXColor unused_5617 = {0xFF, 0xFF, 0x00, 0x80}; + GXColor unused_5621 = {0x00, 0x00, 0xFF, 0x80}; + GXColor unused_5623 = {0x00, 0x00, 0xFF, 0x80}; + GXColor unused_5625 = {0xFF, 0x00, 0x00, 0x80}; + GXColor unused_5629 = {0xFF, 0x00, 0x00, 0x80}; + GXColor unused_5631 = {0x00, 0x00, 0xFF, 0x80}; + GXColor unused_5636 = {0xFF, 0x00, 0x00, 0x80}; + GXColor unused_5640 = {0xFF, 0x00, 0x00, 0x80}; + GXColor unused_5646 = {0xFF, 0x00, 0x00, 0x80}; + // dDbVw_drawSphereOpa__FR4cXyzfRC8_GXColorUc + // dDbVw_drawCircleOpa__FR4cXyzfRC8_GXColorUcUc + if (isWave()) { + // ? + } } /* 00003CD4-00003EE0 .text _draw__13daObj_Ikada_cFv */ @@ -1246,7 +1299,7 @@ bool daObj_Ikada_c::_draw() { J3DModelData* modelData = mpModel->getModelData(); mBckAnm.entry(modelData); mDoExt_modelUpdateDL(mpModel); - mpModel->getModelData()->getJointNodePointer(VSVSP_JNT_SV_SHIP_ROOT_e)->setMtxCalc(NULL); + mBckAnm.remove(mpModel->getModelData()); } else { mDoExt_modelUpdateDL(mpModel); } @@ -1366,10 +1419,10 @@ void daObj_Ikada_c::createInit() { cXyz(0.0f, 0.0f, 0.0f), cXyz(100.0f, 530.0f, 0.0f), }; - static const u32 params[] = {4, 4, 4, 4, 0x2000000}; + static const u32 param[] = {4, 4, 4, 4, 0x2000000}; static const f32 flag_scale[] = {0.2f, 0.0f, 0.0f, 0.0f, 0.12f}; - mFlagPcId = fopAcM_create(fpcNm_MAJUU_FLAG_e, params[mType], ¤t.pos, tevStr.mRoomNo, ¤t.angle); + mFlagPcId = fopAcM_create(fpcNm_MAJUU_FLAG_e, param[mType], ¤t.pos, tevStr.mRoomNo, ¤t.angle); mFlagOffset = flag_offset[mType]; mFlagScale = flag_scale[mType]; } @@ -1385,7 +1438,7 @@ void daObj_Ikada_c::createInit() { cXyz* pcVar7 = &m07DC[m07D8 - 1]; mDoMtx_stack_c::copy(mpModel->getAnmMtx(VSVSP_JNT_SV_CREAN_e)); - mDoMtx_stack_c::transM(m_crane_offset.x, m_crane_offset.y, m_crane_offset.z); + mDoMtx_stack_c::transM(m_crane_offset); mDoMtx_stack_c::multVecZero(pcVar8); cXyz sp80(0.0f, -1.0f, 0.0f); diff --git a/src/d/actor/d_a_obj_majyuu_door.cpp b/src/d/actor/d_a_obj_majyuu_door.cpp index e5a5ff41d..e3ba9f3a3 100644 --- a/src/d/actor/d_a_obj_majyuu_door.cpp +++ b/src/d/actor/d_a_obj_majyuu_door.cpp @@ -209,7 +209,7 @@ void daObj_MjDoor_c::smoke_set() { dComIfGp_particle_setToon(dPa_name::ID_IT_ST_MJMON_SMOKE00, &mPos, &mAngle, NULL, 0xB9, &mSmoke, fopAcM_GetRoomNo(this)); if (mSmoke.getEmitter() != NULL) { - mSmoke.getEmitter()->mGlobalPrmColor.a = 200; + mSmoke.getEmitter()->setGlobalAlpha(200); } } diff --git a/src/d/actor/d_a_obj_mkie.cpp b/src/d/actor/d_a_obj_mkie.cpp index 9c504f690..0e389ce12 100644 --- a/src/d/actor/d_a_obj_mkie.cpp +++ b/src/d/actor/d_a_obj_mkie.cpp @@ -185,7 +185,7 @@ BOOL daObjMkie::Act_c::Create() { #if VERSION > VERSION_DEMO if (daObj::PrmAbstract(this, PRM_FLAG_W, PRM_FLAG_S) != 0) { - actor_status &= ~0x3F; + fopAcM_ClearStatusMap(this); gbaName = 0; } #endif diff --git a/src/d/actor/d_a_obj_vgnfd.cpp b/src/d/actor/d_a_obj_vgnfd.cpp index 928088e0a..5aa05d229 100644 --- a/src/d/actor/d_a_obj_vgnfd.cpp +++ b/src/d/actor/d_a_obj_vgnfd.cpp @@ -419,6 +419,7 @@ bool daObjVgnfd_c::_execute() { dComIfGp_getVibration().StartShock(8, 27, cXyz(0.0f, 1.0f, 0.0f)); mCurModel = 2; fopAcM_seStartCurrent(this, JA_SE_OBJ_B_BOSS_DR_BRK_3, 0); + break; } } diff --git a/src/d/actor/d_a_obj_warpt.cpp b/src/d/actor/d_a_obj_warpt.cpp index 06f6311a0..c1751e6fd 100644 --- a/src/d/actor/d_a_obj_warpt.cpp +++ b/src/d/actor/d_a_obj_warpt.cpp @@ -226,7 +226,7 @@ bool daObj_Warpt_c::createBodyHeap() { } /* 00000620-00000648 .text ride_CB__FP4dBgWP10fopAc_ac_cP10fopAc_ac_c */ -void ride_CB(dBgW*, fopAc_ac_c* a_this, fopAc_ac_c* arg2) { +static void ride_CB(dBgW*, fopAc_ac_c* a_this, fopAc_ac_c* arg2) { ((daObj_Warpt_c*)a_this)->_ride(arg2); } diff --git a/src/d/actor/d_a_oship.cpp b/src/d/actor/d_a_oship.cpp index 20859536e..482f61743 100644 --- a/src/d/actor/d_a_oship.cpp +++ b/src/d/actor/d_a_oship.cpp @@ -132,7 +132,7 @@ void daOship_c::_nodeControl(J3DNode* i_nodeP, J3DModel* i_modelP) { } /* 0000044C-00000488 .text pathMove_CB__FP4cXyzP4cXyzP4cXyzPv */ -int pathMove_CB(cXyz* param_1, cXyz* param_2, cXyz* param_3, void* i_this) { +static int pathMove_CB(cXyz* param_1, cXyz* param_2, cXyz* param_3, void* i_this) { return ((daOship_c *)i_this)->_pathMove(param_1, param_2, param_3); } diff --git a/src/d/actor/d_a_tag_ba1.cpp b/src/d/actor/d_a_tag_ba1.cpp index 399864003..9263c4e03 100644 --- a/src/d/actor/d_a_tag_ba1.cpp +++ b/src/d/actor/d_a_tag_ba1.cpp @@ -12,7 +12,7 @@ daTag_Ba1_HIO_c::daTag_Ba1_HIO_c() { } /* 00000144-00000164 .text daTag_Ba1_XyCheck_cB__FPvi */ -void daTag_Ba1_XyCheck_cB(void*, int) { +static void daTag_Ba1_XyCheck_cB(void*, int) { /* Nonmatching */ } @@ -22,7 +22,7 @@ void daTag_Ba1_c::XyCheck_cB(int) { } /* 00000184-000001A4 .text daTag_Ba1_XyEvent_cB__FPvi */ -void daTag_Ba1_XyEvent_cB(void*, int) { +static void daTag_Ba1_XyEvent_cB(void*, int) { /* Nonmatching */ } diff --git a/src/d/actor/d_a_tag_photo.cpp b/src/d/actor/d_a_tag_photo.cpp index 96b24d5f5..f53b0c029 100644 --- a/src/d/actor/d_a_tag_photo.cpp +++ b/src/d/actor/d_a_tag_photo.cpp @@ -253,6 +253,7 @@ void daTagPhoto_c::privateCut() { switch(mActIdx) { case 0: eventMesSetInit(staffIdx); + break; } } diff --git a/src/d/actor/d_a_tn.cpp b/src/d/actor/d_a_tn.cpp index a001b9ec9..50354536a 100644 --- a/src/d/actor/d_a_tn.cpp +++ b/src/d/actor/d_a_tn.cpp @@ -2701,6 +2701,7 @@ static void Tn_move(tn_class* i_this) { break; case ACTION_S_DEMO: s_demo(i_this); + break; } #if VERSION == VERSION_DEMO if (r29 != 0) { diff --git a/src/d/d_cloth_packet.cpp b/src/d/d_cloth_packet.cpp index 7e9bb3ff6..a53ab8418 100644 --- a/src/d/d_cloth_packet.cpp +++ b/src/d/d_cloth_packet.cpp @@ -357,7 +357,7 @@ void dCloth_packet_c::setMtx(Mtx mtx) { /* 800642FC-80064330 .text cloth_draw__15dCloth_packet_cFv */ void dCloth_packet_c::cloth_draw() { - j3dSys.getDrawBuffer(OPA_BUFFER)->entryImm(this, 0); + j3dSys.getDrawBuffer(J3DSysDrawBuf_Opa)->entryImm(this, 0); } /* 80064330-8006441C .text TexObjInit__15dCloth_packet_cFP7ResTIMG */ diff --git a/src/d/d_com_static.cpp b/src/d/d_com_static.cpp index b68cd7376..fcd96c6ce 100644 --- a/src/d/d_com_static.cpp +++ b/src/d/d_com_static.cpp @@ -457,6 +457,7 @@ void daTitle_proc_c::daTitle_Kirakira_Sound_flag_on() { } #endif +#if VERSION > VERSION_DEMO /* 80056CCC-80056DE0 .text daiItemNodeCallBack__13daStandItem_cFP7J3DNodei */ BOOL daStandItem_c::daiItemNodeCallBack(J3DNode* node, int calcTiming) { if (calcTiming == J3DNodeCBCalcTiming_In) { @@ -485,6 +486,7 @@ BOOL daStandItem_c::daiItemNodeCallBack(J3DNode* node, int calcTiming) { } return TRUE; } +#endif u8 daNpc_Ji1_c::game_life_point; diff --git a/src/d/d_kankyo_dayproc.inc b/src/d/d_kankyo_dayproc.inc index 8c7e5a20d..a7822ed81 100644 --- a/src/d/d_kankyo_dayproc.inc +++ b/src/d/d_kankyo_dayproc.inc @@ -73,7 +73,7 @@ static void dKankyo_DayProc() { dComIfGs_offEventBit(dSv_event_flag_c::UNK_2680); #if VERSION > VERSION_JPN - if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_2A20)) + if (dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED)) #endif { clamped = cLib_maxLimit(dComIfGs_getEventReg(dSv_event_flag_c::UNK_A60F) + 1, 3); diff --git a/src/d/d_menu_collect.cpp b/src/d/d_menu_collect.cpp index 7d0f3bc7b..b33103796 100644 --- a/src/d/d_menu_collect.cpp +++ b/src/d/d_menu_collect.cpp @@ -12,7 +12,7 @@ #include "JAZelAudio/JAZelAudio_SE.h" #include "d/d_meter.h" -static dMc_HIO_c g_mcHIO; +dMc_HIO_c g_mcHIO; // Number of beats in each baton song. static const s32 tact_beat[] = { @@ -212,8 +212,8 @@ void dMenu_Collect_c::screenSet() { if (m820.mUserArea > 180) m820.mUserArea -= 360; - ((J2DTextBox*)(m740).pane)->setFont(mRFont); - ((J2DTextBox*)(m778).pane)->setFont(mFont); + ((J2DTextBox*)(m740).pane)->setFont(mpRubyFont); + ((J2DTextBox*)(m778).pane)->setFont(mpFont); ((J2DTextBox*)(m740).pane)->setWhite(0xFFFFFFFF); ((J2DTextBox*)(m740).pane)->setCharColor(0x000000FF); @@ -224,15 +224,15 @@ void dMenu_Collect_c::screenSet() { ((J2DTextBox*)(m778).pane)->setGradColor(0x000000FF); fopMsgM_setPaneData(&m858, scrn, 'wd'); - ((J2DTextBox*)(m858).pane)->setFont(mFont); + ((J2DTextBox*)(m858).pane)->setFont(mpFont); - outFont->setPane(mFont, &m858, &m008, &m040, &m078); + outFont->setPane(mpFont, &m858, &m008, &m040, &m078); fopMsgM_setPaneData(&m890[0], scrn, 'nm00'); - ((J2DTextBox*)(m890[0]).pane)->setFont(mFont); + ((J2DTextBox*)(m890[0]).pane)->setFont(mpFont); fopMsgM_setPaneData(&m890[1], scrn, 'nm01'); - ((J2DTextBox*)(m890[1]).pane)->setFont(mFont); + ((J2DTextBox*)(m890[1]).pane)->setFont(mpFont); fopMsgM_setPaneData(&m900, scrn, 'itnm'); fopMsgM_setPaneData(&m938, scrn, 'itnk'); @@ -336,16 +336,43 @@ void dMenu_Collect_c::screenSet() { fopMsgM_setPaneData(&m23E8, scrn, 'cc07'); fopMsgM_setPaneData(&m2420, scrn, 'cc00'); +#if VERSION == VERSION_PAL + if (dComIfGs_getPalLanguage() != 0) { + char sp58[24]; + sprintf(sp58, "title_collect_%d.bti", dComIfGs_getPalLanguage()); + JKRArchive* archive = dComIfGp_getItemIconArchive(); + JKRArchive::readTypeResource(mTitleCollectTexBuffer, 0x1000, 'TIMG', sp58, mpArc); + J2DPicture* r3 = (J2DPicture*)scrn->search('tlcl'); + r3->changeTexture(mTitleCollectTexBuffer, 0); + sprintf(sp58, "word_save_%d.bti", dComIfGs_getPalLanguage()); + JKRArchive::readTypeResource(mWordSaveTexBuffer, 0xc00, 'TIMG', sp58, mpArc); + J2DPicture* r3_2 = (J2DPicture*)scrn->search('wdsv'); + r3_2->changeTexture(mWordSaveTexBuffer, 0); + sprintf(sp58, "word_option_%d.bti", dComIfGs_getPalLanguage()); + JKRArchive::readTypeResource(mWordOptionTexBuffer, 0xc00, 'TIMG', sp58, mpArc); + J2DPicture* r3_3 = (J2DPicture*)scrn->search('wdop'); + r3_3->changeTexture(mWordOptionTexBuffer, 0); + } +#endif + { JKRArchive* archive = dComIfGp_getItemIconArchive(); JKRArchive::readTypeResource(mTactTexBuffer, 0xc00, 'TIMG', "baton.bti", archive); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mTactTexBuffer, 0xc00); +#else DCStoreRangeNoSync(mTactTexBuffer, 0xc00); +#endif } { JKRArchive* archive = dComIfGp_getItemIconArchive(); JKRArchive::readTypeResource(mMapTexBuffer, 0xc00, 'TIMG', "cmap_treasure2.bti", archive); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mMapTexBuffer, 0xc00); +#else DCStoreRangeNoSync(mMapTexBuffer, 0xc00); +#endif } for (int i = 0; i < 6; i++) { @@ -357,8 +384,13 @@ void dMenu_Collect_c::screenSet() { for (int i = 0; i < 8; i++) { JKRArchive* archive = dComIfGp_getItemIconArchive(); - JKRArchive::readTypeResource(mTriforceTexBuffer[i], 0xc00, 'TIMG', triTex[i], archive); + char* r6 = triTex[i]; + JKRArchive::readTypeResource(mTriforceTexBuffer[i], 0xc00, 'TIMG', r6, archive); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mTriforceTexBuffer[i], 0xc00); +#else DCStoreRangeNoSync(mTriforceTexBuffer[i], 0xc00); +#endif ((J2DPicture*)mE08[i].pane)->changeTexture(mTriforceTexBuffer[i], 0); } @@ -368,18 +400,28 @@ void dMenu_Collect_c::screenSet() { for (int i = 0; i < 3; i++) { JKRArchive* archive = dComIfGp_getItemIconArchive(); - JKRArchive::readTypeResource(mSymbolTexBuffer[i], 0xc00, 'TIMG', symTex[i], archive); + char* r6 = symTex[i]; + JKRArchive::readTypeResource(mSymbolTexBuffer[i], 0xc00, 'TIMG', r6, archive); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mSymbolTexBuffer[i], 0xc00); +#else DCStoreRangeNoSync(mSymbolTexBuffer[i], 0xc00); - ((J2DPicture*)m1000[i].pane)->changeTexture((ResTIMG*)mSymbolTexBuffer[i], 0); - ((J2DPicture*)m10A8[i].pane)->changeTexture((ResTIMG*)mSymbolTexBuffer[i], 0); +#endif + ((J2DPicture*)m1000[i].pane)->changeTexture(mSymbolTexBuffer[i], 0); + ((J2DPicture*)m10A8[i].pane)->changeTexture(mSymbolTexBuffer[i], 0); } for (int i = 0; i < 5; i++) { JKRArchive* archive = dComIfGp_getItemIconArchive(); - JKRArchive::readTypeResource(mItemTexBuffer[i], 0xc00, 'TIMG', wepTex[i], archive); + char* r6 = wepTex[i]; + JKRArchive::readTypeResource(mItemTexBuffer[i], 0xc00, 'TIMG', r6, archive); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mItemTexBuffer[i], 0xc00); +#else DCStoreRangeNoSync(mItemTexBuffer[i], 0xc00); - ((J2DPicture*)m2030[i].pane)->changeTexture((ResTIMG*)mItemTexBuffer[i], 0); - ((J2DPicture*)m2148[i].pane)->changeTexture((ResTIMG*)mItemTexBuffer[i], 0); +#endif + ((J2DPicture*)m2030[i].pane)->changeTexture(mItemTexBuffer[i], 0); + ((J2DPicture*)m2148[i].pane)->changeTexture(mItemTexBuffer[i], 0); } char print_format[0x10]; @@ -647,11 +689,10 @@ int dMenu_Collect_c::stickDirection(unsigned char param_1) { } /* 8019D5A8-8019E570 .text cursorMainMove__15dMenu_Collect_cFv */ -int dMenu_Collect_c::cursorMainMove() { - /* Nonmatching */ - u8 found; - int check; - uint old_item; +u8 dMenu_Collect_c::cursorMainMove() { + int direction; + bool found; + u8 old_item; f32 trans; u8 tact_no[6]; @@ -679,11 +720,16 @@ int dMenu_Collect_c::cursorMainMove() { {0x05, 0x09, 0x09, 0xFF, 0x11, 0x10, 0x0F, 0x0A}, }; - u8 direction = 0xFF; + direction = 0xFF; + u8 trigger = stick->checkTrigger(); u8 previous_item = mNowItem; - u8 next_item = 0xFF; - bool moved = false; + + u8 moved; + u8 next_item; + + next_item = 0xFF; + moved = false; if (stick->checkRightTrigger()) { moved = true; @@ -701,11 +747,11 @@ int dMenu_Collect_c::cursorMainMove() { direction = stickDirection(trigger); } - if (direction != 0xFF) { + if ((u8)direction != 0xFF) { found = false; old_item = mNowItem; - next_item = item[mNowItem][direction]; + next_item = item[mNowItem][(u8)direction]; switch (next_item) { case 0: @@ -728,11 +774,10 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x13; } - } else if (old_item == next_item || - !dComIfGs_isTact(next_item)) { - if (direction == 0 || direction == 1) { + } else if (old_item == next_item || !dComIfGs_isTact(next_item)) { + if ((u8)direction == 0 || (u8)direction == 1) { next_item = 0x0E; - } else if (direction == 5 || direction == 6) { + } else if ((u8)direction == 5 || (u8)direction == 6) { tact_no[0] = 1; tact_no[1] = 2; tact_no[2] = 3; @@ -774,18 +819,16 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x13; } - } else if (old_item == next_item || - dComIfGs_isTact(next_item)) { - if (direction == 0 || direction == 1) { + } else if (old_item == next_item || !dComIfGs_isTact(next_item)) { + if ((u8)direction == 0 || (u8)direction == 1) { tact_no[0] = 0; - check = dComIfGs_isTact(0); - next_item = tact_no[0]; - - if (check == 0) { + if (dComIfGs_isTact(0)) { + next_item = tact_no[0]; + } else { next_item = 0x0E; } - } else if (direction == 5 || direction == 6) { + } else if ((u8)direction == 5 || (u8)direction == 6) { tact_no[0] = 2; tact_no[1] = 3; tact_no[2] = 4; @@ -807,7 +850,7 @@ int dMenu_Collect_c::cursorMainMove() { break; case 2: - if (old_item < 6) { + if (old_item > 5) { tact_no[0] = 2; tact_no[1] = 1; tact_no[2] = 3; @@ -826,9 +869,8 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x13; } - } else if (old_item == next_item || - dComIfGs_isTact(next_item)) { - if (direction == 0 || direction == 1) { + } else if (old_item == next_item || !dComIfGs_isTact(next_item)) { + if ((u8)direction == 0 || (u8)direction == 1) { tact_no[0] = 1; tact_no[1] = 0; @@ -843,7 +885,7 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x0E; } - } else if (direction == 5 || direction == 6) { + } else if ((u8)direction == 5 || (u8)direction == 6) { tact_no[0] = 3; tact_no[1] = 4; tact_no[2] = 5; @@ -864,43 +906,7 @@ int dMenu_Collect_c::cursorMainMove() { break; case 3: - if (old_item < 6) { - if (old_item == next_item || - dComIfGs_isTact(next_item)) { - if (direction == 0 || direction == 1) { - tact_no[0] = 2; - tact_no[1] = 1; - tact_no[2] = 0; - - for (int i = 0; i < 3; i++) { - if (dComIfGs_isTact(tact_no[i])) { - next_item = tact_no[i]; - found = true; - break; - } - } - - if (!found) { - next_item = 0x0E; - } - } else if (direction == 5 || direction == 6) { - tact_no[0] = 4; - tact_no[1] = 5; - - for (int i = 0; i < 2; i++) { - if (dComIfGs_isTact(tact_no[i])) { - next_item = tact_no[i]; - found = true; - break; - } - } - - if (!found) { - next_item = 10; - } - } - } - } else { + if (old_item > 5) { tact_no[0] = 3; tact_no[1] = 2; tact_no[2] = 4; @@ -919,52 +925,49 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x13; } + } else if (old_item == next_item || !dComIfGs_isTact(next_item)) { + if ((u8)direction == 0 || (u8)direction == 1) { + tact_no[0] = 2; + tact_no[1] = 1; + tact_no[2] = 0; + + for (int i = 0; i < 3; i++) { + if (dComIfGs_isTact(tact_no[i])) { + next_item = tact_no[i]; + found = true; + break; + } + } + + if (!found) { + next_item = 0x0E; + } + } else if ((u8)direction == 5 || (u8)direction == 6) { + tact_no[0] = 4; + tact_no[1] = 5; + + for (int i = 0; i < 2; i++) { + if (dComIfGs_isTact(tact_no[i])) { + next_item = tact_no[i]; + found = true; + break; + } + } + + if (!found) { + next_item = 10; + } + } } break; case 4: - if (old_item < 6) { - if (old_item == next_item || - dComIfGs_isTact(next_item)) { - if (direction == 0 || direction == 1) { - tact_no[0] = 2; - tact_no[1] = 1; - tact_no[2] = 0; - - for (int i = 0; i < 3; i++) { - if (dComIfGs_isTact(tact_no[i])) { - next_item = tact_no[i]; - found = true; - break; - } - } - - if (!found) { - next_item = 0x0E; - } - } else if (direction == 5 || direction == 6) { - tact_no[0] = 4; - tact_no[1] = 5; - - for (int i = 0; i < 2; i++) { - if (dComIfGs_isTact(tact_no[i])) { - next_item = tact_no[i]; - found = true; - break; - } - } - - if (!found) { - next_item = 10; - } - } - } - } else { - tact_no[0] = 3; - tact_no[1] = 2; - tact_no[2] = 4; - tact_no[3] = 1; - tact_no[4] = 5; + if (old_item > 5) { + tact_no[0] = 4; + tact_no[1] = 3; + tact_no[2] = 5; + tact_no[3] = 2; + tact_no[4] = 1; tact_no[5] = 0; for (int i = 0; i < 6; i++) { @@ -978,52 +981,46 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x13; } + } else if (old_item == next_item || !dComIfGs_isTact(next_item)) { + if ((u8)direction == 0 || (u8)direction == 1) { + tact_no[0] = 3; + tact_no[1] = 2; + tact_no[2] = 1; + tact_no[3] = 0; + + for (int i = 0; i < 4; i++) { + if (dComIfGs_isTact(tact_no[i])) { + next_item = tact_no[i]; + found = true; + break; + } + } + + if (!found) { + next_item = 0x0E; + } + } else if ((u8)direction == 5 || (u8)direction == 6) { + tact_no[0] = 5; + + if (dComIfGs_isTact(5)) { + next_item = tact_no[0]; + found = true; + } + + if (!found) { + next_item = 10; + } + } } break; case 5: - if (old_item < 6) { - if (old_item == next_item || - dComIfGs_isTact(next_item)) { - if (direction == 0 || direction == 1) { - tact_no[0] = 2; - tact_no[1] = 1; - tact_no[2] = 0; - - for (int i = 0; i < 3; i++) { - if (dComIfGs_isTact(tact_no[i])) { - next_item = tact_no[i]; - found = true; - break; - } - } - - if (!found) { - next_item = 0x0E; - } - } else if (direction == 5 || direction == 6) { - tact_no[0] = 4; - tact_no[1] = 5; - - for (int i = 0; i < 2; i++) { - if (dComIfGs_isTact(tact_no[i])) { - next_item = tact_no[i]; - found = true; - break; - } - } - - if (!found) { - next_item = 10; - } - } - } - } else { - tact_no[0] = 3; - tact_no[1] = 2; - tact_no[2] = 4; - tact_no[3] = 1; - tact_no[4] = 5; + if (old_item > 5) { + tact_no[0] = 5; + tact_no[1] = 4; + tact_no[2] = 3; + tact_no[3] = 2; + tact_no[4] = 1; tact_no[5] = 0; for (int i = 0; i < 6; i++) { @@ -1037,13 +1034,33 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x13; } + } else if (old_item == next_item || !dComIfGs_isTact(next_item)) { + if ((u8)direction == 0 || (u8)direction == 1) { + tact_no[0] = 4; + tact_no[1] = 3; + tact_no[2] = 2; + tact_no[3] = 1; + tact_no[4] = 0; + + for (int i = 0; i < 5; i++) { + if (dComIfGs_isTact(tact_no[i])) { + next_item = tact_no[i]; + found = true; + break; + } + } + + if (!found) { + next_item = 0x0E; + } + } else if ((u8)direction == 5 || (u8)direction == 6) { + next_item = 10; + } } break; case 0x0B: - if (old_item == 0x0B || - old_item == 0x0C || - old_item == 0x0D) { + if (old_item != 0x0B && old_item != 0x0C && old_item != 0x0D) { tact_no[0] = 0x0B; tact_no[1] = 0x0C; tact_no[2] = 0x0D; @@ -1059,22 +1076,19 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x14; } - } else if (old_item == next_item || - !dComIfGs_isSymbol(next_item - 0x0B)) { - if (direction == 1) { + } else if (old_item == next_item || !dComIfGs_isSymbol(next_item - 0x0B)) { + if ((u8)direction == 1) { next_item = 9; - } else if (direction == 5 || direction == 6) { + } else if ((u8)direction == 5 || (u8)direction == 6) { next_item = 0x11; - } else if (direction == 0 || direction == 7) { + } else if ((u8)direction == 0 || (u8)direction == 7) { next_item = 10; } } break; case 0x0C: - if (old_item == 0x0B || - old_item == 0x0C || - old_item == 0x0D) { + if (old_item != 0x0B && old_item != 0x0C && old_item != 0x0D) { tact_no[0] = 0x0C; tact_no[1] = 0x0B; tact_no[2] = 0x0D; @@ -1090,17 +1104,16 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x14; } - } else if (old_item == next_item || - !dComIfGs_isSymbol(next_item - 0x0B)) { - if (direction == 1) { + } else if (old_item == next_item || !dComIfGs_isSymbol(next_item - 0x0B)) { + if ((u8)direction == 1) { next_item = 9; - } else if (direction == 5 || direction == 6) { + } else if ((u8)direction == 5 || (u8)direction == 6) { next_item = 0x0B; if (!dComIfGs_isSymbol(0)) { next_item = 0x11; } - } else if (direction == 0 || direction == 7) { + } else if ((u8)direction == 0 || (u8)direction == 7) { next_item = 0x0B; if (!dComIfGs_isSymbol(0)) { @@ -1111,9 +1124,7 @@ int dMenu_Collect_c::cursorMainMove() { break; case 0x0D: - if (old_item != 0x0B && - old_item != 0x0C && - old_item != 0x0D) { + if (old_item != 0x0B && old_item != 0x0C && old_item != 0x0D) { tact_no[0] = 0x0D; tact_no[1] = 0x0C; tact_no[2] = 0x0B; @@ -1129,17 +1140,16 @@ int dMenu_Collect_c::cursorMainMove() { if (!found) { next_item = 0x14; } - } else if (old_item == next_item || - !dComIfGs_isSymbol(next_item - 0x0B)) { - if (direction == 1) { + } else if (old_item == next_item || !dComIfGs_isSymbol(next_item - 0x0B)) { + if ((u8)direction == 1) { next_item = 0x0C; if (!dComIfGs_isSymbol(1)) { next_item = 9; } - } else if (direction == 5 || direction == 6) { + } else if ((u8)direction == 5 || (u8)direction == 6) { next_item = 0x11; - } else if (direction == 0 || direction == 7) { + } else if ((u8)direction == 0 || (u8)direction == 7) { next_item = 0x0B; if (!dComIfGs_isSymbol(0)) { @@ -1156,10 +1166,8 @@ int dMenu_Collect_c::cursorMainMove() { } if (mNowItem != previous_item) { - if (((mNowItem <= 0x0D || mNowItem >= 0x13) && - (previous_item > 0x0D && previous_item < 0x13)) || - ((previous_item <= 0x0D || previous_item >= 0x13) && - (mNowItem > 0x0D && mNowItem < 0x13))) { + if (((mNowItem <= 0x0D || mNowItem >= 0x13) && (previous_item > 0x0D && previous_item < 0x13)) || + ((previous_item <= 0x0D || previous_item >= 0x13) && (mNowItem > 0x0D && mNowItem < 0x13))) { mA18[1].mUserArea = 10; } @@ -1177,7 +1185,7 @@ int dMenu_Collect_c::cursorMainMove() { m858.mUserArea = 0; itemnameSet(); - mDoAud_seStart(0x80E, NULL, 0); + mDoAud_seStart(JA_SE_ITM_MENU_CURSOR); } switch (mNowItem) { @@ -1190,33 +1198,31 @@ int dMenu_Collect_c::cursorMainMove() { case 6: case 7: if (collectItemGetCheck(mNowItem)) { - dComIfGp_setDoStatusForce(0x17); + dComIfGp_setDoStatusForce(dActStts_CHOOSE_e); } else { - dComIfGp_setDoStatusForce(0); - dComIfGp_setDoStatus(0); + dComIfGp_setDoStatusForce(dActStts_BLANK_e); + dComIfGp_setDoStatus(dActStts_BLANK_e); } break; default: if (collectItemGetCheck(mNowItem)) { - dComIfGp_setDoStatusForce(0x21); + dComIfGp_setDoStatusForce(dActStts_INFO_e); } else { - dComIfGp_setDoStatusForce(0); - dComIfGp_setDoStatus(0); + dComIfGp_setDoStatusForce(dActStts_BLANK_e); + dComIfGp_setDoStatus(dActStts_BLANK_e); } break; } if (mA18[1].mUserArea) { + trans = 10.0f; + mA18[1].mUserArea--; - trans = - fopMsgM_valueIncrease( - 5, - 5 - abs(5 - mA18[1].mUserArea), - 0 - ) * - 10.0f; + s16 amount = 5 - abs(5 - mA18[1].mUserArea); + + trans *= fopMsgM_valueIncrease(5, amount, 0); mainTrans(-trans, 0.0f); subTrans(trans, 0.0f); @@ -1572,10 +1578,11 @@ void dMenu_Collect_c::titleOpenProc(short i_step, short i_max) { void dMenu_Collect_c::noteOpenProc(short i_step, short i_max) { if (i_max >= i_step) { fopMsgM_valueIncrease(i_max, i_step, 0); - float t = fopMsgM_valueIncrease(i_max, i_max - i_step, 0); - float angle = m820.mUserArea + t * (45 - m820.mUserArea); + f32 t = fopMsgM_valueIncrease(i_max, i_max - i_step, 0); + f32 angle = m820.mUserArea + t * (45 - m820.mUserArea); - noteRotate(t * 200.0f, angle); + f32 f1 = t * 200.0f; + noteRotate(f1, angle); fopMsgM_setInitAlpha(&m7B0); fopMsgM_setInitAlpha(&m7E8); @@ -1596,97 +1603,1935 @@ void dMenu_Collect_c::nameOpenProc(short i_step, short i_max) { /* 8019F7C4-8019FE64 .text itemBitCheck__15dMenu_Collect_cFv */ void dMenu_Collect_c::itemBitCheck() { - /* Nonmatching */ + static const u8 melody[6] = { + 0, 1, 2, 3, 4, 5, + }; + + static const u8 triforce[8] = { + 0, 1, 2, 3, 4, 5, 6, 7, + }; + + static const u8 symbol[3] = { + 0, 1, 2, + }; + + static const u8 collect[5] = { + 0, 1, 2, 3, 4, + }; + + /* Baton songs: show/hide each song icon based on whether the song is learned */ + for (int i = 0; i < 6; i++) { + if (dComIfGs_isTact(melody[i])) { + m1498[i].pane->show(); + m15E8[i].pane->show(); + + if (i == 3) { + m1738.pane->show(); + } else if (i == 4) { + m1770.pane->show(); + } + } else { + m1498[i].pane->hide(); + m15E8[i].pane->hide(); + + if (i == 3) { + m1738.pane->hide(); + } else if (i == 4) { + m1770.pane->hide(); + } + } + } + + /* Life containers: show only the number the player has unlocked */ + for (int i = 0; i < 3; i++) { + if (i < dComIfGs_getMaxLife() % 4) { + m13B8[i].pane->show(); + } else { + m13B8[i].pane->hide(); + } + } + + /* Map chart section: hidden unless the map event is set or the collect map count is nonzero */ + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_0908) || dComIfGs_getCollectMapNum() != 0) { + mC48.pane->show(); + mC80.pane->show(); + mCB8.pane->show(); + mCF0.pane->show(); + mD28.pane->show(); + } else { + mC48.pane->hide(); + mC80.pane->hide(); + mCB8.pane->hide(); + mCF0.pane->hide(); + mD28.pane->hide(); + } + + /* Triforce count: store current total and switch the display depending on whether the full triforce has been collected. */ + m27F3 = dComIfGs_getTriforceNum(); + + if (m27F3 == 8 && mCollectMode != 5) { + if (m27F3 != mE08[4].mUserArea) { + for (int i = 0; i < 8; i++) { + if (i == 4) { + mE08[i].pane->show(); + } else { + mE08[i].pane->hide(); + } + } + + ((J2DPicture*)mE08[4].pane)->changeTexture("triforce.bti", 0); + + JKRArchive* r5 = mpArc; + ResTIMG* timg = (ResTIMG*)JKRArchive::getGlbResource('TIMG', "triforce.bti", r5); + + mE08[4].mPosCenterOrig = mFC8.mPosCenterOrig; + mE08[4].mPosCenter = mFC8.mPosCenter; + + mE08[4].mSize.x = timg->width * 1.45f; + mE08[4].mSize.y = timg->height * 1.45f; + + fopMsgM_cposMove(&mE08[4]); + + mE08[4].mUserArea = m27F3; + } + } else { + if (m27F3 != mE08[4].mUserArea) { + JKRArchive* r7 = dComIfGp_getItemIconArchive(); + JKRArchive::readTypeResource( + mTriforceTexBuffer[4], + 0xC00, + 'TIMG', + "triforce_04.bti", + r7 + ); + + #if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mTriforceTexBuffer[4], 0xC00); +#else + DCStoreRangeNoSync(mTriforceTexBuffer[4], 0xC00); +#endif + + ((J2DPicture*)mE08[4].pane)->changeTexture( + mTriforceTexBuffer[4], + 0 + ); + + mE08[4].mPosCenterOrig.x = mFC8.mPosCenterOrig.x - m27A8; + mE08[4].mPosCenterOrig.y = mFC8.mPosCenterOrig.y - m27AC; + + mE08[4].mPosCenter.x = mFC8.mPosCenter.x - m27A8; + mE08[4].mPosCenter.y = mFC8.mPosCenter.y - m27AC; + + mE08[4].mSize = mE08[4].mSizeOrig; + + fopMsgM_cposMove(&mE08[4]); + } + + for (int i = 0; i < 8; i++) { + if (dComIfGs_isTriforce(triforce[i])) { + mE08[i].pane->show(); + } else { + mE08[i].pane->hide(); + } + } + + mE08[4].mUserArea = m27F3; + } + + /* Goddess symbols */ + for (int i = 0; i < 3; i++) { + if (dComIfGs_isSymbol(symbol[i])) { + m1000[i].pane->show(); + m10A8[i].pane->show(); + } else { + m1000[i].pane->hide(); + m10A8[i].pane->hide(); + } + } + + /* Collection items / quest items */ + for (int i = 0; i < 5; i++) { + if (dComIfGs_isCollect(collect[i], 0) || + dComIfGs_isCollect(collect[i], 1) || + dComIfGs_isCollect(collect[i], 2) || + dComIfGs_isCollect(collect[i], 3)) + { + m2030[i].pane->show(); + m2148[i].pane->show(); + m2260[i].pane->show(); + } else { + m2030[i].pane->hide(); + m2148[i].pane->hide(); + m2260[i].pane->hide(); + } + } + + /* Special last collect-item window tint, depending on whether its item is owned */ + if (dComIfGs_isCollect(4, 0) && !dComIfGs_isCollect(4, 1)) { + ((J2DWindow*)m2260[4].pane)->setContentsColor(JUtility::TColor(0x505000FF)); + ((J2DWindow*)m2260[4].pane)->setWhite(JUtility::TColor(0x505050FF)); + ((J2DWindow*)m2260[4].pane)->setBlack(JUtility::TColor(0x50505000)); + } else { + ((J2DWindow*)m2260[4].pane)->setContentsColor(JUtility::TColor(0xFFB400FF)); + ((J2DWindow*)m2260[4].pane)->setWhite(JUtility::TColor(0xFFB400FF)); + ((J2DWindow*)m2260[4].pane)->setBlack(JUtility::TColor(0x50500000)); + + } } /* 8019FE64-801A0194 .text itemScale__15dMenu_Collect_cFv */ void dMenu_Collect_c::itemScale() { - /* Nonmatching */ + int now = mNowItem; + + for (int i = 0; i < 0x15; i++) { + switch (i) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: { + if (i == now) { + fopMsgM_paneScaleXY(&m1498[i], g_menuHIO.field_0x8); + fopMsgM_paneScaleXY(&m15E8[i], g_menuHIO.field_0x8); + } else { + fopMsgM_paneScaleXY(&m1498[i], 1.0f); + fopMsgM_paneScaleXY(&m15E8[i], 1.0f); + } + + if (now == 3) { + m2478->insertChild(m1498[0].pane, m1738.pane); + fopMsgM_paneScaleXY(&m1738, g_menuHIO.field_0x8); + + J2DPane* pane = m1738.pane; + float y = m1738.mSize.y / 2.0f; + float x = m1738.mSize.x / 2.0f; + + pane->mBasePosition.x = x; + pane->mBasePosition.y = y; + pane->mRotationAxis = ROTATE_Z; + pane->calcMtx(); + } else { + m2478->insertChild(m15E8[5].pane, m1738.pane); + fopMsgM_paneScaleXY(&m1738, 1.0f); + + J2DPane* pane = m1738.pane; + float y = m1738.mSize.y / 2.0f; + float x = m1738.mSize.x / 2.0f; + + pane->mBasePosition.x = x; + pane->mBasePosition.y = y; + pane->mRotationAxis = ROTATE_Z; + pane->calcMtx(); + } + + if (now == 4) { + m2478->insertChild(m1498[0].pane, m1770.pane); + fopMsgM_paneScaleXY(&m1770, g_menuHIO.field_0x8); + + J2DPane* pane = m1770.pane; + float y = m1770.mSize.y / 2.0f; + float x = m1770.mSize.x / 2.0f; + + pane->mBasePosition.x = x; + pane->mBasePosition.y = y; + pane->mRotationAxis = ROTATE_Z; + pane->calcMtx(); + } else { + m2478->insertChild(m15E8[5].pane, m1770.pane); + fopMsgM_paneScaleXY(&m1770, 1.0f); + + J2DPane* pane = m1770.pane; + float y = m1770.mSize.y / 2.0f; + float x = m1770.mSize.x / 2.0f; + + pane->mBasePosition.x = x; + pane->mBasePosition.y = y; + pane->mRotationAxis = ROTATE_Z; + pane->calcMtx(); + } + + break; + } + + case 6: + case 7: + case 8: + case 10: + break; + + case 9: + if (i == now) { + fopMsgM_paneScaleXY(&mCF0, g_menuHIO.field_0x8); + fopMsgM_paneScaleXY(&mCF0, g_menuHIO.field_0x8); + } else { + fopMsgM_paneScaleXY(&mCF0, 1.0f); + fopMsgM_paneScaleXY(&mCF0, 1.0f); + } + break; + + case 11: + case 12: + case 13: { + if (i == now) { + fopMsgM_paneScaleXY(&m1000[i - 11], g_menuHIO.field_0x8); + fopMsgM_paneScaleXY(&m10A8[i - 11], g_menuHIO.field_0x8); + } else { + fopMsgM_paneScaleXY(&m1000[i - 11], 1.0f); + fopMsgM_paneScaleXY(&m10A8[i - 11], 1.0f); + } + + break; + } + + case 14: + case 15: + case 16: + case 17: + case 18: { + if (i == now) { + fopMsgM_paneScaleXY(&m2030[i - 14], g_menuHIO.field_0x8); + fopMsgM_paneScaleXY(&m2148[i - 14], g_menuHIO.field_0x8); + } else { + fopMsgM_paneScaleXY(&m2030[i - 14], 1.0f); + fopMsgM_paneScaleXY(&m2148[i - 14], 1.0f); + } + + break; + } + } + } } /* 801A0194-801A05DC .text collectPriority__15dMenu_Collect_cFv */ void dMenu_Collect_c::collectPriority() { - /* Nonmatching */ + m2478->insertChild(mA18[0].pane, mAF8.pane); + m2478->insertChild(mAF8.pane, mB30.pane); + m2478->insertChild(mB30.pane, mB68[3].pane); + m2478->insertChild(mB68[3].pane, mB68[2].pane); + m2478->insertChild(mB68[2].pane, mB68[1].pane); + m2478->insertChild(mB68[1].pane, mB68[0].pane); + m2478->insertChild(mB68[0].pane, mC48.pane); + m2478->insertChild(mC48.pane, mC80.pane); + m2478->insertChild(mC80.pane, mCB8.pane); + m2478->insertChild(mCB8.pane, mCF0.pane); + m2478->insertChild(mCF0.pane, mD28.pane); + m2478->insertChild(mD28.pane, mD60.pane); + m2478->insertChild(mD60.pane, mD98.pane); + m2478->insertChild(mD98.pane, mDD0.pane); + m2478->insertChild(mDD0.pane, mE08[0].pane); + + for (int i = 1; i < 8; i++) { + m2478->insertChild(mE08[i - 1].pane, mE08[i].pane); + } + + m2478->insertChild(mE08[7].pane, mFC8.pane); + m2478->insertChild(mFC8.pane, m1000[0].pane); + m2478->insertChild(m1000[0].pane, m1000[1].pane); + m2478->insertChild(m1000[1].pane, m1000[2].pane); + m2478->insertChild(m1000[2].pane, m10A8[0].pane); + m2478->insertChild(m10A8[0].pane, m10A8[1].pane); + m2478->insertChild(m10A8[1].pane, m10A8[2].pane); + m2478->insertChild(m10A8[2].pane, m1150[0].pane); + + for (int i = 1; i < 11; i++) { + m2478->insertChild(m1150[i - 1].pane, m1150[i].pane); + } + + m2478->insertChild(m1150[10].pane, m13B8[0].pane); + m2478->insertChild(m13B8[0].pane, m13B8[1].pane); + m2478->insertChild(m13B8[1].pane, m13B8[2].pane); + m2478->insertChild(m13B8[2].pane, m1460.pane); + m2478->insertChild(m1460.pane, m1498[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m1498[i - 1].pane, m1498[i].pane); + } + + m2478->insertChild(m1498[5].pane, m15E8[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m15E8[i - 1].pane, m15E8[i].pane); + } + + m2478->insertChild(m15E8[5].pane, m1738.pane); + m2478->insertChild(m1738.pane, m1770.pane); + m2478->insertChild(m1770.pane, m17A8[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m17A8[i - 1].pane, m17A8[i].pane); + } + + m2478->insertChild(m17A8[5].pane, m18F8[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m18F8[i - 1].pane, m18F8[i].pane); + } + + m2478->insertChild(m18F8[5].pane, m1A48[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m1A48[i - 1].pane, m1A48[i].pane); + } + + m2478->insertChild(m1A48[5].pane, m1B98[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m1B98[i - 1].pane, m1B98[i].pane); + } + + m2478->insertChild(m1B98[5].pane, m1CE8[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m1CE8[i - 1].pane, m1CE8[i].pane); + } + + m2478->insertChild(m1CE8[5].pane, m1E38[0].pane); + + for (int i = 1; i < 6; i++) { + m2478->insertChild(m1E38[i - 1].pane, m1E38[i].pane); + } + + m2478->insertChild(m1E38[5].pane, m1FF8.pane); } /* 801A05DC-801A06F4 .text weponPriority__15dMenu_Collect_cFv */ void dMenu_Collect_c::weponPriority() { - /* Nonmatching */ + m2478->insertChild(mA18[0].pane, m2030[0].pane); + + for (int i = 1; i < 5; i++) { + m2478->insertChild(m2030[i - 1].pane, m2030[i].pane); + } + + m2478->insertChild(m2030[4].pane, m2148[0].pane); + + for (int i = 1; i < 5; i++) { + m2478->insertChild(m2148[i - 1].pane, m2148[i].pane); + } + + m2478->insertChild(m2148[4].pane, m2260[0].pane); + m2478->insertChild(m2260[0].pane, m2260[1].pane); + m2478->insertChild(m2260[1].pane, m2260[2].pane); + m2478->insertChild(m2260[2].pane, m2260[3].pane); + m2478->insertChild(m2260[3].pane, m2260[4].pane); + m2478->insertChild(m2260[4].pane, m2378.pane); + m2478->insertChild(m2378.pane, m2420.pane); } /* 801A06F4-801A0A4C .text tactGuideShow__15dMenu_Collect_cFUcb */ -void dMenu_Collect_c::tactGuideShow(unsigned char, bool) { - /* Nonmatching */ +void dMenu_Collect_c::tactGuideShow(u8 i_song, bool i_fadeIn) { + static const s16 rotate_angle[5] = { + 225, + 225, + 135, + 45, + 315, + }; + + float rightOffset; + float xOffset = 0.0f; + + if (tact_beat[i_song] == 3) { + xOffset = (m17A8[1].mPosCenterOrig.x - m17A8[0].mPosCenterOrig.x) * 1.5f; + } else if (tact_beat[i_song] == 4) { + xOffset = m17A8[1].mPosCenterOrig.x - m17A8[0].mPosCenterOrig.x; + } + + s32 pattern[6]; + + for (int i = 0; i < 6; i++) { + m1498[i].mUserArea = mDoAud_tact_getMelodyPattern(i_song, i, &pattern[i]); + + if (i_fadeIn && i < tact_beat[i_song]) { + fopMsgM_setInitAlpha(&m17A8[i]); + fopMsgM_setInitAlpha(&m18F8[i]); + fopMsgM_setInitAlpha(&m1A48[i]); + fopMsgM_setInitAlpha(&m1B98[i]); + fopMsgM_setInitAlpha(&m1CE8[i]); + fopMsgM_setInitAlpha(&m1E38[i]); + } + + if (i < tact_beat[i_song]) { + m1E38[i].pane->show(); + } + } + + int i = 0; + int patternOffset = 0; + int paneOffset = 0; + + rightOffset = xOffset + 7.0f; + + for (; i < tact_beat[i_song]; + i++, patternOffset += 4, paneOffset += 0x38) { + if (m1E38[i].mUserArea == 1) { + + m1A48[i].pane->rotate( + m1A48[i].mSizeOrig.x / 2.0f, + m1A48[i].mSizeOrig.y / 2.0f, + ROTATE_Z, + rotate_angle[pattern[i]] + ); + + if (pattern[i] == 0) { + m17A8[i].pane->show(); + m18F8[i].pane->show(); + m1A48[i].pane->show(); + m1B98[i].pane->show(); + m1CE8[i].pane->show(); + m1E38[i].pane->show(); + + fopMsgM_paneTrans(&m17A8[i], xOffset, 0.0f); + } else { + m17A8[i].pane->show(); + m18F8[i].pane->show(); + m1A48[i].pane->show(); + m1B98[i].pane->hide(); + m1CE8[i].pane->show(); + m1E38[i].pane->show(); + + switch (pattern[i]) { + case 1: + fopMsgM_paneTrans( &m17A8[i], xOffset, -7.0f); + break; + + case 2: + fopMsgM_paneTrans(&m17A8[i], rightOffset, 0.0f); + break; + + case 3: + fopMsgM_paneTrans( &m17A8[i], xOffset, 7.0f); + break; + + case 4: + fopMsgM_paneTrans(&m17A8[i], xOffset - 7.0f, 0.0f); + break; + } + } + + fopMsgM_paneTrans(&m18F8[i], xOffset, 0.0f); + fopMsgM_paneTrans(&m1A48[i], xOffset, 0.0f); + fopMsgM_paneTrans(&m1B98[i], xOffset, 0.0f); + fopMsgM_paneTrans(&m1CE8[i], xOffset, 0.0f); + fopMsgM_paneTrans(&m1E38[i], xOffset, 0.0f); + } + } } /* 801A0A4C-801A0C58 .text tactDemoMode__15dMenu_Collect_cFUc */ -void dMenu_Collect_c::tactDemoMode(unsigned char) { - /* Nonmatching */ +void dMenu_Collect_c::tactDemoMode(u8) { + s16 stepMark[8]; + + stepMark[0] = 0; + stepMark[1] = m1498[0].mUserArea; + stepMark[2] = stepMark[1] + m1498[1].mUserArea; + stepMark[3] = stepMark[2] + m1498[2].mUserArea; + stepMark[4] = stepMark[3] + m1498[3].mUserArea; + stepMark[5] = stepMark[4] + m1498[4].mUserArea; + stepMark[6] = stepMark[5] + m1498[5].mUserArea; + stepMark[7] = stepMark[6] + 10; + + if (cursorMainMove()) { + itemScale(); + + if (collectItemGetCheck(mNowItem)) { + itemnameMove(); + } else { + fopMsgM_setNowAlphaZero(&m890[0]); + fopMsgM_setNowAlphaZero(&m890[1]); + fopMsgM_setNowAlphaZero(&m858); + } + + mDoAud_tact_melodyStop(); + outFontMove(); + mCollectMode = 0; + } else { + s16 counter = m15E8[0].mUserArea; + + if (counter < stepMark[6]) { + m15E8[0].mUserArea = counter + 1; + + for (int i = 0; i < 6; i++) { + if (stepMark[i] <= m15E8[0].mUserArea) { + m1E38[i].mUserArea = 1; + } else { + m1E38[i].mUserArea = 0; + } + } + + tactGuideShow(mNowItem, true); + } else if (counter < stepMark[7]) { + m15E8[0].mUserArea = counter + 1; + + for (int i = 0; i < 6; i++) { + m1E38[i].mUserArea = 1; + } + } else { + for (int i = 0; i < 6; i++) { + m1E38[i].mUserArea = 0; + } + + m15E8[0].mUserArea = 0; + tactGuideShow(mNowItem, true); + mCollectMode = 2; + + dComIfGp_setAStatusForce(dActStts_BLANK_e); + } + } + + dComIfGp_setAStatusForce(dActStts_RETURN_e); } /* 801A0C58-801A1344 .text tactPlayMode__15dMenu_Collect_cFUc */ -void dMenu_Collect_c::tactPlayMode(unsigned char) { - /* Nonmatching */ +void dMenu_Collect_c::tactPlayMode(u8 i_song) { + static const s16 rotate_angle[5] = { + 225, + 225, + 135, + 45, + 315, + }; + + s32 pattern[6]; + f32 xOffset = 0.0f; + if (m15E8[0].mUserArea < tact_beat[i_song]) { + s32 temp = tact_beat[i_song]; + + if (temp == 3) { + xOffset = (m17A8[1].mPosCenterOrig.x - m17A8[0].mPosCenterOrig.x) * 1.5f; + mDoAud_tact_setBeat(0); + } else if (temp == 4) { + xOffset = m17A8[1].mPosCenterOrig.x - m17A8[0].mPosCenterOrig.x; + mDoAud_tact_setBeat(4); + } else { + mDoAud_tact_setBeat(2); + } + + for (int i = 0; i < 6; i++) { + m1498[i].mUserArea = + mDoAud_tact_getMelodyPattern( + i_song, + i, + &pattern[i] + ); + + if (i < tact_beat[i_song]) { + if (i < m15E8[0].mUserArea) { + fopMsgM_setInitAlpha(&m17A8[i]); + fopMsgM_setInitAlpha(&m18F8[i]); + fopMsgM_setInitAlpha(&m1A48[i]); + fopMsgM_setInitAlpha(&m1B98[i]); + fopMsgM_setInitAlpha(&m1CE8[i]); + } else { + fopMsgM_setNowAlpha(&m17A8[i], 0.5f); + fopMsgM_setNowAlpha(&m18F8[i], 0.5f); + fopMsgM_setNowAlpha(&m1A48[i], 0.5f); + fopMsgM_setNowAlpha(&m1B98[i], 0.5f); + fopMsgM_setNowAlpha(&m1CE8[i], 0.5f); + } + + fopMsgM_setInitAlpha(&m1E38[i]); + } + + if (i < tact_beat[i_song]) { + m1E38[i].pane->show(); + } + } + + s32 direction = mDoAud_getTactDirection(0, m27DC); + + bool inputReady = false; + + if (direction != m27DC) { + m27DC = direction; + + if (direction != 0) { + inputReady = true; + m27E4 = 0; + } else { + if (pattern[m15E8[0].mUserArea] == 0) { + m27E4 = g_mcHIO.m44; + } else { + m27E4 = 0; + } + } + } else if (direction == 0) { + if (m27E4 > 0) { + m27E4--; + + if (m27E4 == 0) { + inputReady = true; + } + } + } else { + m27E4 = 0; + } + + if (inputReady) { + mDoAud_tact_judge( + m15E8[0].mUserArea, + m27DC + ); + + if (m27DC == pattern[m15E8[0].mUserArea]) { + m1E38[m15E8[0].mUserArea].mUserArea = 1; + m15E8[0].mUserArea++; + + if (m15E8[0].mUserArea == tact_beat[i_song]) { + m27E4 = 10; + } + + for (int i = 0; i < tact_beat[i_song]; i++) { + f32 rightOffset = xOffset + 7.0f; + + if (m1E38[i].mUserArea == 1) { + m1A48[i].pane->rotate( + m1A48[i].mSizeOrig.x / 2.0f, + m1A48[i].mSizeOrig.y / 2.0f, + ROTATE_Z, + rotate_angle[pattern[i]] + ); + + if (pattern[i] == 0) { + m17A8[i].pane->show(); + m18F8[i].pane->show(); + m1A48[i].pane->show(); + m1B98[i].pane->show(); + m1CE8[i].pane->show(); + m1E38[i].pane->show(); + + fopMsgM_paneTrans( + &m17A8[i], + xOffset, + 0.0f + ); + } else { + m17A8[i].pane->show(); + m18F8[i].pane->show(); + m1A48[i].pane->show(); + m1B98[i].pane->hide(); + m1CE8[i].pane->show(); + m1E38[i].pane->show(); + + switch (pattern[i]) { + case 1: + fopMsgM_paneTrans( + &m17A8[i], + xOffset, + -7.0f + ); + break; + + case 2: + fopMsgM_paneTrans( + &m17A8[i], + rightOffset, + 0.0f + ); + break; + + case 3: + fopMsgM_paneTrans( + &m17A8[i], + xOffset, + 7.0f + ); + break; + + case 4: + fopMsgM_paneTrans( + &m17A8[i], + xOffset - 7.0f, + 0.0f + ); + break; + } + } + + fopMsgM_paneTrans( + &m18F8[i], + xOffset, + 0.0f + ); + + fopMsgM_paneTrans( + &m1A48[i], + xOffset, + 0.0f + ); + + fopMsgM_paneTrans( + &m1B98[i], + xOffset, + 0.0f + ); + + fopMsgM_paneTrans( + &m1CE8[i], + xOffset, + 0.0f + ); + + fopMsgM_paneTrans( + &m1E38[i], + xOffset, + 0.0f + ); + + fopMsgM_setInitAlpha(&m17A8[i]); + fopMsgM_setInitAlpha(&m18F8[i]); + fopMsgM_setInitAlpha(&m1A48[i]); + fopMsgM_setInitAlpha(&m1B98[i]); + fopMsgM_setInitAlpha(&m1CE8[i]); + } + } + } else { + for (int i = 0; i < 6; i++) { + m1E38[i].mUserArea = 0; + } + + m15E8[0].mUserArea = 0; + mDoAud_seStart(JA_SE_COLL_TAKT_WRONG); + } + } + + if (CPad_CHECK_TRIG_A(0)) { + mCollectMode = 1; + m15E8[0].mUserArea = 0; + + tactGuideHide(); + + for (int i = 0; i < 6; i++) { + if (i < tact_beat[mNowItem]) { + m1E38[i].pane->show(); + } + } + + mDoAud_tact_melodyPlay(mNowItem); + } else if (cursorMainMove()) { + itemScale(); + + if (collectItemGetCheck(mNowItem)) { + itemnameMove(); + } else { + fopMsgM_setNowAlphaZero(&m890[0]); + fopMsgM_setNowAlphaZero(&m890[1]); + fopMsgM_setNowAlphaZero(&m858); + } + + outFontMove(); + mCollectMode = 0; + } + } else { + if (--m27E4 <= 0) { + mDoAud_seStart(JA_SE_COLL_TAKT_RIGHT); + + for (int i = 0; i < 6; i++) { + m1E38[i].mUserArea = 0; + } + + m15E8[0].mUserArea = 0; + + tactGuideShow(mNowItem, true); + mCollectMode = 2; + } + } } /* 801A1344-801A1598 .text tactTrans__15dMenu_Collect_cFUcff */ -void dMenu_Collect_c::tactTrans(unsigned char, float, float) { - /* Nonmatching */ +void dMenu_Collect_c::tactTrans(u8 i_song, f32 i_transX, f32 i_transY) { + f32 y = i_transY; + f32 x = i_transX; + + if (tact_beat[i_song] == 3) { + x += (m17A8[1].mPosCenterOrig.x - m17A8[0].mPosCenterOrig.x) * 1.5f; + } else if (tact_beat[i_song] == 4) { + x += (m17A8[1].mPosCenterOrig.x - m17A8[0].mPosCenterOrig.x); + } + + s32 pattern[6]; + + for (int i = 0; i < 6; i++) { + m1498[i].mUserArea = (s16)mDoAud_tact_getMelodyPattern(i_song, i, &pattern[i]); + } + + for (int i = 0; i < tact_beat[i_song]; i++) { + int dir = pattern[i]; + + switch (dir) { + case 0: + fopMsgM_paneTrans(&m17A8[i], x, y); + break; + case 1: + fopMsgM_paneTrans(&m17A8[i], x, y - 7.0f); + break; + case 2: + fopMsgM_paneTrans(&m17A8[i], x + 7.0f, y); + break; + case 3: + fopMsgM_paneTrans(&m17A8[i], x, y + 7.0f); + break; + case 4: + fopMsgM_paneTrans(&m17A8[i], x - 7.0f, y); + break; + } + + fopMsgM_paneTrans(&m18F8[i], x, y); + fopMsgM_paneTrans(&m1A48[i], x, y); + fopMsgM_paneTrans(&m1B98[i], x, y); + fopMsgM_paneTrans(&m1CE8[i], x, y); + fopMsgM_paneTrans(&m1E38[i], x, y); + } } /* 801A1598-801A1600 .text tactBaseShow__15dMenu_Collect_cFv */ void dMenu_Collect_c::tactBaseShow() { - /* Nonmatching */ + for (int i = 0; i < 6; i++) { + fopMsgM_paneTrans(&m1E38[i], 0.0f, 0.0f); + m1E38[i].pane->show(); + } } /* 801A1600-801A2958 .text cornerMove__15dMenu_Collect_cFv */ void dMenu_Collect_c::cornerMove() { - /* Nonmatching */ + int r4 = 0xF0; + J2DWindow::TContentsColor outColor; + JUtility::TColor sp1C; + + m27E6++; + + if (m27E6 >= r4) { + m27E6 = 0; + } + + int r4_2 = m27E6 % 60; + f32 t = fopMsgM_valueIncrease(60, r4_2, 2); + + if (m27E6 < 60) { + outColor.mTL.r = m2488.mTL.r + (m2488.mBL.r - m2488.mTL.r) * t; + outColor.mTL.g = m2488.mTL.g + (m2488.mBL.g - m2488.mTL.g) * t; + outColor.mTL.b = m2488.mTL.b + (m2488.mBL.b - m2488.mTL.b) * t; + outColor.mTL.a = m2488.mTL.a + (m2488.mBL.a - m2488.mTL.a) * t; + outColor.mTR.r = m2488.mTR.r + (m2488.mTL.r - m2488.mTR.r) * t; + outColor.mTR.g = m2488.mTR.g + (m2488.mTL.g - m2488.mTR.g) * t; + outColor.mTR.b = m2488.mTR.b + (m2488.mTL.b - m2488.mTR.b) * t; + outColor.mTR.a = m2488.mTR.a + (m2488.mTL.a - m2488.mTR.a) * t; + outColor.mBL.r = m2488.mBL.r + (m2488.mBR.r - m2488.mBL.r) * t; + outColor.mBL.g = m2488.mBL.g + (m2488.mBR.g - m2488.mBL.g) * t; + outColor.mBL.b = m2488.mBL.b + (m2488.mBR.b - m2488.mBL.b) * t; + outColor.mBL.a = m2488.mBL.a + (m2488.mBR.a - m2488.mBL.a) * t; + outColor.mBR.r = m2488.mBR.r + (m2488.mTR.r - m2488.mBR.r) * t; + outColor.mBR.g = m2488.mBR.g + (m2488.mTR.g - m2488.mBR.g) * t; + outColor.mBR.b = m2488.mBR.b + (m2488.mTR.b - m2488.mBR.b) * t; + outColor.mBR.a = m2488.mBR.a + (m2488.mTR.a - m2488.mBR.a) * t; + } else if (m27E6 < 120) { + outColor.mTR.r = m2488.mTL.r + (m2488.mBL.r - m2488.mTL.r) * t; + outColor.mTR.g = m2488.mTL.g + (m2488.mBL.g - m2488.mTL.g) * t; + outColor.mTR.b = m2488.mTL.b + (m2488.mBL.b - m2488.mTL.b) * t; + outColor.mTR.a = m2488.mTL.a + (m2488.mBL.a - m2488.mTL.a) * t; + outColor.mBR.r = m2488.mTR.r + (m2488.mTL.r - m2488.mTR.r) * t; + outColor.mBR.g = m2488.mTR.g + (m2488.mTL.g - m2488.mTR.g) * t; + outColor.mBR.b = m2488.mTR.b + (m2488.mTL.b - m2488.mTR.b) * t; + outColor.mBR.a = m2488.mTR.a + (m2488.mTL.a - m2488.mTR.a) * t; + outColor.mTL.r = m2488.mBL.r + (m2488.mBR.r - m2488.mBL.r) * t; + outColor.mTL.g = m2488.mBL.g + (m2488.mBR.g - m2488.mBL.g) * t; + outColor.mTL.b = m2488.mBL.b + (m2488.mBR.b - m2488.mBL.b) * t; + outColor.mTL.a = m2488.mBL.a + (m2488.mBR.a - m2488.mBL.a) * t; + outColor.mBL.r = m2488.mBR.r + (m2488.mTR.r - m2488.mBR.r) * t; + outColor.mBL.g = m2488.mBR.g + (m2488.mTR.g - m2488.mBR.g) * t; + outColor.mBL.b = m2488.mBR.b + (m2488.mTR.b - m2488.mBR.b) * t; + outColor.mBL.a = m2488.mBR.a + (m2488.mTR.a - m2488.mBR.a) * t; + } else if (m27E6 < 180) { + outColor.mBR.r = m2488.mTL.r + (m2488.mBL.r - m2488.mTL.r) * t; + outColor.mBR.g = m2488.mTL.g + (m2488.mBL.g - m2488.mTL.g) * t; + outColor.mBR.b = m2488.mTL.b + (m2488.mBL.b - m2488.mTL.b) * t; + outColor.mBR.a = m2488.mTL.a + (m2488.mBL.a - m2488.mTL.a) * t; + outColor.mBL.r = m2488.mTR.r + (m2488.mTL.r - m2488.mTR.r) * t; + outColor.mBL.g = m2488.mTR.g + (m2488.mTL.g - m2488.mTR.g) * t; + outColor.mBL.b = m2488.mTR.b + (m2488.mTL.b - m2488.mTR.b) * t; + outColor.mBL.a = m2488.mTR.a + (m2488.mTL.a - m2488.mTR.a) * t; + outColor.mTR.r = m2488.mBL.r + (m2488.mBR.r - m2488.mBL.r) * t; + outColor.mTR.g = m2488.mBL.g + (m2488.mBR.g - m2488.mBL.g) * t; + outColor.mTR.b = m2488.mBL.b + (m2488.mBR.b - m2488.mBL.b) * t; + outColor.mTR.a = m2488.mBL.a + (m2488.mBR.a - m2488.mBL.a) * t; + outColor.mTL.r = m2488.mBR.r + (m2488.mTR.r - m2488.mBR.r) * t; + outColor.mTL.g = m2488.mBR.g + (m2488.mTR.g - m2488.mBR.g) * t; + outColor.mTL.b = m2488.mBR.b + (m2488.mTR.b - m2488.mBR.b) * t; + outColor.mTL.a = m2488.mBR.a + (m2488.mTR.a - m2488.mBR.a) * t; + } else { + outColor.mBL.r = m2488.mTL.r + (m2488.mBL.r - m2488.mTL.r) * t; + outColor.mBL.g = m2488.mTL.g + (m2488.mBL.g - m2488.mTL.g) * t; + outColor.mBL.b = m2488.mTL.b + (m2488.mBL.b - m2488.mTL.b) * t; + outColor.mBL.a = m2488.mTL.a + (m2488.mBL.a - m2488.mTL.a) * t; + outColor.mTL.r = m2488.mTR.r + (m2488.mTL.r - m2488.mTR.r) * t; + outColor.mTL.g = m2488.mTR.g + (m2488.mTL.g - m2488.mTR.g) * t; + outColor.mTL.b = m2488.mTR.b + (m2488.mTL.b - m2488.mTR.b) * t; + outColor.mTL.a = m2488.mTR.a + (m2488.mTL.a - m2488.mTR.a) * t; + outColor.mBR.r = m2488.mBL.r + (m2488.mBR.r - m2488.mBL.r) * t; + outColor.mBR.g = m2488.mBL.g + (m2488.mBR.g - m2488.mBL.g) * t; + outColor.mBR.b = m2488.mBL.b + (m2488.mBR.b - m2488.mBL.b) * t; + outColor.mBR.a = m2488.mBL.a + (m2488.mBR.a - m2488.mBL.a) * t; + outColor.mTR.r = m2488.mBR.r + (m2488.mTR.r - m2488.mBR.r) * t; + outColor.mTR.g = m2488.mBR.g + (m2488.mTR.g - m2488.mBR.g) * t; + outColor.mTR.b = m2488.mBR.b + (m2488.mTR.b - m2488.mBR.b) * t; + outColor.mTR.a = m2488.mBR.a + (m2488.mTR.a - m2488.mBR.a) * t; + } + + ((J2DWindow*)mB68[1].pane)->setContentsColor(outColor); + + m27E8++; + + if (m27E8 >= g_mcHIO.m50 * 2) { + m27E8 = 0; + } + + f32 pulse; + + if (m27E8 < g_mcHIO.m50) { + pulse = fopMsgM_valueIncrease( + g_mcHIO.m50, + m27E8, + 0 + ); + } else { + pulse = fopMsgM_valueIncrease( + g_mcHIO.m50, + g_mcHIO.m50 * 2 - m27E8, + 0 + ); + } + + f32 f2 = 255.0f; + f32 f0 = (f2 - g_mcHIO.m58.r); + f0 *= pulse; + sp1C.r = f2 - f0; + sp1C.g = 128.0f - (128.0f - g_mcHIO.m58.g) * pulse; + sp1C.b = -(-(f32)g_mcHIO.m58.b * pulse); + sp1C.a = 0xFF; + ((J2DWindow*)mB68[1].pane)->setWhite(sp1C); } /* 801A2958-801A2A4C .text triforceAnime__15dMenu_Collect_cFUc */ -void dMenu_Collect_c::triforceAnime(unsigned char) { - /* Nonmatching */ +void dMenu_Collect_c::triforceAnime(u8 i_maxAlpha) { + s16 halfPeriod = g_mcHIO.m4E; + + mDD0.mUserArea++; + + if (mDD0.mUserArea >= halfPeriod * 2) { + mDD0.mUserArea = 0; + } + + if (halfPeriod > mDD0.mUserArea) { + mDD0.mNowAlpha = i_maxAlpha * fopMsgM_valueIncrease(halfPeriod, mDD0.mUserArea, 0); + } else if (halfPeriod * 2 > mDD0.mUserArea) { + mDD0.mNowAlpha = i_maxAlpha * fopMsgM_valueIncrease(halfPeriod, halfPeriod * 2 - mDD0.mUserArea, 0); + } } /* 801A2A4C-801A2AC8 .text tactGuideHide__15dMenu_Collect_cFv */ void dMenu_Collect_c::tactGuideHide() { - /* Nonmatching */ + for(int i = 0; i < 6; i++) { + m1E38[i].mUserArea = 0; + + m17A8[i].pane->hide(); + m18F8[i].pane->hide(); + m1A48[i].pane->hide(); + m1B98[i].pane->hide(); + m1CE8[i].pane->hide(); + m1E38[i].pane->hide(); + } } /* 801A2AC8-801A2CA4 .text itemnameMove__15dMenu_Collect_cFv */ void dMenu_Collect_c::itemnameMove() { - /* Nonmatching */ + u8 now_item = mNowItem; + + switch (now_item) { + case 0x12: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: { + m858.mUserArea++; + + if (m858.mUserArea > 0x82) { + m858.mUserArea = 0x0B; + } + + int timer = m858.mUserArea; + int temp; + + if (timer <= 10) { + float t = fopMsgM_valueIncrease(10, timer, 0); + fopMsgM_setNowAlpha(&m890[0], t); + fopMsgM_setNowAlpha(&m890[1], 1.0f - t); + fopMsgM_setNowAlphaZero(&m858); + } else if (timer <= 60) { + fopMsgM_setInitAlpha(&m890[0]); + fopMsgM_setNowAlphaZero(&m858); + } else if (timer <= 70) { + temp = timer - 60; + float t = fopMsgM_valueIncrease( 10, temp, 0); + fopMsgM_setNowAlpha(&m890[0], 1.0f - t); + fopMsgM_setNowAlpha(&m858, t); + } else if (timer <= 120) { + fopMsgM_setNowAlphaZero(&m890[0]); + fopMsgM_setInitAlpha(&m858); + } else if (timer <= 130) { + temp = timer - 120; + float t = fopMsgM_valueIncrease(10, temp, 0); + fopMsgM_setNowAlpha(&m890[0], t); + fopMsgM_setNowAlpha(&m858, 1.0f - t); + } + + outFont->move(); + break; + } + default: { + s16 timer = m858.mUserArea; + + if (timer < 10) { + m858.mUserArea = timer + 1; + } + + int alpha_timer = m858.mUserArea; + + if (alpha_timer <= 10) { + float t = fopMsgM_valueIncrease(10, alpha_timer, 0); + fopMsgM_setNowAlpha(&m890[0], t); + fopMsgM_setNowAlpha(&m890[1], 1.0f - t); + fopMsgM_setNowAlphaZero(&m858); + } else { + fopMsgM_setInitAlpha(&m890[0]); + fopMsgM_setNowAlphaZero(&m890[1]); + fopMsgM_setNowAlphaZero(&m858); + } + } + } } /* 801A2CA4-801A36AC .text itemnameSet__15dMenu_Collect_cFv */ void dMenu_Collect_c::itemnameSet() { /* Nonmatching */ + fopMsgM_itemMsgGet_c msgGet; + u32 msgNo = 0; + int i = 0; + + J2DTextBox::TFontSize copiedFontSize; + J2DTextBox::TFontSize nameFontSize; + J2DTextBox::TFontSize initialFontSize; + + initialFontSize.mSizeY = 29.0f; + initialFontSize.mSizeX = 29.0f; + + ((J2DTextBox*)m858.pane)->setFontSize(initialFontSize); + + ((J2DTextBox*)m890[0].pane)->getFontSize(copiedFontSize); + ((J2DTextBox*)m890[1].pane)->setFontSize(copiedFontSize); + + ((J2DTextBox*)m890[1].pane)->setCharSpace(((J2DTextBox*)m890[0].pane)->getCharSpace()); + + while (name[0][i] != '\0') { + name[1][i] = name[0][i]; + i++; + } + + name[1][i] = '\0'; + + ((J2DTextBox*)m890[1].pane)->setString(name[1]); + strcpy(name[0], ""); + + if (mCollectMode != 5) { + switch (mNowItem) { + case 0: + if (dComIfGs_isTact(0)) { + msgNo = dItem_data::getItemMesgNum(109); + + outFont->messageSet(0x1FA); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + } + break; + + case 1: + if (dComIfGs_isTact(1)) { + msgNo = dItem_data::getItemMesgNum(110); + + outFont->messageSet(0x1FA); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + } + break; + + case 2: + if (dComIfGs_isTact(2)) { + msgNo = dItem_data::getItemMesgNum(112); + + outFont->messageSet(0x1FA); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + } + break; + + case 3: + if (dComIfGs_isTact(3)) { + msgNo = dItem_data::getItemMesgNum(113); + + outFont->messageSet(0x1FA); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + } + break; + + case 4: + if (dComIfGs_isTact(4)) { + msgNo = dItem_data::getItemMesgNum(114); + + outFont->messageSet(0x1FA); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + } + break; + + case 5: + if (dComIfGs_isTact(5)) { + msgNo = dItem_data::getItemMesgNum(111); + + outFont->messageSet(0x1FA); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + } + break; + + case 6: + msgNo = 0x19D; + + outFont->messageSet(0x1FB); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + break; + + case 7: + msgNo = 0x1F8; + + outFont->messageSet(0x1FC); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + break; + + case 8: + if (dComIfGs_getMaxLife() % 4 != 0) { + msgNo = dItem_data::getItemMesgNum(7); + } + break; + + case 9: + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_0908) || + dComIfGs_getCollectMapNum() != 0) { + msgNo = 0x1F7; + } + break; + + case 10: + if (dComIfGs_getTriforceNum() == 8) { + msgNo = 0x1C4; + } else if (dComIfGs_getTriforceNum() == 0) { + msgNo = 0; + } else { + msgNo = dItem_data::getItemMesgNum(97); + } + break; + + case 0x0B: + if (dComIfGs_isSymbol(0)) { + msgNo = dItem_data::getItemMesgNum(105); + } + break; + + case 0x0C: + if (dComIfGs_isSymbol(1)) { + msgNo = dItem_data::getItemMesgNum(106); + } + break; + + case 0x0D: + if (dComIfGs_isSymbol(2)) { + msgNo = dItem_data::getItemMesgNum(107); + } + break; + + case 0x0E: { + u32 equipMsg = dItem_data::getItemMesgNum(dComIfGs_getSelectEquip(0)); + + msgNo = equipMsg; + + if (equipMsg == 0) { + msgNo = 0; + } + break; + } + + case 0x0F: { + u32 equipMsg = dItem_data::getItemMesgNum(dComIfGs_getSelectEquip(1)); + + msgNo = equipMsg; + + if (equipMsg == 0) { + msgNo = 0; + } + break; + } + + case 0x10: { + u32 equipMsg = dItem_data::getItemMesgNum(dComIfGs_getSelectEquip(2)); + + msgNo = equipMsg; + + if (equipMsg == 0) { + msgNo = 0; + } + break; + } + + case 0x11: + if (dComIfGs_isCollect(3, 0)) { + msgNo = dItem_data::getItemMesgNum(66); + } + break; + + case 0x12: + if (dComIfGs_isCollect(4, 0)) { + msgNo = dItem_data::getItemMesgNum(67); + + outFont->messageSet(0x1FD); + outFont->setLeftUpPos( + m858.mPosTopLeft.x, + m858.mPosTopLeft.y + ); + } + break; + + case 0x13: + if (!dComIfGs_isTact(0) && + !dComIfGs_isTact(1) && + !dComIfGs_isTact(2) && + !dComIfGs_isTact(3) && + !dComIfGs_isTact(4) && + !dComIfGs_isTact(5)) { + msgNo = 0; + } else { + msgNo = 0; + } + break; + + case 0x14: + if (!dComIfGs_isSymbol(0) && + !dComIfGs_isSymbol(1) && + !dComIfGs_isSymbol(2)) { + msgNo = 0; + } else { + msgNo = 0; + } + break; + } + } else { + msgNo = (s16)(mNowItem + 0x1C2); + } + + if (msgNo == 0) { + ((J2DTextBox*)m890[0].pane)->setString(name[0]); + return; + } + + JUTFont::TWidth width; + JUTFont::TWidth firstWidth; + u8 characterWidth; + + mesg_header* head_p = msgGet.getMesgHeader(msgNo); + JUT_ASSERT(VERSION_SELECT(0xBD1, 0xBD1, 0xBD1, 0xBD1), head_p); + + ((J2DTextBox*)m890[0].pane)->getFontSize(nameFontSize); + nameFontSize.mSizeX = nameFontSize.mSizeY; + + const char* mesg = msgGet.getMessage(head_p); + const char* current; + + bool firstCharacter = false; + + f32 fontScale = nameFontSize.mSizeY / mpFont->getCellWidth(); + + f32 measuredWidth; + + current = mesg; + + while (*current != '\0') { + char appendBuf[3]; + + appendBuf[0] = appendBuf[1] = appendBuf[2] = '\0'; + + if ((u8)current[0] == 0x1A) { + // Control code. + current++; + int codeLen = *current; + current += codeLen - 1; + continue; + } + + int c; + + int hi_nibble = ((u8)current[0] >> 4) & 0xF; + if ((hi_nibble == 8) || (hi_nibble == 9)) { + // Multi-byte Shift JIS character. + int hi = (u8)current++[0]; + int lo = (u8)current++[0]; + c = hi << 8 | lo; + + appendBuf[0] = hi; + appendBuf[1] = lo; + appendBuf[2] = '\0'; + } else { + c = (u8)current++[0]; + appendBuf[0] = c; + appendBuf[1] = '\0'; + } + + mpFont->getWidthEntry(c, &width); + + characterWidth = width.field_0x1; + + strcat(name[0], appendBuf); + + if (!firstCharacter) { + mpFont->getWidthEntry(c, &firstWidth); + + measuredWidth = fontScale * (characterWidth + firstWidth.field_0x0); + + firstCharacter = true; + } else { + measuredWidth += (s16)characterWidth * fontScale; + } + } + + f32 paneWidth = ((J2DTextBox*)m890[0].pane)->getBounds().f.x - ((J2DTextBox*)m890[0].pane)->getBounds().i.x; + + if (paneWidth < measuredWidth) { + nameFontSize.mSizeX = (s32)((nameFontSize.mSizeX * paneWidth) / measuredWidth); + } + + ((J2DTextBox*)m890[0].pane)->setFontSize(nameFontSize); + ((J2DTextBox*)m890[0].pane)->setCharSpace(0.0f); + ((J2DTextBox*)m890[0].pane)->setString(name[0]); } /* 801A36AC-801A42D0 .text itemnoteSet__15dMenu_Collect_cFv */ void dMenu_Collect_c::itemnoteSet() { - /* Nonmatching */ + /* Nonmatching - regswap */ + fopMsgM_itemMsgGet_c msgGet; + int triforceCount; + u32 msgNo; + + msgNo = 0; + triforceCount = 0; + + if (dComIfGs_getOptRuby() != 0) { + fopMsgM_paneTrans(&m778, 0.0f, -4.0f); + } else { + fopMsgM_paneTrans(&m778, 0.0f, 0.0f); + } + + strcpy(note[0], ""); + strcpy(note[1], ""); + strcpy(dummy[0], ""); + strcpy(dummy[1], ""); + + outFontInit(); + + if (dComIfGs_getOptRuby() != 0) { + m740.pane->hide(); + } else { + m740.pane->show(); + } + + f32 rubyFontSize = ((J2DTextBox*)m740.pane)->mFontSizeX; + +#if VERSION == VERSION_DEMO + f32 f30 = ((J2DTextBox*)m778.pane)->mFontSizeX; +#else + J2DTextBox::TFontSize msgFontSize; + msgFontSize.mSizeX = g_msgHIO.field_0x70; + msgFontSize.mSizeY = g_msgHIO.field_0x70; + + ((J2DTextBox*)m778.pane)->setFontSize(msgFontSize); + ((J2DTextBox*)m778.pane)->setLineSpace(g_msgHIO.field_0x5e); +#endif + + switch (mNowItem) { + case 0: + if (dComIfGs_isTact(0)) { + msgNo = dItem_data::getItemMesgNum(109) + 200; + } + break; + + case 1: + if (dComIfGs_isTact(1)) { + msgNo = dItem_data::getItemMesgNum(110) + 200; + } + break; + + case 2: + if (dComIfGs_isTact(2)) { + msgNo = dItem_data::getItemMesgNum(111) + 200; + } + break; + + case 3: + if (dComIfGs_isTact(3)) { + msgNo = dItem_data::getItemMesgNum(112) + 200; + } + break; + + case 4: + if (dComIfGs_isTact(4)) { + msgNo = dItem_data::getItemMesgNum(113) + 200; + } + break; + + case 5: + if (dComIfGs_isTact(5)) { + msgNo = dItem_data::getItemMesgNum(114) + 200; + } + break; + + case 6: + msgNo = 0x265; + break; + + case 7: + msgNo = 0x2C0; + break; + + case 8: + if (dComIfGs_getMaxLife() % 4 != 0) { + msgNo = dItem_data::getItemMesgNum(7) + 200; + } + break; + + case 9: + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_0908) || + dComIfGs_getCollectMapNum() != 0) { + msgNo = 0x2BF; + } + break; + + case 10: + for (int i = 0; i < 8; i++) { + if (dComIfGs_isTriforce(i)) { + triforceCount++; + } + } + + if (triforceCount > 0) { + if (triforceCount == 8) { + msgNo = 0x28C; + } else { + msgNo = dItem_data::getItemMesgNum(97) + 200; + } + } + break; + + case 0x0B: + if (dComIfGs_isSymbol(0)) { + msgNo = dItem_data::getItemMesgNum(105) + 200; + } + break; + + case 0x0C: + if (dComIfGs_isSymbol(1)) { + msgNo = dItem_data::getItemMesgNum(106) + 200; + } + break; + + case 0x0D: + if (dComIfGs_isSymbol(2)) { + msgNo = dItem_data::getItemMesgNum(107) + 200; + } + break; + + case 0x0E: { + u8 item = dComIfGs_getSelectEquip(0); + u32 itemMsgNo = dItem_data::getItemMesgNum(item); + + if (itemMsgNo == 0) { + msgNo = 0x25C; + } else { + msgNo = itemMsgNo + 200; + } + break; + } + + case 0x0F: { + u8 item = dComIfGs_getSelectEquip(1); + u32 itemMsgNo = dItem_data::getItemMesgNum(item); + + if (itemMsgNo == 0) { + msgNo = 0x25C; + } else { + msgNo = itemMsgNo + 200; + } + break; + } + + case 0x10: { + u8 item = dComIfGs_getSelectEquip(2); + u32 itemMsgNo = dItem_data::getItemMesgNum(item); + + if (itemMsgNo == 0) { + msgNo = 0x25C; + } else { + msgNo = itemMsgNo + 200; + } + break; + } + + case 0x11: + if (dComIfGs_isCollect(3, 0)) { + msgNo = dItem_data::getItemMesgNum(66) + 200; + } + break; + + case 0x12: + if (dComIfGs_isCollect(4, 0)) { + msgNo = dItem_data::getItemMesgNum(67) + 200; + } + break; + + case 0x13: + if (!dComIfGs_isTact(0) && + !dComIfGs_isTact(1) && + !dComIfGs_isTact(2) && + !dComIfGs_isTact(3) && + !dComIfGs_isTact(4) && + !dComIfGs_isTact(5)) { + msgNo = 0; + } else { + msgNo = 0x25C; + } + break; + + case 0x14: + if (!dComIfGs_isSymbol(0) && + !dComIfGs_isSymbol(1) && + !dComIfGs_isSymbol(2)) { + msgNo = 0; + } else { + msgNo = 0x25C; + } + break; + } + + if (msgNo == 0) { + return; + } + + mesg_header* head_p = msgGet.getMesgHeader(msgNo); + JUT_ASSERT(VERSION_SELECT(0xCD3, 0xCD3, 0xCD3, 0xCD3), head_p); + + const char* bmgData = msgGet.getMessage(head_p); + + JMSMesgEntry_c mesgEntry; + mesgEntry = msgGet.getMesgEntry(head_p); + + mMsgProc.dataInit(); + mMsgProc.setBmgData((char*)bmgData); + mMsgProc.setOutMessage(note[0], note[1], dummy[0], dummy[1]); + mMsgProc.setFont(mpFont); + mMsgProc.setRubyFont(mpRubyFont); + mMsgProc.setCharSpace(((J2DTextBox*)m778.pane)->getCharSpace()); + mMsgProc.setRubyCharSpace(((J2DTextBox*)m740.pane)->getCharSpace()); + mMsgProc.setLineSpace(((J2DTextBox*)m778.pane)->getLineSpace()); + mMsgProc.setMesgEntry(&mesgEntry); +#if VERSION == VERSION_DEMO + mMsgProc.setFontSize(f30); +#else + mMsgProc.setFontSize(msgFontSize.mSizeX); +#endif + mMsgProc.setRubyFontSize(rubyFontSize); + mMsgProc.setLineWidth(0x1FE); + mMsgProc.setCenterLineWidth(0x1E6); + mMsgProc.setSendSpeed(2); + mMsgProc.setSpaceTimer(0); + mMsgProc.shortCut(); + mMsgProc.setSpaceFlagOff(); + mMsgProc.stringLength(); + mMsgProc.stringShift(); + mMsgProc.iconIdxRefresh(); + + s16 lineCount = mMsgProc.lineCount; + mMsgProc.lineCount = 0; + + f32 lineSpace = ((J2DTextBox*)m778.pane)->getLineSpace(); + + int lineAdjust = 3 - lineCount; + f32 yShift = lineAdjust * (lineSpace / 2.0f); + + ((J2DTextBox*)m740.pane)->shiftSet(0.0f, yShift); + ((J2DTextBox*)m778.pane)->shiftSet(0.0f, yShift); + + mMsgProc.stringSet(); + + ((J2DTextBox*)m778.pane)->setString(note[0]); + ((J2DTextBox*)m740.pane)->setString(note[1]); + + int halfLine = (((J2DTextBox*)m778.pane)->getLineSpace() / 2.0f); + + for (int i = 0; i < 15; i++) { + u8 iconNo = mMsgProc.getIconNum(i); + u32 iconColor = mMsgProc.getIconColor(i); + + if (iconColor == 0xFFFFFFFF) { + iconColor = 0xFF; + } + + if (iconNo != 0xFF && m0B0[i].mUserArea == -1) { + if (iconNo == 0x14) { + if (m27EB == 0) { + m27E0 = i; + m0B0[i].mUserArea = 0; + } + + m0B0[m27E0].mPosCenter.x = mMsgProc.getIconPosX(i); + m0B0[m27E0].mPosCenter.y = (halfLine * (lineAdjust + mMsgProc.getIconPosY(i) * 2)); + + m27EB = 1; + } else if (iconNo == 0x15) { + if (m27EB == 0) { + m27EB = 1; + m27F0 = 0; + m27E0 = i; + m0B0[i].mUserArea = 0; + } else { + m27F0 = 1; + } + + m0B0[m27E0].mPosTopLeft.x = mMsgProc.getIconPosX(i); + + m0B0[m27E0].mPosTopLeft.y = (halfLine * (lineAdjust + mMsgProc.getIconPosY(i) * 2)); + + fopMsgM_blendDraw(&m0B0[m27E0], "font_10.bti"); + + J2DPicture* pic = (J2DPicture*)m0B0[m27E0].pane; + + pic->setBlendColorRatio( + 0.0f, + 1.0f, + 1.0f, + 1.0f + ); + + pic->setBlendAlphaRatio( + 0.0f, + 1.0f, + 1.0f, + 1.0f + ); + + if (mNowItem == 0x12) { + if (dComIfGs_isCollect(4, 1)) { + m27F0 = 0; + mMsgProc.field_0x27D = 0; + } else { + m27F0 = 1; + mMsgProc.field_0x27D = 1; + } + } + + m27F1 = m27F0; + } else if (iconNo != 0x16) { + m0B0[i].mPosTopLeft.x = mMsgProc.getIconPosX(i); + m0B0[i].mPosTopLeft.y = (halfLine * (lineAdjust + mMsgProc.getIconPosY(i) * 2)); + + m0B0[i].mPosTopLeftOrig.y = iconNo; + + fopMsgM_outFontSet( + (J2DPicture*)m0B0[i].pane, + &m0B0[i].mUserArea, + iconColor, + iconNo + ); + } + } + } } /* 801A42D0-801A45BC .text itemSet__15dMenu_Collect_cFv */ void dMenu_Collect_c::itemSet() { - /* Nonmatching */ + if (dComIfGs_isCollect(0, 3)) { + JKRReadTypeResource( + mItemTexBuffer[0], 0xC00, 'TIMG', "sword_03.bti", + dComIfGp_getItemIconArchive() + ); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mItemTexBuffer[0], 0xC00); +#else + DCStoreRangeNoSync(mItemTexBuffer[0], 0xC00); +#endif + ((J2DPicture*)m2030[0].pane)->changeTexture(mItemTexBuffer[0], 0); + ((J2DPicture*)m2148[0].pane)->changeTexture(mItemTexBuffer[0], 0); + } + else if (dComIfGs_isCollect(0, 2)) { + JKRReadTypeResource( + mItemTexBuffer[0], 0xC00, 'TIMG', "sword_02.bti", + dComIfGp_getItemIconArchive() + ); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mItemTexBuffer[0], 0xC00); +#else + DCStoreRangeNoSync(mItemTexBuffer[0], 0xC00); +#endif + ((J2DPicture*)m2030[0].pane)->changeTexture(mItemTexBuffer[0], 0); + ((J2DPicture*)m2148[0].pane)->changeTexture(mItemTexBuffer[0], 0); + } + else if (dComIfGs_isCollect(0, 1)) { + JKRReadTypeResource( + mItemTexBuffer[0], 0xC00, 'TIMG', "sword_01.bti", + dComIfGp_getItemIconArchive() + ); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mItemTexBuffer[0], 0xC00); +#else + DCStoreRangeNoSync(mItemTexBuffer[0], 0xC00); +#endif + ((J2DPicture*)m2030[0].pane)->changeTexture(mItemTexBuffer[0], 0); + ((J2DPicture*)m2148[0].pane)->changeTexture(mItemTexBuffer[0], 0); + } + else if (dComIfGs_isCollect(0, 0) != 0) { + JKRReadTypeResource( + mItemTexBuffer[0], 0xC00, 'TIMG', "sword_00.bti", + dComIfGp_getItemIconArchive() + ); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mItemTexBuffer[0], 0xC00); +#else + DCStoreRangeNoSync(mItemTexBuffer[0], 0xC00); +#endif + ((J2DPicture*)m2030[0].pane)->changeTexture(mItemTexBuffer[0], 0); + ((J2DPicture*)m2148[0].pane)->changeTexture(mItemTexBuffer[0], 0); + } + + if (dComIfGs_isCollect(1, 1)) { + JKRReadTypeResource( + mItemTexBuffer[1], 0xC00, 'TIMG', "shield_01.bti", + dComIfGp_getItemIconArchive() + ); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mItemTexBuffer[1], 0xC00); +#else + DCStoreRangeNoSync(mItemTexBuffer[1], 0xC00); +#endif + ((J2DPicture*)m2030[0].pane)->changeTexture(mItemTexBuffer[0], 0); + ((J2DPicture*)m2148[0].pane)->changeTexture(mItemTexBuffer[0], 0); + } + else if (dComIfGs_isCollect(1, 0)) { + JKRReadTypeResource( + mItemTexBuffer[1], 0xC00, 'TIMG', "shield_00.bti", + dComIfGp_getItemIconArchive() + ); +#if VERSION <= VERSION_JPN + DCFlushRangeNoSync(mItemTexBuffer[1], 0xC00); +#else + DCStoreRangeNoSync(mItemTexBuffer[1], 0xC00); +#endif + ((J2DPicture*)m2030[0].pane)->changeTexture(mItemTexBuffer[0], 0); + ((J2DPicture*)m2148[0].pane)->changeTexture(mItemTexBuffer[0], 0); + } } /* 801A45BC-801A4658 .text outFontInit__15dMenu_Collect_cFv */ void dMenu_Collect_c::outFontInit() { - /* Nonmatching */ + for (int i = 0; i < 15; i++) { + m0B0[i].mUserArea = -1; + + m0B0[i].pane->rotate(0.0f); + + fopMsgM_setNowAlphaZero(&m0B0[i]); + } + + m27E0 = -1; + m27EB = 0; + m27F0 = 0; } /* 801A4658-801A4774 .text outFontMove__15dMenu_Collect_cFv */ void dMenu_Collect_c::outFontMove() { - /* Nonmatching */ + for (int i = 0; i < 15; i++) { + if (m0B0[i].mUserArea != -1) { + m3F8[i].mPosTopLeft.x = m0B0[i].mPosTopLeft.x + (m778.mPosTopLeft.x + (m820.mPosTopLeft.x + m7B0.mPosTopLeft.x)); + m3F8[i].mPosTopLeft.y = m0B0[i].mPosTopLeft.y + (m778.mPosTopLeft.y + (m820.mPosTopLeft.y + m7B0.mPosTopLeft.y)); + + if (i == m27E0 && m27F0 == 0) { + m3F8[i].mPosTopLeft.x -= (m0B0[i].mPosTopLeft.x - m0B0[i].mPosCenter.x); + } + + f32 rotOffX = m820.mPosCenter.x - m3F8[i].mPosTopLeft.x; + f32 rotOffY = m820.mPosCenter.y - m3F8[i].mPosTopLeft.y; + + m3F8[i].pane->rotate(rotOffX, rotOffY, ROTATE_Z, m820.pane->mRotation); + } else { + fopMsgM_setNowAlphaZero(&m0B0[i]); + } + } } /* 801A4774-801A48AC .text outFontDraw__15dMenu_Collect_cFv */ void dMenu_Collect_c::outFontDraw() { - /* Nonmatching */ + for (int i = 0; i < 15; i++) { + if (m0B0[i].mUserArea != -1) { + m0B0[i].mNowAlpha = m778.pane->getAlpha(); + + if (i == m27E0) { + mMsgProc.selectArrow((J2DPicture*)m0B0[i].pane, g_msgHIO.field_0x70, g_msgHIO.field_0x70); + + m3F8[i].pane->move(m3F8[i].mPosTopLeft.x, m3F8[i].mPosTopLeft.y); + + fopMsgM_setAlpha(&m0B0[i]); + } else { + fopMsgM_outFontDraw2( + (J2DPicture*)m0B0[i].pane, + (J2DPicture*)m3F8[i].pane, + (int)m3F8[i].mPosTopLeft.x, + (int)m3F8[i].mPosTopLeft.y, + g_msgHIO.field_0x70, + g_msgHIO.field_0x70, + &m0B0[i].mUserArea, + m0B0[i].mNowAlpha, + m0B0[i].mPosTopLeftOrig.y + ); + } + } else { + fopMsgM_setAlpha(&m0B0[i]); + + } + } } /* 801A48AC-801A4A28 .text collectItemGetCheck__15dMenu_Collect_cFUc */ @@ -1699,6 +3544,13 @@ bool dMenu_Collect_c::collectItemGetCheck(unsigned char param_1) { case 4: case 5: return dComIfGs_isTact(param_1); +#if VERSION == VERSION_DEMO + case 6: + case 7: + case 8: + case 9: + return true; +#else case 6: case 7: return true; @@ -1711,6 +3563,7 @@ bool dMenu_Collect_c::collectItemGetCheck(unsigned char param_1) { else { return false; } +#endif case 10: for (int i = 0; i < 8; i++) { if (dComIfGs_isTriforce(i)) { @@ -1735,34 +3588,33 @@ bool dMenu_Collect_c::collectItemGetCheck(unsigned char param_1) { /* 801A4A28-801A4F18 .text _create__15dMenu_Collect_cFv */ void dMenu_Collect_c::_create() { - /* Nonmatching */ scrn = new MyScreen(); - JUT_ASSERT(0xe4a, scrn != NULL); + JUT_ASSERT(VERSION_SELECT(0xe4a, 0xe4a, 0xe4a, 0xe4a), scrn != NULL); scrn->set("menu_collect_01.blo", mpArc); stick = new STControl(5, 2, 3, 2); - JUT_ASSERT(0xe4e, stick != NULL); + JUT_ASSERT(VERSION_SELECT(0xe4e, 0xe4e, 0xe4e, 0xe4e), stick != NULL); - cstick = new CSTControl(); - JUT_ASSERT(0xe51, cstick != NULL); + cstick = new CSTControl(5, 2, 3, 2); + JUT_ASSERT(VERSION_SELECT(0xe51, 0xe51, 0xe51, 0xe51), cstick != NULL); stick->setWaitParm(5, 2, 3, 2, 0.9f, 0.5f, 0, 0x800); outFont = new dDlst_2DOutFont_c(); - JUT_ASSERT(0xe55, outFont != NULL); + JUT_ASSERT(VERSION_SELECT(0xe55, 0xe55, 0xe55, 0xe55), outFont != NULL); - outFont->setAlpha(1); + outFont->m74 = 1; dMo_c = new dMenu_Option_c(); - JUT_ASSERT(0xe59, dMo_c != NULL); + JUT_ASSERT(VERSION_SELECT(0xe59, 0xe59, 0xe59, 0xe59), dMo_c != NULL); dMo_c->setArchive(mpOptArc); - dMo_c->setFont(mFont, mRFont); + dMo_c->setFont(mpFont, mpRubyFont); dMo_c->setTextArea(note[0], note[1], dummy[0], dummy[1]); dMo_c->_create(); dMs_c = new dMenu_save_c(); - JUT_ASSERT(0xe63, dMs_c != NULL); + JUT_ASSERT(VERSION_SELECT(0xe63, 0xe63, 0xe63, 0xe63), dMs_c != NULL); dMs_c->setUseType(1); dMs_c->_create(); @@ -1774,11 +3626,10 @@ void dMenu_Collect_c::_create() { m247C[i] = NULL; } - g_mcHIO.mNo = mDoHIO_createChild("triforce_00.bti", &g_mcHIO); + g_mcHIO.mNo = mDoHIO_createChild("コレクト画面", &g_mcHIO); for(int i = 0; i < 4; i++) { - J2DPicture* pic = (J2DPicture*)mA18[i].pane; - pic->insert("cursor_00_02.bti", pic->mAlpha, 1.0f); + ((J2DPicture*)mA18[i].pane)->append("cursor_00_02.bti", 1.0f); m2788[i] = mA18[i].mPosCenterOrig.x - m1498[0].mPosCenterOrig.x; m2798[i] = mA18[i].mPosCenterOrig.y - m1498[0].mPosCenterOrig.y; @@ -1794,32 +3645,31 @@ void dMenu_Collect_c::_create() { /* 801A4F18-801A5498 .text _create3__15dMenu_Collect_cFv */ void dMenu_Collect_c::_create3() { - /* Nonmatching */ scrn = new MyScreen(); - JUT_ASSERT(0xE8F, scrn != NULL); + JUT_ASSERT(VERSION_SELECT(3638, 3651, 3727, 3727), scrn != NULL); scrn->set("menu_collect_01.blo", mpArc); stick = new STControl(5, 2, 3, 2); - JUT_ASSERT(0xE93, stick != NULL); + JUT_ASSERT(VERSION_SELECT(3642, 3655, 3731, 3731), stick != NULL); - cstick = new CSTControl(); - JUT_ASSERT(0xE96, cstick != NULL); + cstick = new CSTControl(5, 2, 3, 2); + JUT_ASSERT(VERSION_SELECT(3645, 3658, 3734, 3734), cstick != NULL); stick->setWaitParm(5, 2, 3, 2, 0.9f, 0.5f, 0, 0x800); outFont = new dDlst_2DOutFont_c(); - JUT_ASSERT(0xE9A, outFont != NULL); + JUT_ASSERT(VERSION_SELECT(0xE9A, 0xE9A, 0xE9A, 0xE9A), outFont != NULL); dMo_c = new dMenu_Option_c(); - JUT_ASSERT(0xE9D, dMo_c != NULL); + JUT_ASSERT(VERSION_SELECT(0xE9D, 0xE9D, 0xE9D, 0xE9D), dMo_c != NULL); dMo_c->setArchive(mpOptArc); - dMo_c->setFont(mFont, mRFont); + dMo_c->setFont(mpFont, mpRubyFont); dMo_c->setTextArea(note[0], note[1], dummy[0], dummy[1]); dMo_c->_create(); dMs_c = new dMenu_save_c(); - JUT_ASSERT(0xEA6, dMs_c != NULL); + JUT_ASSERT(VERSION_SELECT(0xEA6, 0xEA6, 0xEA6, 0xEA6), dMs_c != NULL); dMs_c->setUseType(1); dMs_c->_create(); @@ -1852,7 +3702,7 @@ void dMenu_Collect_c::_create3() { m247C[i] = 0; } - g_mcHIO.mNo = mDoHIO_createChild("triforce_00.bti", &g_mcHIO); + g_mcHIO.mNo = mDoHIO_createChild("コレクト画面", &g_mcHIO); for (int i = 0; i < 4; i++) { mA18[i].pane->hide(); @@ -1919,15 +3769,17 @@ void dMenu_Collect_c::_move() { } } - mDoAud_zelAudio_c::mTact.melodyPlay(mNowItem); + mDoAud_tact_melodyPlay(mNowItem); } else if (mNowItem == 6) { mCollectMode = 4; dMo_c->initialize(); mDoAud_seStart(JA_SE_ITM_MENU_OPT_IN); } else if (mNowItem == 7) { +#if VERSION > VERSION_DEMO mCollectMode = 3; dMs_c->initialize(); mDoAud_seStart(JA_SE_ITM_MENU_OPT_IN); +#endif } else if (mNowItem == 0x11) { if (dComIfGs_isCollect(3, 0)) { dComIfGs_onCollect(3, 1); @@ -1935,11 +3787,9 @@ void dMenu_Collect_c::_move() { } if (((mNowItem >= 0xA && mNowItem <= 0x12) || - (mNowItem == 8 && - dComIfGs_getMaxLife() % 4) || - (mNowItem == 9 && - (dComIfGs_isEventBit(dSv_event_flag_c::UNK_0908) || - dComIfGs_getCollectMapNum()))) && + (mNowItem == 8 && dComIfGs_getMaxLife() % 4) || + (mNowItem == 9 && (dComIfGs_isEventBit(dSv_event_flag_c::UNK_0908) || + dComIfGs_getCollectMapNum()))) && collectItemGetCheck(mNowItem)) { fopMsgM_setInitAlpha(&m740); @@ -2642,7 +4492,7 @@ void dMenu_Collect_c::animeStep1(short param_1, short param_2) { if (m247C[2] == NULL) { m247C[2] = dComIfGp_particle_set2DmenuFore(dPa_name::ID_HM_J2_RUPYLIGHT, &pos); - m247C[2]->mGlobalPrmColor.a = 0xFF; + m247C[2]->setGlobalAlpha(0xFF); } } else if (step_max - 4 == step) { cXyz pos( @@ -2653,7 +4503,7 @@ void dMenu_Collect_c::animeStep1(short param_1, short param_2) { if (m247C[1] == NULL) { m247C[1] = dComIfGp_particle_set2DmenuFore(dPa_name::ID_HM_J2_RUPYLIGHT, &pos); - m247C[1]->mGlobalPrmColor.a = 0xFF; + m247C[1]->setGlobalAlpha(0xFF); } } @@ -2683,7 +4533,7 @@ void dMenu_Collect_c::animeStep1(short param_1, short param_2) { if (m247C[0] == NULL) { m247C[0] = dComIfGp_particle_set2DmenuFore(dPa_name::ID_HM_J2_RUPYLIGHT, &pos); - m247C[0]->mGlobalPrmColor.a = 0xFF; + m247C[0]->setGlobalAlpha(0xFF); } } } @@ -2715,7 +4565,7 @@ void dMenu_Collect_c::animeStep3(short param_1, short param_2) { fopMsgM_setNowAlpha(&m890[0], name_t); fopMsgM_setNowAlpha(&m890[1], 1.0f - name_t); - const s16 emitterPaneIdx[3] = {1, 6, 7}; + const s16 emitterPaneIdx[3] = {6, 1, 7}; for (int i = 0; i < 3; i++) { cXyz pos( @@ -2744,15 +4594,15 @@ void dMenu_Collect_c::animeStep4(short param_1, short param_2) { if (step == quarter) { if (m247C[0] != NULL) { - m247C[0]->mGlobalPrmColor.a = 0; + m247C[0]->setGlobalAlpha(0); } } else if (step == quarter * 2) { if (m247C[1] != NULL) { - m247C[1]->mGlobalPrmColor.a = 0; + m247C[1]->setGlobalAlpha(0); } } else if (step == quarter * 3) { if (m247C[2] != NULL) { - m247C[2]->mGlobalPrmColor.a = 0; + m247C[2]->setGlobalAlpha(0); } } diff --git a/src/d/d_menu_option.cpp b/src/d/d_menu_option.cpp index 0e2b349c6..234e216d5 100644 --- a/src/d/d_menu_option.cpp +++ b/src/d/d_menu_option.cpp @@ -95,22 +95,22 @@ void dMenu_Option_c::screenSet() { fopMsgM_messageGet(mDE8[3], 0x1D6); #endif - ((J2DTextBox*)m008.pane)->setFont(mD2C); + ((J2DTextBox*)m008.pane)->setFont(mpFont); #if VERSION > VERSION_JPN ((J2DTextBox*)m008.pane)->setString(mD48); #endif - ((J2DTextBox*)m740[0].pane)->setFont(mD2C); - ((J2DTextBox*)m740[1].pane)->setFont(mD30); + ((J2DTextBox*)m740[0].pane)->setFont(mpFont); + ((J2DTextBox*)m740[1].pane)->setFont(mpRubyFont); for (int i = 0; i < 2; i++) { - ((J2DTextBox*)m9A8[i].pane)->setFont(mD2C); + ((J2DTextBox*)m9A8[i].pane)->setFont(mpFont); #if VERSION <= VERSION_JPN - ((J2DTextBox*)mA18_jpn[i].pane)->setFont(mD2C); + ((J2DTextBox*)mA18_jpn[i].pane)->setFont(mpFont); #endif #if VERSION > VERSION_JPN ((J2DTextBox*)m9A8[i].pane)->setString(mD5C[i]); #endif - ((J2DTextBox*)mAC0[i].pane)->setFont(mD2C); + ((J2DTextBox*)mAC0[i].pane)->setFont(mpFont); #if VERSION > VERSION_JPN ((J2DTextBox*)mAC0[i].pane)->setString(mD84[i]); changeScaleCenter(&m9A8[i], mD5C[i]); @@ -119,7 +119,7 @@ void dMenu_Option_c::screenSet() { } for (int i = 0; i < 3; i++) { - ((J2DTextBox*)mA18[i].pane)->setFont(mD2C); + ((J2DTextBox*)mA18[i].pane)->setFont(mpFont); #if VERSION > VERSION_JPN ((J2DTextBox*)mA18[i].pane)->setString(mDAC[i]); changeScaleCenter(&mA18[i], mDAC[i]); @@ -130,7 +130,7 @@ void dMenu_Option_c::screenSet() { #if VERSION > VERSION_JPN if (i == 1) continue; #endif - ((J2DTextBox*)m8C8[i].pane)->setFont(mD2C); + ((J2DTextBox*)m8C8[i].pane)->setFont(mpFont); #if VERSION > VERSION_JPN ((J2DTextBox*)m8C8[i].pane)->setString(mDE8[i]); changeScaleRight(&m8C8[i], mDE8[i]); @@ -666,8 +666,8 @@ void dMenu_Option_c::noteSet() { msgDataProc.dataInit(); msgDataProc.setBmgData((char*)mesg); msgDataProc.setOutMessage(mD38, mD3C, mD40, mD44); - msgDataProc.setFont(mD2C); - msgDataProc.setRubyFont(mD30); + msgDataProc.setFont(mpFont); + msgDataProc.setRubyFont(mpRubyFont); msgDataProc.setCharSpace(((J2DTextBox*)m740[0].pane)->getCharSpace()); msgDataProc.setRubyCharSpace(((J2DTextBox*)m740[1].pane)->getCharSpace()); msgDataProc.setLineSpace(((J2DTextBox*)m740[0].pane)->getLineSpace()); @@ -763,16 +763,16 @@ f32 dMenu_Option_c::stringlength(fopMsgM_pane_class* r30, char* r31) { J2DTextBox::TFontSize sp18; ((J2DTextBox*)r30->pane)->getFontSize(sp18); f32 f31 = ((J2DTextBox*)r30->pane)->getCharSpace(); - f30 = sp18.mSizeX / mD2C->getCellWidth(); + f30 = sp18.mSizeX / mpFont->getCellWidth(); while (*r31 != 0) { if ((u8)*r31 == 0x1A) { r31++; r31 += (*r31 - 1); } else { int r26 = (u8)*r31++; - int r28 = mD2C->getWidth(r26); + int r28 = mpFont->getWidth(r26); if (!r27) { - f29 = f30 * (r28 + mD2C->getOffset(r26)); + f29 = f30 * (r28 + mpFont->getOffset(r26)); r27 = true; } else{ f29 += f31 + r28 * f30; diff --git a/src/dolphin/gx/GXAttr.c b/src/dolphin/gx/GXAttr.c index d9981b613..3a044d7fc 100644 --- a/src/dolphin/gx/GXAttr.c +++ b/src/dolphin/gx/GXAttr.c @@ -1,42 +1,34 @@ #include "dolphin/gx/GXAttr.h" #include "dolphin/gx/GX.h" -static inline void SETVCDATTR(GXAttr name, GXAttrType type) { - switch (name) { +static inline void SETVCDATTR(GXAttr attr, GXAttrType type) { + switch (attr) { case GX_VA_PNMTXIDX: GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_POSMTXIDX_ST, GX_CP_VCD_LO_POSMTXIDX_END); break; case GX_VA_TEX0MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX0MTXIDX_ST, - GX_CP_VCD_LO_TEX0MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX0MTXIDX_ST, GX_CP_VCD_LO_TEX0MTXIDX_END); break; case GX_VA_TEX1MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX1MTXIDX_ST, - GX_CP_VCD_LO_TEX1MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX1MTXIDX_ST, GX_CP_VCD_LO_TEX1MTXIDX_END); break; case GX_VA_TEX2MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX2MTXIDX_ST, - GX_CP_VCD_LO_TEX2MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX2MTXIDX_ST, GX_CP_VCD_LO_TEX2MTXIDX_END); break; case GX_VA_TEX3MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX3MTXIDX_ST, - GX_CP_VCD_LO_TEX3MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX3MTXIDX_ST, GX_CP_VCD_LO_TEX3MTXIDX_END); break; case GX_VA_TEX4MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX4MTXIDX_ST, - GX_CP_VCD_LO_TEX4MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX4MTXIDX_ST, GX_CP_VCD_LO_TEX4MTXIDX_END); break; case GX_VA_TEX5MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX5MTXIDX_ST, - GX_CP_VCD_LO_TEX5MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX5MTXIDX_ST, GX_CP_VCD_LO_TEX5MTXIDX_END); break; case GX_VA_TEX6MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX6MTXIDX_ST, - GX_CP_VCD_LO_TEX6MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX6MTXIDX_ST, GX_CP_VCD_LO_TEX6MTXIDX_END); break; case GX_VA_TEX7MTXIDX: - GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX7MTXIDX_ST, - GX_CP_VCD_LO_TEX7MTXIDX_END); + GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_TEX7MTXIDX_ST, GX_CP_VCD_LO_TEX7MTXIDX_END); break; case GX_VA_POS: GX_SET_REG(gx->vcdLo, type, GX_CP_VCD_LO_POS_ST, GX_CP_VCD_LO_POS_END); @@ -92,6 +84,29 @@ static inline void SETVCDATTR(GXAttr name, GXAttrType type) { } } +static void __GXXfVtxSpecs(void) { + u32 nCols = 0; + u32 nNrm; + u32 nTex; + u32 reg; + + nCols = GET_REG_FIELD(gx->vcdLo, 2, 13) ? 1 : 0; + nCols += GET_REG_FIELD(gx->vcdLo, 2, 15) ? 1 : 0; + nNrm = gx->hasBiNrms ? 2 : gx->hasNrms ? 1 : 0; + nTex = 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 0) ? 1 : 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 2) ? 1 : 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 4) ? 1 : 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 6) ? 1 : 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 8) ? 1 : 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 10) ? 1 : 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 12) ? 1 : 0; + nTex += GET_REG_FIELD(gx->vcdHi, 2, 14) ? 1 : 0; + reg = (nCols) | (nNrm << 2) | (nTex << 4); + GX_WRITE_XF_REG(8, reg); + gx->bpSentNot = GX_TRUE; +} + void GXSetVtxDesc(GXAttr name, GXAttrType type) { SETVCDATTR(name, type); @@ -120,25 +135,6 @@ void GXSetVtxDescv(GXVtxDescList* list) { gx->dirtyState |= GX_DIRTY_VCD; } -static void __GXXfVtxSpecs(void) { - u32 normCount, colorCount, texCount; - - normCount = gx->hasBiNrms ? 2 : (gx->hasNrms ? 1 : 0); - - // Both fields in one access - colorCount = 33 - __cntlzw((gx->vcdLo & (0xf << 0xd)) >> 0xd); - colorCount /= 2; // equivalent to /=2 and >>= 1 - - // All 16 assigned bits in VCD_Hi - texCount = 33 - __cntlzw((gx->vcdHi & (0xffff << 0)) >> 0); - texCount /= 2; // equivalent to /=2 and >>= 1 - - GX_XF_LOAD_REG(GX_XF_REG_INVERTEXSPEC, (colorCount) | (normCount << 2) | (texCount << 4)); - gx->bpSentNot = GX_TRUE; - - return; -} - void __GXSetVCD(void) { GX_CP_LOAD_REG(GX_CP_REG_VCD_LO, gx->vcdLo); GX_CP_LOAD_REG(GX_CP_REG_VCD_HI, gx->vcdHi); @@ -195,105 +191,45 @@ void __GXCalculateVLim(void) { gx->vLim = vlim; } -void GXGetVtxDesc(int param_0, GXAttrType* param_1) { - int local_38; +void GXGetVtxDesc(GXAttr attr, GXAttrType* type) { + u32 cpType; - switch (param_0) { - case 0: - local_38 = gx->vcdLo & 1; - break; - case 1: - local_38 = (gx->vcdLo & 2) >> 1; - break; - case 2: - local_38 = (gx->vcdLo & 4) >> 2; - break; - case 3: - local_38 = (gx->vcdLo & 8) >> 3; - break; - case 4: - local_38 = (gx->vcdLo & 0x10) >> 4; - break; - case 5: - local_38 = (gx->vcdLo & 0x20) >> 5; - break; - case 6: - local_38 = (gx->vcdLo & 0x40) >> 6; - break; - case 7: - local_38 = (gx->vcdLo & 0x80) >> 7; - break; - case 8: - local_38 = (gx->vcdLo & 0x100) >> 8; - break; - case 9: - local_38 = (gx->vcdLo & 0x600) >> 9; - break; - case 10: - if (gx->hasNrms != 0) { - local_38 = (gx->vcdLo & 0x1800) >> 11; - } else { - local_38 = 0; - } - break; - case 0x19: - if (gx->hasBiNrms != 0) { - local_38 = (gx->vcdLo & 0x1800) >> 11; - } else { - local_38 = 0; - } - break; - case 11: - local_38 = (gx->vcdLo & 0x6000) >> 13; - break; - case 12: - local_38 = (gx->vcdLo & 0x18000) >> 15; - break; - case 13: - local_38 = (gx->vcdHi & 3); - break; - case 14: - local_38 = (gx->vcdHi & 0xC) >> 2; - break; - case 15: - local_38 = (gx->vcdHi & 0x30) >> 4; - break; - case 16: - local_38 = (gx->vcdHi & 0xC0) >> 6; - break; - case 17: - local_38 = (gx->vcdHi & 0x300) >> 8; - break; - case 18: - local_38 = (gx->vcdHi & 0xC00) >> 10; - break; - case 19: - local_38 = (gx->vcdHi & 0x3000) >> 12; - break; - case 20: - local_38 = (gx->vcdHi & 0xC000) >> 14; - break; - default: - local_38 = 0; - break; + switch (attr) { + case GX_VA_PNMTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 0); break; + case GX_VA_TEX0MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 1); break; + case GX_VA_TEX1MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 2); break; + case GX_VA_TEX2MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 3); break; + case GX_VA_TEX3MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 4); break; + case GX_VA_TEX4MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 5); break; + case GX_VA_TEX5MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 6); break; + case GX_VA_TEX6MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 7); break; + case GX_VA_TEX7MTXIDX: cpType = GET_REG_FIELD(gx->vcdLo, 1, 8); break; + case GX_VA_POS: cpType = GET_REG_FIELD(gx->vcdLo, 2, 9); break; + case GX_VA_NRM: cpType = gx->hasNrms ? GET_REG_FIELD(gx->vcdLo, 2, 11) : 0; break; + case GX_VA_NBT: cpType = gx->hasBiNrms ? GET_REG_FIELD(gx->vcdLo, 2, 11) : 0; break; + case GX_VA_CLR0: cpType = GET_REG_FIELD(gx->vcdLo, 2, 13); break; + case GX_VA_CLR1: cpType = GET_REG_FIELD(gx->vcdLo, 2, 15); break; + case GX_VA_TEX0: cpType = GET_REG_FIELD(gx->vcdHi, 2, 0); break; + case GX_VA_TEX1: cpType = GET_REG_FIELD(gx->vcdHi, 2, 2); break; + case GX_VA_TEX2: cpType = GET_REG_FIELD(gx->vcdHi, 2, 4); break; + case GX_VA_TEX3: cpType = GET_REG_FIELD(gx->vcdHi, 2, 6); break; + case GX_VA_TEX4: cpType = GET_REG_FIELD(gx->vcdHi, 2, 8); break; + case GX_VA_TEX5: cpType = GET_REG_FIELD(gx->vcdHi, 2, 10); break; + case GX_VA_TEX6: cpType = GET_REG_FIELD(gx->vcdHi, 2, 12); break; + case GX_VA_TEX7: cpType = GET_REG_FIELD(gx->vcdHi, 2, 14); break; + default: cpType = 0; break; } - - *param_1 = local_38; + *type = cpType; } -void GXGetVtxDescv(GXVtxDescList* attrPtr) { - int i; +void GXGetVtxDescv(GXVtxDescList* vcd) { + GXAttr attr; - for (i = 0; i <= 0x14; i++) { - attrPtr[i].attr = (GXAttr)i; - GXGetVtxDesc(i, &attrPtr[i].type); + for (attr = 0; attr < GX_VA_MAX_ATTR; attr++) { + vcd[attr].attr = attr; + GXGetVtxDesc(attr, &vcd[attr].type); } - - attrPtr[i].attr = (GXAttr)0x19; - GXGetVtxDesc(0x19, &attrPtr[i].type); - - i++; - attrPtr[i].attr = (GXAttr)0xFF; + vcd[attr].attr = 0xFF; } void GXClearVtxDesc(void) { @@ -329,13 +265,11 @@ static inline void SETVAT(u32* vatA, u32* vatB, u32* vatC, GXAttr attr, GXCompCn break; case GX_VA_CLR0: GX_SET_REG(*vatA, compCnt, GX_CP_VAT_GRP0_CLRDIFF_CNT_ST, GX_CP_VAT_GRP0_CLRDIFF_CNT_END); - GX_SET_REG(*vatA, compType, GX_CP_VAT_GRP0_CLRDIFF_TYPE_ST, - GX_CP_VAT_GRP0_CLRDIFF_TYPE_END); + GX_SET_REG(*vatA, compType, GX_CP_VAT_GRP0_CLRDIFF_TYPE_ST, GX_CP_VAT_GRP0_CLRDIFF_TYPE_END); break; case GX_VA_CLR1: GX_SET_REG(*vatA, compCnt, GX_CP_VAT_GRP0_CLRSPEC_CNT_ST, GX_CP_VAT_GRP0_CLRSPEC_CNT_END); - GX_SET_REG(*vatA, compType, GX_CP_VAT_GRP0_CLRSPEC_TYPE_ST, - GX_CP_VAT_GRP0_CLRSPEC_TYPE_END); + GX_SET_REG(*vatA, compType, GX_CP_VAT_GRP0_CLRSPEC_TYPE_ST, GX_CP_VAT_GRP0_CLRSPEC_TYPE_END); break; case GX_VA_TEX0: GX_SET_REG(*vatA, compCnt, GX_CP_VAT_GRP0_TXC0_CNT_ST, GX_CP_VAT_GRP0_TXC0_CNT_END); @@ -409,343 +343,243 @@ void GXSetVtxAttrFmtv(GXVtxFmt format, GXVtxAttrFmtList* list) { } void __GXSetVAT(void) { - u32 i = 0; - u32 dirtyVAT = gx->dirtyVAT; - do { - if (dirtyVAT & (1)) { - GX_CP_LOAD_REG(GX_CP_REG_VAT_GRP0 | i, gx->vatA[i]); - GX_CP_LOAD_REG(GX_CP_REG_VAT_GRP1 | i, gx->vatB[i]); - GX_CP_LOAD_REG(GX_CP_REG_VAT_GRP2 | i, gx->vatC[i]); - } - dirtyVAT >>= 1; - i++; - } while (dirtyVAT != 0); + u8 i; + for (i = 0; i < 8; i++) { + if (gx->dirtyVAT & (1 << (u8)i)) { + GX_WRITE_SOME_REG4(8, i | 0x70, gx->vatA[i], i - 12); + GX_WRITE_SOME_REG4(8, i | 0x80, gx->vatB[i], i - 12); + GX_WRITE_SOME_REG4(8, i | 0x90, gx->vatC[i], i - 12); + } + } gx->dirtyVAT = 0; } -static u8 GetFracForNrm(int param_0) { - int var_r31; +static inline u8 GetFracForNrm(GXCompType type) { + u8 frac; - switch (param_0) { - case 1: - var_r31 = 6; + switch (type) { + case GX_S8: + frac = 6; break; - case 3: - var_r31 = 14; + case GX_S16: + frac = 14; break; default: - case 2: - var_r31 = 0; + case GX_U16: + frac = 0; break; } - return var_r31; + return frac; } -void GXGetVtxAttrFmtv(GXVtxFmt param_0, GXVtxAttrFmtList* param_1) { - s32 tmp; - s32 tmp2; - s32 tmp3; - int i; +void GXGetVtxAttrFmt(GXVtxFmt fmt, int attr, GXCompCnt* cnt, GXCompType* type, u8* frac) { + u32 *va; + u32 *vb; + u32 *vc; -#ifdef DEBUG - // not fully matching - /* tmp = 1; - if (data_8074d3c8 != 0) { - OSPanic("GXAttr.c", 941, "\'GXGetVtxAttrFmtv\' is not allowed between GXBegin/GXEnd"); - tmp = 0; - } - - tmp2 = 1; - if (param_1 == NULL) { - OSPanic("GXAttr.c", 942, "GXSetVtxAttrFmt: list pointer is NULL"); - tmp2 = 0; - } - - tmp3 = 1; - if (param_0 >= 8) { - OSPanic("GXAttr.c", 943, "GXSetVtxAttrFmt: Format Index is out of range"); - tmp3 = 0; - } */ -#endif - - for (i = 9; i <= 0x14; i++) { - param_1->attr = i; - GXGetVtxAttrFmt(param_0, i, ¶m_1->cnt, ¶m_1->type, ¶m_1->frac); - param_1++; - } - - param_1->attr = 0xFF; -} - -void GXGetVtxAttrFmt(GXVtxFmt param_0, int param_1, GXCompCnt* param_2, GXCompType* param_3, - u8* param_4) { - s32 tmp; - s32 tmp2; - GXCompCnt* tmp_1; - GXCompCnt* tmp_2; - u32* tmp_3; - -#ifdef DEBUG - // not fully matching - /* tmp = 1; - if (data_8074d3c8) { - OSPanic("GXAttr.c", 844, "\'GXGetVtxAttrFmt\' is not allowed between GXBegin/GXEnd"); - tmp = 0; - } - - tmp2 = 1; - if (param_0 >= 8) { - OSPanic("GXAttr.c", 845, "GXSetVtxAttrFmt: Format Index is out of range"); - tmp2 = 0; - } */ -#endif - - tmp_1 = (GXCompCnt*)&gx->vatA[param_0]; - tmp_2 = (GXCompCnt*)&gx->vatB[param_0]; - tmp_3 = &gx->vatC[param_0]; - - switch (param_1) { - case 9: - *param_2 = *tmp_1 & 1; - *param_3 = (*tmp_1 & 0xE) >> 1; - *param_4 = (*tmp_1 & 0x1F0) >> 4; - break; - case 10: - case 0x19: - *param_2 = (*tmp_1 & 0x200) >> 9; - if (*param_2 == 1 && ((*tmp_1 & 0x80000000) >> 31) != 0) { - *param_2 = 2; + va = &gx->vatA[fmt]; + vb = &gx->vatB[fmt]; + vc = &gx->vatC[fmt]; + switch (attr) { + case GX_VA_POS: + *cnt = GET_REG_FIELD(*va, 1, 0); + *type = GET_REG_FIELD(*va, 3, 1); + *frac = GET_REG_FIELD(*va, 5, 4); + return; + case GX_VA_NRM: + case GX_VA_NBT: + *cnt = GET_REG_FIELD(*va, 1, 9); + if (*cnt == GX_TEX_ST && (u8)(*va >> 0x1F) != 0) { + *cnt = GX_NRM_NBT3; } - - *param_3 = (*tmp_1 & 0x1C00) >> 10; - *param_4 = GetFracForNrm(*param_3); - break; - case 11: - *param_2 = (*tmp_1 & 0x2000) >> 0xd; - *param_3 = (*tmp_1 & 0x1C000) >> 0xe; - *param_4 = 0; - break; - case 12: - *param_2 = (*tmp_1 & 0x20000) >> 0x11; - *param_3 = (*tmp_1 & 0x1C0000) >> 0x12; - *param_4 = 0; - break; - case 13: - *param_2 = (*tmp_1 & 0x200000) >> 0x15; - *param_3 = (*tmp_1 & 0x1C00000) >> 0x16; - *param_4 = ((*tmp_1 & 0x3e000000)) >> 25; - break; - case 14: - *param_2 = *tmp_2 & 1; - *param_3 = (*tmp_2 & 0xE) >> 1; - *param_4 = (*tmp_2 & 0x1F0) >> 4; - break; - case 15: - *param_2 = (*tmp_2 & 0x200) >> 9; - *param_3 = (*tmp_2 & 0x1C00) >> 10; - *param_4 = (*tmp_2 & 0x3E000) >> 13; - break; - case 16: - *param_2 = (*tmp_2 & 0x40000) >> 0x12; - *param_3 = (*tmp_2 & 0x380000) >> 0x13; - *param_4 = (*tmp_2 & 0x7C00000) >> 0x16; - break; - case 17: - *param_2 = (*tmp_2 & 0x8000000) >> 0x1B; - *param_3 = (*tmp_2 & 0x70000000) >> 0x1C; - *param_4 = (*tmp_3 & 0x1F); - break; - case 18: - *param_2 = (*tmp_3 & 0x20) >> 5; - *param_3 = (*tmp_3 & 0x1C0) >> 6; - *param_4 = (*tmp_3 & 0x3E00) >> 9; - break; - case 19: - *param_2 = (*tmp_3 & 0x4000) >> 0xe; - *param_3 = (*tmp_3 & 0x38000) >> 0xf; - *param_4 = (*tmp_3 & 0x7c0000) >> 0x12; - break; - case 20: - *param_2 = (*tmp_3 & 0x800000) >> 0x17; - *param_3 = (*tmp_3 & 0x7000000) >> 0x18; - *param_4 = (*tmp_3 & 0xF8000000) >> 0x1b; - break; + *type = GET_REG_FIELD(*va, 3, 10); + *frac = GetFracForNrm(*type); + return; + case GX_VA_CLR0: + *cnt = GET_REG_FIELD(*va, 1, 13); + *type = GET_REG_FIELD(*va, 3, 14); + *frac = 0; + return; + case GX_VA_CLR1: + *cnt = GET_REG_FIELD(*va, 1, 17); + *type = GET_REG_FIELD(*va, 3, 18); + *frac = 0; + return; + case GX_VA_TEX0: + *cnt = GET_REG_FIELD(*va, 1, 21); + *type = GET_REG_FIELD(*va, 3, 22); + *frac = (u8)(*va >> 0x19U) & 0x1F; + return; + case GX_VA_TEX1: + *cnt = GET_REG_FIELD(*vb, 1, 0); + *type = GET_REG_FIELD(*vb, 3, 1); + *frac = (u8)(*vb >> 4U) & 0x1F; + return; + case GX_VA_TEX2: + *cnt = GET_REG_FIELD(*vb, 1, 9); + *type = GET_REG_FIELD(*vb, 3, 10); + *frac = (u8)(*vb >> 0xDU) & 0x1F; + return; + case GX_VA_TEX3: + *cnt = GET_REG_FIELD(*vb, 1, 18); + *type = GET_REG_FIELD(*vb, 3, 19); + *frac = (u8)(*vb >> 0x16U) & 0x1F; + return; + case GX_VA_TEX4: + *cnt = GET_REG_FIELD(*vb, 1, 27); + *type = GET_REG_FIELD(*vb, 3, 28); + *frac = GET_REG_FIELD(*vc, 5, 0); + return; + case GX_VA_TEX5: + *cnt = GET_REG_FIELD(*vc, 1, 5); + *type = GET_REG_FIELD(*vc, 3, 6); + *frac = (u8)(*vc >> 9U) & 0x1F; + return; + case GX_VA_TEX6: + *cnt = GET_REG_FIELD(*vc, 1, 14); + *type = GET_REG_FIELD(*vc, 3, 15); + *frac = (u8)(*vc >> 0x12) & 0x1F; + return; + case GX_VA_TEX7: + *cnt = GET_REG_FIELD(*vc, 1, 23); + *type = GET_REG_FIELD(*vc, 3, 24); + *frac = (int)(*vc >> 0x1BU); + return; default: - *param_2 = 1; - *param_3 = 0; - *param_4 = 0; + *cnt = GX_TEX_ST; + *type = GX_RGB565; + *frac = 0; + return; } } -void GXSetArray(GXAttr attr, void* basePtr, u8 stride) { - s32 newAttr; - s32 attrReg; +void GXGetVtxAttrFmtv(GXVtxFmt fmt, GXVtxAttrFmtList* vat) { + GXAttr attr; - newAttr = attr; - if (newAttr == GX_VA_NBT) { - newAttr = GX_VA_NRM; + for (attr = GX_VA_POS; attr <= GX_VA_TEX7; attr++) { + vat->attr = attr; + GXGetVtxAttrFmt(fmt, attr, &vat->cnt, &vat->type, &vat->frac); + vat++; } + vat->attr = GX_VA_NULL; +} - attrReg = newAttr - GX_VA_POS; +void GXSetArray(GXAttr attr, void* base_ptr, u8 stride) { + GXAttr cpAttr; + u32 phyAddr; - GX_CP_LOAD_REG(GX_BP_REG_SETMODE0_TEX4 | attrReg, - // Address -> offset? - (u32)basePtr & ~0xC0000000); - - GX_CP_LOAD_REG(GX_BP_REG_SETIMAGE2_TEX4 | attrReg, stride); + if (attr == GX_VA_NBT) { + attr = GX_VA_NRM; + } + cpAttr = attr - GX_VA_POS; + phyAddr = (u32)base_ptr & 0x3FFFFFFF; + GX_WRITE_SOME_REG2(8, cpAttr | GX_BP_REG_SETMODE0_TEX4, phyAddr, cpAttr - 12); + GX_WRITE_SOME_REG3(8, cpAttr | GX_BP_REG_SETIMAGE2_TEX4, stride, cpAttr - 12); } void GXInvalidateVtxCache(void) { GXFIFO.u8 = GX_FIFO_CMD_INVAL_VTX; } -void GXSetTexCoordGen2(GXTexCoordID id, GXTexGenType type, GXTexGenSrc src, u32 texMtxIdx, - GXBool normalize, u32 dualTexMtxIdx) { - u32 reg; - u32 inputRow; - GXXfTexReg inputForm; +void GXSetTexCoordGen2(GXTexCoordID dst_coord, GXTexGenType func, GXTexGenSrc src_param, u32 mtx, GXBool normalize, u32 pt_texmtx) { + u32 reg = 0; + u32 row; + u32 bumprow; // unused + u32 form; + GXAttr mtxIdAttr; - reg = 0; - inputForm = GX_XF_TEX_FORM_AB11; - inputRow = 5; - - switch (src) { - case GX_TG_POS: - inputRow = 0; - inputForm = GX_XF_TEX_FORM_ABC1; - break; - case GX_TG_NRM: - inputRow = 1; - inputForm = GX_XF_TEX_FORM_ABC1; - break; - case GX_TG_BINRM: - inputRow = 3; - inputForm = GX_XF_TEX_FORM_ABC1; - break; - case GX_TG_TANGENT: - inputRow = 4; - inputForm = GX_XF_TEX_FORM_ABC1; - break; - case GX_TG_COLOR0: - inputRow = 2; - break; - case GX_TG_COLOR1: - inputRow = 2; - break; - case GX_TG_TEX0: - inputRow = 5; - break; - case GX_TG_TEX1: - inputRow = 6; - break; - case GX_TG_TEX2: - inputRow = 7; - break; - case GX_TG_TEX3: - inputRow = 8; - break; - case GX_TG_TEX4: - inputRow = 9; - break; - case GX_TG_TEX5: - inputRow = 10; - break; - case GX_TG_TEX6: - inputRow = 11; - break; - case GX_TG_TEX7: - inputRow = 12; + form = 0; + row = 5; + switch (src_param) { + case GX_TG_POS: row = 0; form = 1; break; + case GX_TG_NRM: row = 1; form = 1; break; + case GX_TG_BINRM: row = 3; form = 1; break; + case GX_TG_TANGENT: row = 4; form = 1; break; + case GX_TG_COLOR0: row = 2; break; + case GX_TG_COLOR1: row = 2; break; + case GX_TG_TEX0: row = 5; break; + case GX_TG_TEX1: row = 6; break; + case GX_TG_TEX2: row = 7; break; + case GX_TG_TEX3: row = 8; break; + case GX_TG_TEX4: row = 9; break; + case GX_TG_TEX5: row = 10; break; + case GX_TG_TEX6: row = 11; break; + case GX_TG_TEX7: row = 12; break; + case GX_TG_TEXCOORD0: bumprow; break; + case GX_TG_TEXCOORD1: bumprow; break; + case GX_TG_TEXCOORD2: bumprow; break; + case GX_TG_TEXCOORD3: bumprow; break; + case GX_TG_TEXCOORD4: bumprow; break; + case GX_TG_TEXCOORD5: bumprow; break; + case GX_TG_TEXCOORD6: bumprow; break; + default: break; } - - switch (type) { - case GX_TG_NRM: - GX_SET_REG(reg, GX_XF_TEX_PROJ_ST, GX_XF_TEX_PROJTYPE_ST, - GX_XF_TEX_PROJTYPE_END); // 2x4 projection - GX_SET_REG(reg, inputForm, GX_XF_TEX_INPUTFORM_ST, GX_XF_TEX_INPUTFORM_END); - GX_SET_REG(reg, GX_TG_POS, GX_XF_TEX_TEXGENTYPE_ST, GX_XF_TEX_TEXGENTYPE_END); - GX_SET_REG(reg, inputRow, GX_XF_TEX_SRCROW_ST, GX_XF_TEX_SRCROW_END); + switch (func) + { + case GX_TG_MTX2x4: + SET_REG_FIELD(reg, 1, 1, 0); + SET_REG_FIELD(reg, 1, 2, form); + SET_REG_FIELD(reg, 3, 4, 0); + SET_REG_FIELD(reg, 5, 7, row); break; - case GX_TG_POS: - GX_SET_REG(reg, GX_XF_TEX_PROJ_STQ, GX_XF_TEX_PROJTYPE_ST, - GX_XF_TEX_PROJTYPE_END); // 3x4 projection - GX_SET_REG(reg, inputForm, GX_XF_TEX_INPUTFORM_ST, GX_XF_TEX_INPUTFORM_END); - GX_SET_REG(reg, GX_TG_POS, GX_XF_TEX_TEXGENTYPE_ST, GX_XF_TEX_TEXGENTYPE_END); - GX_SET_REG(reg, inputRow, GX_XF_TEX_SRCROW_ST, GX_XF_TEX_SRCROW_END); + case GX_TG_MTX3x4: + SET_REG_FIELD(reg, 1, 1, 1); + SET_REG_FIELD(reg, 1, 2, form); + SET_REG_FIELD(reg, 3, 4, 0); + SET_REG_FIELD(reg, 5, 7, row); break; - case GX_TG_BUMP0: - case GX_TG_BUMP1: - case GX_TG_BUMP2: - case GX_TG_BUMP3: - case GX_TG_BUMP4: - case GX_TG_BUMP5: - case GX_TG_BUMP6: - case GX_TG_BUMP7: - GX_SET_REG(reg, GX_XF_TEX_PROJ_ST, GX_XF_TEX_PROJTYPE_ST, - GX_XF_TEX_PROJTYPE_END); // 2x4 projection - GX_SET_REG(reg, inputForm, GX_XF_TEX_INPUTFORM_ST, GX_XF_TEX_INPUTFORM_END); - GX_SET_REG(reg, GX_TG_NRM, GX_XF_TEX_TEXGENTYPE_ST, GX_XF_TEX_TEXGENTYPE_END); - GX_SET_REG(reg, inputRow, GX_XF_TEX_SRCROW_ST, GX_XF_TEX_SRCROW_END); - GX_SET_REG(reg, src - GX_TG_TEXCOORD0, GX_XF_TEX_BUMPSRCTEX_ST, GX_XF_TEX_BUMPSRCTEX_END); - GX_SET_REG(reg, type - GX_TG_BUMP0, GX_XF_TEX_BUMPSRCLIGHT_ST, GX_XF_TEX_BUMPSRCLIGHT_END); + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + SET_REG_FIELD(reg, 1, 1, 0); + SET_REG_FIELD(reg, 1, 2, form); + SET_REG_FIELD(reg, 3, 4, 1); + SET_REG_FIELD(reg, 5, 7, row); + SET_REG_FIELD(reg, 3, 12, src_param - 12); + SET_REG_FIELD(reg, 3, 15, func - 2); break; case GX_TG_SRTG: - GX_SET_REG(reg, GX_XF_TEX_PROJ_ST, GX_XF_TEX_PROJTYPE_ST, - GX_XF_TEX_PROJTYPE_END); // 2x4 projection - GX_SET_REG(reg, inputForm, GX_XF_TEX_INPUTFORM_ST, GX_XF_TEX_INPUTFORM_END); - - if (src == GX_TG_COLOR0) { - GX_SET_REG(reg, GX_XF_TG_CLR0, GX_XF_TEX_TEXGENTYPE_ST, GX_XF_TEX_TEXGENTYPE_END); + SET_REG_FIELD(reg, 1, 1, 0); + SET_REG_FIELD(reg, 1, 2, form); + if (src_param == GX_TG_COLOR0) { + SET_REG_FIELD(reg, 3, 4, 2); } else { - GX_SET_REG(reg, GX_XF_TG_CLR1, GX_XF_TEX_TEXGENTYPE_ST, GX_XF_TEX_TEXGENTYPE_END); + SET_REG_FIELD(reg, 3, 4, 3); } - GX_SET_REG(reg, 2, GX_XF_TEX_SRCROW_ST, GX_XF_TEX_SRCROW_END); + SET_REG_FIELD(reg, 5, 7, 2); break; default: break; } - - GX_XF_LOAD_REG(GX_XF_REG_TEX0 + id, reg); - + GX_WRITE_XF_REG(dst_coord + 0x40, reg); reg = 0; - GX_SET_REG(reg, dualTexMtxIdx - 0x40, GX_XF_MTXIDX0_GEOM_ST, GX_XF_MTXIDX0_GEOM_END); - GX_SET_REG(reg, normalize, GX_XF_DUALTEX_NORMALISE_ST, GX_XF_DUALTEX_NORMALISE_END); - - GX_XF_LOAD_REG(GX_XF_REG_DUALTEX0 + id, reg); - - switch (id) { - case GX_TEXCOORD0: - GX_SET_REG(gx->matIdxA, texMtxIdx, GX_XF_MTXIDX0_TEX0_ST, GX_XF_MTXIDX0_TEX0_END); - break; - case GX_TEXCOORD1: - GX_SET_REG(gx->matIdxA, texMtxIdx, GX_XF_MTXIDX0_TEX1_ST, GX_XF_MTXIDX0_TEX1_END); - break; - case GX_TEXCOORD2: - GX_SET_REG(gx->matIdxA, texMtxIdx, GX_XF_MTXIDX0_TEX2_ST, GX_XF_MTXIDX0_TEX2_END); - break; - case GX_TEXCOORD3: - GX_SET_REG(gx->matIdxA, texMtxIdx, GX_XF_MTXIDX0_TEX3_ST, GX_XF_MTXIDX0_TEX3_END); - break; - case GX_TEXCOORD4: - GX_SET_REG(gx->matIdxB, texMtxIdx, GX_XF_MTXIDX1_TEX4_ST, GX_XF_MTXIDX1_TEX4_END); - break; - case GX_TEXCOORD5: - GX_SET_REG(gx->matIdxB, texMtxIdx, GX_XF_MTXIDX1_TEX5_ST, GX_XF_MTXIDX1_TEX5_END); - break; - case GX_TEXCOORD6: - GX_SET_REG(gx->matIdxB, texMtxIdx, GX_XF_MTXIDX1_TEX6_ST, GX_XF_MTXIDX1_TEX6_END); - break; - default: - GX_SET_REG(gx->matIdxB, texMtxIdx, GX_XF_MTXIDX1_TEX7_ST, GX_XF_MTXIDX1_TEX7_END); - break; + SET_REG_FIELD(reg, 6, 0, pt_texmtx - 64); + SET_REG_FIELD(reg, 1, 8, normalize); + GX_WRITE_XF_REG(dst_coord + 0x50, reg); + switch (dst_coord) { + case GX_TEXCOORD0: SET_REG_FIELD(gx->matIdxA, 6, 6, mtx); break; + case GX_TEXCOORD1: SET_REG_FIELD(gx->matIdxA, 6, 12, mtx); break; + case GX_TEXCOORD2: SET_REG_FIELD(gx->matIdxA, 6, 18, mtx); break; + case GX_TEXCOORD3: SET_REG_FIELD(gx->matIdxA, 6, 24, mtx); break; + case GX_TEXCOORD4: SET_REG_FIELD(gx->matIdxB, 6, 0, mtx); break; + case GX_TEXCOORD5: SET_REG_FIELD(gx->matIdxB, 6, 6, mtx); break; + case GX_TEXCOORD6: SET_REG_FIELD(gx->matIdxB, 6, 12, mtx); break; + default: SET_REG_FIELD(gx->matIdxB, 6, 18, mtx); break; } - __GXSetMatrixIndex(id + 1); + mtxIdAttr = dst_coord + 1; + __GXSetMatrixIndex(mtxIdAttr); } -void GXSetNumTexGens(u8 count) { - GX_SET_REG(gx->genMode, count, GX_BP_GENMODE_NUMTEX_ST, GX_BP_GENMODE_NUMTEX_END); - GX_XF_LOAD_REG(GX_XF_REG_NUMTEX, count); +void GXSetNumTexGens(u8 nTexGens) { + SET_REG_FIELD(gx->genMode, 4, 0, nTexGens); + GX_WRITE_XF_REG(0x3F, nTexGens); gx->dirtyState |= GX_DIRTY_GEN_MODE; } diff --git a/src/f_ap/f_ap_game.cpp b/src/f_ap/f_ap_game.cpp index 7764527a7..a50c248a0 100644 --- a/src/f_ap/f_ap_game.cpp +++ b/src/f_ap/f_ap_game.cpp @@ -16,7 +16,7 @@ fapGm_HIO_c g_HIO; /* 8002306C-800231BC .text __ct__11fapGm_HIO_cFv */ fapGm_HIO_c::fapGm_HIO_c() { - field_0x05 = 1; + mUsingHostIO = true; #if VERSION > VERSION_DEMO if (mDoMain::developmentMode) { @@ -45,25 +45,26 @@ fapGm_HIO_c::fapGm_HIO_c() { field_0x1a = 0; field_0x1b = 1; field_0x1c = 0; - mFbWidth = 0x280; - mEfbHeight = 0x1e0; + mFbWidth = 640; + mEfbHeight = 480; field_0x30 = 0; - field_0x20.r = 0xff; - field_0x20.g = 0xff; - field_0x20.b = 0xff; - field_0x20.a = 0xff; + + mColor = JUtility::TColor(0xff, 0xff, 0xff, 0xff); + mTriggerThreshLo = 0.9f; mTriggerThreshHi = 0.6f; - field_0x3c = JUtility::TColor(0xff, 0x96, 0x00, 0xff); - field_0x40 = JUtility::TColor(0xff, 0x78, 0x00, 0xff); - field_0x44 = JUtility::TColor(0x00, 0x00, 0x00, 0xff); - field_0x48 = JUtility::TColor(0x00, 0x00, 0x00, 0xff); - field_0x4c = 0; - field_0x4e = 10; - field_0x54 = 0x1b; - field_0x50 = 0; - field_0x52 = 0; - field_0x56 = 0x82; + + mLetterTopColor = JUtility::TColor(0xff, 0x96, 0x00, 0xff); + mLetterBottomColor = JUtility::TColor(0xff, 0x78, 0x00, 0xff); + mLetterTopShadowColor = JUtility::TColor(0x00, 0x00, 0x00, 0xff); + mLetterBottomShadowColor = JUtility::TColor(0x00, 0x00, 0x00, 0xff); + + mLetterPositionX = 0; + mLetterPositionY = 10; + mLetterFontSize = 27; + mLineSpacing = 0; + mLetterSpacing = 0; + mBackgroundAlpha = 130; } /* 800231BC-800231E4 .text fapGm_After__Fv */ diff --git a/src/f_op/f_op_actor_mng.cpp b/src/f_op/f_op_actor_mng.cpp index fcccd253c..730c82a5d 100644 --- a/src/f_op/f_op_actor_mng.cpp +++ b/src/f_op/f_op_actor_mng.cpp @@ -1127,7 +1127,7 @@ void* fopAcM_fastCreateItem(cXyz* pos, int i_itemNo, int roomNo, csXyz* angle, c #if VERSION > VERSION_DEMO /* 80027254-80027280 .text stealItem_CB__FPv */ -BOOL stealItem_CB(void* actor) { +static BOOL stealItem_CB(void* actor) { if (actor) { daItem_c* item = (daItem_c*)actor; item->scale.setall(1.0f); diff --git a/src/f_op/f_op_msg_mng.cpp b/src/f_op/f_op_msg_mng.cpp index b2ce7f1d5..7e4429706 100644 --- a/src/f_op/f_op_msg_mng.cpp +++ b/src/f_op/f_op_msg_mng.cpp @@ -3202,8 +3202,9 @@ u32 fopMsgM_msgDataProc_c::stringLength() { int r7 = sp18[sp14]; #if VERSION <= VERSION_JPN - sp18[sp14] = (int)((f32)sp0C + 0.5f); + sp18[sp14] = (int)(sp0C + 0.5f); #else + // Fakematch? Why the (f64) cast? sp18[sp14] = (int)((f32)(f64)sp0C + 0.5f); #endif if (!r27) { diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index 09c1f1078..0eaf2a156 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -159,15 +159,15 @@ int mDoExt_bpkAnm::init(J3DMaterialTable* i_matTable, J3DAnmColor* i_bpk, BOOL i if (i_anmPlay) { int attribute; - #if VERSION == VERSION_JPN +#if VERSION == VERSION_JPN if (i_attribute < 0) { attribute = mpAnm->getAttribute(); } else { attribute = i_attribute; } - #else +#else attribute = i_attribute; - #endif +#endif if (initPlay(mpAnm->getFrameMax(), attribute, i_rate, i_startF, i_endF, i_modify) == 0) { return 0; } @@ -260,7 +260,7 @@ int mDoExt_btkAnm::init(J3DMaterialTable* i_matTable, J3DAnmTextureSRTKey* i_btk J3DMaterial* material = i_matTable->getMaterialNodePointer(materialId); u8 texMtxId = mpAnm->getUpdateTexMtxID(i); if (texMtxId != 0xFF) { - J3DTexMtx* texMtx = material->getTexGenBlock()->getTexMtx(texMtxId); + J3DTexMtx* texMtx = material->getTexMtx(texMtxId); if (!texMtx) { texMtx = new J3DTexMtx(); } @@ -286,15 +286,15 @@ int mDoExt_btkAnm::init(J3DMaterialTable* i_matTable, J3DAnmTextureSRTKey* i_btk if (i_anmPlay) { int attribute; - #if VERSION == VERSION_JPN +#if VERSION == VERSION_JPN if (i_attribute < 0) { attribute = mpAnm->getAttribute(); } else { attribute = i_attribute; } - #else +#else attribute = i_attribute; - #endif +#endif if (initPlay(mpAnm->getFrameMax(), attribute, i_rate, i_startF, i_endF, i_modify) == 0) { return 0; } @@ -365,15 +365,15 @@ int mDoExt_brkAnm::init(J3DMaterialTable* i_matTable, J3DAnmTevRegKey* i_brk, BO if (i_anmPlay) { int attribute; - #if VERSION == VERSION_JPN +#if VERSION == VERSION_JPN if (i_attribute < 0) { attribute = mpAnm->getAttribute(); } else { attribute = i_attribute; } - #else +#else attribute = i_attribute; - #endif +#endif if (initPlay(mpAnm->getFrameMax(), attribute, i_rate, i_startF, i_endF, i_modify) == 0) { return 0; } @@ -405,15 +405,15 @@ int mDoExt_bvaAnm::init(J3DModel* i_model, J3DAnmVisibilityFull* i_bva, BOOL i_a } if (i_anmPlay) { int attribute; - #if VERSION == VERSION_JPN +#if VERSION == VERSION_JPN if (i_attribute < 0) { attribute = mpAnm->getAttribute(); } else { attribute = i_attribute; } - #else +#else attribute = i_attribute; - #endif +#endif if (initPlay(mpAnm->getFrameMax(), attribute, i_rate, i_startF, i_endF, i_modify) == 0) { return 0; } @@ -442,15 +442,15 @@ int mDoExt_bckAnm::init(J3DModelData* i_modelData, J3DAnmTransform* i_bck, BOOL } if (i_anmPlay) { int attribute; - #if VERSION == VERSION_JPN +#if VERSION == VERSION_JPN if (i_attribute < 0) { attribute = mpAnm->getAttribute(); } else { attribute = i_attribute; } - #else +#else attribute = i_attribute; - #endif +#endif if (initPlay(mpAnm->getFrameMax(), attribute, i_rate, i_startF, i_endF, i_modify) == 0) { return 0; } @@ -850,9 +850,9 @@ JKRExpHeap* gameHeap; JKRExpHeap* mDoExt_createGameHeap(u32 heapSize, JKRHeap* i_heap) { JUT_ASSERT(VERSION_SELECT(2036, 2035, 2050, 2050), gameHeap == NULL || heapSize == 0); gameHeap = JKRCreateExpHeap(heapSize, i_heap, true); - #if VERSION > VERSION_DEMO +#if VERSION > VERSION_DEMO gameHeap->setAllocationMode(JKRExpHeap::ALLOC_MODE_1); - #endif +#endif return gameHeap; } @@ -935,9 +935,9 @@ JKRExpHeap* archiveHeap; JKRExpHeap* mDoExt_createArchiveHeap(u32 heapSize, JKRHeap* i_heap) { JUT_ASSERT(VERSION_SELECT(2173, 2222, 2237, 2237), archiveHeap == NULL || heapSize == 0); archiveHeap = JKRCreateExpHeap(heapSize, i_heap, true); - #if VERSION > VERSION_DEMO +#if VERSION > VERSION_DEMO archiveHeap->setAllocationMode(JKRExpHeap::ALLOC_MODE_1); - #endif +#endif return archiveHeap; } @@ -955,25 +955,28 @@ s32 mDoExt_getSafeArchiveHeapSize() { } #endif +#if VERSION == VERSION_DEMO +static u8 archiveHeapGroupID; +#endif + JKRHeap* mDoExt_SaveCurrentHeap; #if VERSION == VERSION_DEMO -static u8 archiveHeapGroupID; static u8 SolidHeapGroupID; #endif /* 80011AB4-80011ABC .text mDoExt_getArchiveHeap__Fv */ JKRExpHeap* mDoExt_getArchiveHeap() { - #if VERSION == VERSION_DEMO +#if VERSION == VERSION_DEMO JKRExpHeap* heap = archiveHeap; heap->changeGroupID(archiveHeapGroupID++); if (archiveHeapGroupID >= 200) { archiveHeapGroupID = 0; } return heap; - #else +#else return archiveHeap; - #endif +#endif } static void dummy() { @@ -993,9 +996,9 @@ JKRSolidHeap* mDoExt_createSolidHeap(u32 i_size, JKRHeap* i_heap, u32 i_alignmen u32 size; JKRSolidHeap* createdHeap; - #if VERSION == VERSION_DEMO +#if VERSION == VERSION_DEMO u8 groupID = i_heap->changeGroupID(SolidHeapGroupID); - #endif +#endif if (i_size == 0 || i_size == -1) { createdHeap = JKRSolidHeap::create(-1, i_heap, false); @@ -1010,15 +1013,15 @@ JKRSolidHeap* mDoExt_createSolidHeap(u32 i_size, JKRHeap* i_heap, u32 i_alignmen createdHeap = JKRSolidHeap::create(size, i_heap, false); } - #if VERSION == VERSION_DEMO +#if VERSION == VERSION_DEMO i_heap->changeGroupID(groupID); - #endif +#endif if (createdHeap != NULL) { createdHeap->setErrorFlag(true); } - #if VERSION == VERSION_DEMO +#if VERSION == VERSION_DEMO if (createdHeap == NULL) { // "mDoExt_createMaxSolidHeap: Failed to allocate a %fK solid heap. Contiguous free space=%fK Remaining free space=%f\n" OSReport_Warning( @@ -1034,7 +1037,7 @@ JKRSolidHeap* mDoExt_createSolidHeap(u32 i_size, JKRHeap* i_heap, u32 i_alignmen } else { SolidHeapGroupID = SolidHeapGroupID < 199 ? (u8)(SolidHeapGroupID + 1) : 0; } - #endif +#endif return createdHeap; } @@ -1055,9 +1058,9 @@ JKRSolidHeap* mDoExt_createSolidHeapToCurrent(u32 i_size, JKRHeap* i_parent, u32 if (!resultHeap) { return NULL; } - #if VERSION > VERSION_DEMO +#if VERSION > VERSION_DEMO JUT_ASSERT(VERSION_SELECT(0, 2530, 2545, 2545), OSGetCurrentThread() == &mainThread); - #endif +#endif JUT_ASSERT(VERSION_SELECT(2441, 2531, 2546, 2546), mDoExt_SaveCurrentHeap == NULL); mDoExt_SaveCurrentHeap = JKRGetCurrentHeap(); mDoExt_setCurrentHeap(resultHeap); @@ -1102,9 +1105,9 @@ JKRHeap* mDoExt_getCurrentHeap() { /* 80011DDC-80011E98 .text mDoExt_restoreCurrentHeap__Fv */ void mDoExt_restoreCurrentHeap() { - #if VERSION > VERSION_DEMO +#if VERSION > VERSION_DEMO JUT_ASSERT(VERSION_SELECT(0, 2739, 2754, 2754), OSGetCurrentThread() == &mainThread); - #endif +#endif JUT_ASSERT(VERSION_SELECT(2647, 2740, 2755, 2755), mDoExt_SaveCurrentHeap != NULL); mDoExt_SaveCurrentHeap->becomeCurrentHeap(); mDoExt_SaveCurrentHeap = NULL; @@ -1136,6 +1139,7 @@ void mDoExt_MtxCalcAnmBlendTbl::calc(u16 jnt_no) { Quaternion quat3; mAnmRatio->getAnmTransform()->getTransform(jnt_no, &info2); JMAEulerToQuat(info2.mRotation.x, info2.mRotation.y, info2.mRotation.z, &quat1); + f32 f30 = mAnmRatio[0].getRatio(); quat3 = quat1; for (int i = 1; i < mNum; i++) { J3DAnmTransform* transform = mAnmRatio[i].getAnmTransform(); @@ -1143,7 +1147,7 @@ void mDoExt_MtxCalcAnmBlendTbl::calc(u16 jnt_no) { J3DTransformInfo info3; transform->getTransform(jnt_no, &info3); f32 ratio = mAnmRatio[i].getRatio(); - f32 f30 = 1.0f - ratio; + f30 = 1.0f - ratio; JMAEulerToQuat(info3.mRotation.x, info3.mRotation.y, info3.mRotation.z, &quat2); JMAQuatLerp(&quat1, &quat2, ratio, &quat3); quat1 = quat3; @@ -1316,7 +1320,7 @@ mDoExt_McaMorf::mDoExt_McaMorf(J3DModelData* modelData, mDoExt_McaMorfCallBack1_ J3DTransformInfo* info = mpTransformInfo; Quaternion* quat = mpQuat; J3DModelData* r23 = mpModel->getModelData(); - u16 jointNum = r23->getJointNum(); + int jointNum = r23->getJointNum(); for (int i = 0; i < jointNum; i++) { *info = r23->getJointNodePointer(i)->getTransformInfo(); JMAEulerToQuat(info->mRotation.x, info->mRotation.y, info->mRotation.z, quat); @@ -1604,7 +1608,7 @@ mDoExt_McaMorf2::mDoExt_McaMorf2(J3DModelData* modelData, mDoExt_McaMorfCallBack J3DTransformInfo* info = mpTransformInfo; Quaternion* quat = mpQuat; J3DModelData* r23 = mpModel->getModelData(); - u16 jointNum = r23->getJointNum(); + int jointNum = r23->getJointNum(); for (int i = 0; i < jointNum; i++) { *info = r23->getJointNodePointer(i)->getTransformInfo(); JMAEulerToQuat(info->mRotation.x, info->mRotation.y, info->mRotation.z, quat); @@ -1954,9 +1958,9 @@ void mDoExt_3DlineMat0_c::setMaterial() { {0xC0, 0x00, 0x00}, }; j3dSys.reinitGX(); - #if VERSION > VERSION_JPN +#if VERSION > VERSION_JPN GXSetNumIndStages(0); - #endif +#endif dKy_setLight_again(); GXClearVtxDesc(); @@ -2220,9 +2224,9 @@ void mDoExt_3DlineMat1_c::setMaterial() { {0xC0, 0x00, 0x00}, }; j3dSys.reinitGX(); - #if VERSION > VERSION_JPN +#if VERSION > VERSION_JPN GXSetNumIndStages(0); - #endif +#endif dKy_setLight_again(); GXClearVtxDesc(); @@ -2341,7 +2345,7 @@ void mDoExt_3DlineMat1_c::update(u16 i_segs, f32 i_size, GXColor& i_color, u16 i delta = delta.outprod(eyeDelta); f32 scale = delta.abs(); if (scale != 0.0f) { - scale = i_size / scale; + scale = r_size / scale; delta *= scale; } @@ -2531,9 +2535,9 @@ void mDoExt_3DlineMatSortPacket::draw() { lineMat->draw(); lineMat = lineMat->mpNextLineMat; } while (lineMat); - #if VERSION > VERSION_JPN +#if VERSION > VERSION_JPN J3DShape::resetVcdVatCache(); - #endif +#endif } /* 800165E4-8001683C .text mDoExt_initFontCommon__FPP7JUTFontPP7ResFONTP7JKRHeapPCcP10JKRArchiveUcUlUl */ @@ -2549,11 +2553,11 @@ void mDoExt_initFontCommon(JUTFont** p_font, ResFONT** p_resfont, JKRHeap* p_hea JUT_ASSERT(VERSION_SELECT(6544, 6637, 6651, 6651), mDoExt_resfont != NULL); if (param_6 == 0) { - #if VERSION <= VERSION_JPN +#if VERSION <= VERSION_JPN u32 temp = (param_8 + 0x40) * param_7; - #else +#else u32 temp = (((param_8+0x1F) & ~0x1F) + 0x40) * param_7; - #endif +#endif JUTCacheFont* cacheFont = new(p_heap, 0) JUTCacheFont(*p_resfont, temp, p_heap); if (cacheFont->isValid()) { *p_font = cacheFont; @@ -2576,18 +2580,29 @@ void mDoExt_initFontCommon(JUTFont** p_font, ResFONT** p_resfont, JKRHeap* p_hea JUT_ASSERT(VERSION_SELECT(6575, 6668, 6685, 6685), mDoExt_font != NULL); } +#if VERSION == VERSION_DEMO JUTFont* mDoExt_font0; -ResFONT* mDoExt_resfont0; +JUTFont* mDoExt_font1; s32 mDoExt_font0_getCount; +s32 mDoExt_font1_getCount; +ResFONT* mDoExt_resfont0; +ResFONT* mDoExt_resfont1; +#else +JUTFont* mDoExt_font0; +s32 mDoExt_font0_getCount; +ResFONT* mDoExt_resfont0; +JUTFont* mDoExt_font1; +s32 mDoExt_font1_getCount; +ResFONT* mDoExt_resfont1; +#endif #if VERSION <= VERSION_JPN void mDoExt_initFont0() { - /* Nonmatching */ - static const char* fontdata[] = { + static const char* const fontdata[] = { "rock_24_20_4i1.bfn", "rock_e_24_20_4i.bfn", }; - u8 r30 = g_msgDHIO.field_0x08; + const u8 r30 = g_msgDHIO.field_0x08; mDoExt_initFontCommon(&mDoExt_font0, &mDoExt_resfont0, mDoExt_getZeldaHeap(), fontdata[r30], dComIfGp_getFontArchive(), r30, 0xB4, 0x800); } #else @@ -2598,10 +2613,6 @@ void mDoExt_initFont0() { } #endif -JUTFont* mDoExt_font1; -ResFONT* mDoExt_resfont1; -s32 mDoExt_font1_getCount; - #if VERSION <= VERSION_JPN void mDoExt_initFont1() { mDoExt_initFontCommon(&mDoExt_font1, &mDoExt_resfont1, mDoExt_getZeldaHeap(), "rodb_16_11_4i.bfn", dComIfGp_getRubyArchive(), 1, 1, 0x8000); @@ -2640,11 +2651,11 @@ void mDoExt_removeMesgFont() { mDoExt_font0 = NULL; if (mDoExt_resfont0) { - #if VERSION <= VERSION_JPN +#if VERSION <= VERSION_JPN if (g_msgDHIO.field_0x08 == 0) { JKRFileLoader::removeResource(mDoExt_resfont0, NULL); } else - #endif +#endif { JKRHeap::free(mDoExt_resfont0, NULL); } @@ -2657,12 +2668,12 @@ void mDoExt_removeMesgFont() { #if VERSION > VERSION_JPN /* 80016A1C-80016A7C .text mDoExt_initFont1__Fv */ void mDoExt_initFont1() { - #if VERSION <= VERSION_JPN +#if VERSION <= VERSION_JPN mDoExt_initFontCommon(&mDoExt_font1, &mDoExt_resfont1, mDoExt_getZeldaHeap(), "rodb_16_11_4i.bfn", dComIfGp_getRubyArchive(), 1, 1, 0x8000); - #else +#else static const char fontdata[] = "hyrule.bfn"; mDoExt_initFontCommon(&mDoExt_font1, &mDoExt_resfont1, mDoExt_getZeldaHeap(), fontdata, dComIfGp_getRubyArchive(), 1, 1, 0x8000); - #endif +#endif } #endif