From 6812d925ff1d919f7baf1475aa71f714e25136c9 Mon Sep 17 00:00:00 2001 From: Mattias Blum <142374929+mattias-blum@users.noreply.github.com> Date: Sun, 5 Jul 2026 13:49:57 -0400 Subject: [PATCH] d_a_npc_mt 100% for GZLE01 (#1102) * d_a_npc_mt 100% for GZLE01 * implemented dPb_erasePicture and added some relevant inlines * fixed existing references to mSelectPicture * PR changes made --- configure.py | 2 +- include/d/actor/d_a_npc_mt.h | 116 +++- include/d/d_com_inf_game.h | 17 +- include/d/d_snap.h | 2 +- src/d/actor/d_a_npc_mt.cpp | 1247 ++++++++++++++++++++++++++++++++-- src/d/d_com_inf_game.cpp | 2 +- src/d/d_picture_box.cpp | 9 +- 7 files changed, 1288 insertions(+), 107 deletions(-) diff --git a/configure.py b/configure.py index af0d3a9ad..229f76e71 100755 --- a/configure.py +++ b/configure.py @@ -1684,7 +1684,7 @@ config.libs = [ ActorRel(Matching, "d_a_npc_ls1"), ActorRel(NonMatching, "d_a_npc_mk"), ActorRel(NonMatching, "d_a_npc_mn"), - ActorRel(NonMatching, "d_a_npc_mt"), + ActorRel(MatchingFor("GZLE01"), "d_a_npc_mt"), ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_npc_nz"), ActorRel(NonMatching, "d_a_npc_ob1"), ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_npc_os"), diff --git a/include/d/actor/d_a_npc_mt.h b/include/d/actor/d_a_npc_mt.h index b3d2679b1..5ecf4098d 100644 --- a/include/d/actor/d_a_npc_mt.h +++ b/include/d/actor/d_a_npc_mt.h @@ -8,9 +8,45 @@ #include "d/d_npc.h" struct sMtAnmDat { - + /* 0x00 */ u8 field_0x00; + /* 0x01 */ u8 field_0x01; + /* 0x02 */ u8 field_0x02; }; +struct NpcDatStruct { + /* 0x00 */ s16 mMax_head_x; + /* 0x02 */ s16 mMax_head_y; + /* 0x04 */ s16 mMax_backbone_x; + /* 0x06 */ s16 mMax_backbone_y; + /* 0x08 */ s16 mMin_head_x; + /* 0x0A */ s16 mMin_head_y; + /* 0x0C */ s16 mMin_backbone_x; + /* 0x0E */ s16 mMin_backbone_y; + /* 0x10 */ s16 mMax_turn_step; + /* 0x12 */ s16 field_0x12; + /* 0x14 */ f32 field_0x14; + /* 0x18 */ f32 field_0x18; + /* 0x1C */ f32 field_0x1C; + /* 0x20 */ f32 field_0x20; + /* 0x24 */ f32 field_0x24; + /* 0x28 */ s16 field_0x28; + /* 0x2A */ s16 field_0x2A; + /* 0x2C */ s16 field_0x2C; + /* 0x2E */ s16 field_0x2E; + /* 0x30 */ f32 field_0x30; + /* 0x34 */ f32 field_0x34; + /* 0x38 */ f32 field_0x38; + /* 0x3C */ s16 field_0x3C; + /* 0x3E */ s16 field_0x3E; + /* 0x40 */ s16 field_0x40; + /* 0x42 */ s16 field_0x42; + /* 0x44 */ s16 field_0x44; + /* 0x46 */ s16 field_0x46; + /* 0x48 */ s16 field_0x48; + /* 0x4A */ s8 field_0x4A; + /* 0x4B */ s8 field_0x4B; +}; // Size: 0x4c + class daNpcMt_c : public fopNpc_npc_c { public: void attnOff() { @@ -25,73 +61,99 @@ public: daNpcMt_c(); cPhs_State _create(); - void createHeap(); - void createInit(); + BOOL createHeap(); + cPhs_State createInit(); bool _delete(); bool _draw(); bool _execute(); - void executeCommon(); + BOOL executeCommon(); void executeSetMode(u8); - void executeWaitInit(); + s32 executeWaitInit(); void executeWait(); - void executeTalkInit(); + s32 executeTalkInit(); void executeTalk(); void checkOrder(); void eventOrder(); void eventMove(); void privateCut(); void eventMesSetInit(int); - void eventMesSet(); + bool eventMesSet(); void eventGetItemInit(); - void talk2(int); + u16 talk2(int); u16 next_msgStatus(u32*); u32 getMsg(); void chkMsg(); void setMessage(u32); void setAnmFromMsgTag(); - void getPrmNpcNo(); + u8 getPrmNpcNo(); void setMtx(); void chkAttention(); void lookBack(); - void initTexPatternAnm(bool); + BOOL initTexPatternAnm(bool); void playTexPatternAnm(); void playAnm(); void setAnm(u8, int, f32); - void setAnmTbl(sMtAnmDat*); - void XyCheckCB(int); + bool setAnmTbl(sMtAnmDat*); + s16 XyCheckCB(int); void setCollision(dCcD_Cyl*, cXyz, f32, f32); - void chkEndEvent(); - bool isFigureGet(u8); + BOOL chkEndEvent(); + u8 isFigureGet(u8); void setFigure(u8); int getFigureMakeNum(); - bool isComp(); - void changePhotoNo(u8); + BOOL isComp(); + u8 changePhotoNo(u8); + + static const char m_arcname[6]; public: + typedef s32(daNpcMt_c::*InitFunc_t)(); + typedef void(daNpcMt_c::*MoveFunc_t)(); + /* 0x6C4 */ request_of_phase_process_class mPhsArcname; /* 0x6CC */ request_of_phase_process_class mPhs; - /* 0x6D4 */ u8 m6D4[0x6D8 - 0x6D4]; + /* 0x6D4 */ J3DAnmTexPattern* m_head_tex_pattern; /* 0x6D8 */ mDoExt_btpAnm mBtpAnm; - /* 0x6EC */ u8 m6EC[0x710 - 0x6EC]; + /* 0x6EC */ s32 mShadowId; + /* 0x6F0 */ u32 m6F0; + /* 0x6F4 */ u8 m6F4[0x704 - 0x6F4]; + /* 0x704 */ cXyz mLookAtPos; /* 0x710 */ sMtAnmDat* mpAnmDat; - /* 0x714 */ int* mpMsgTbl; - /* 0x718 */ u8 m718[0x71C - 0x718]; + /* 0x714 */ u32* mpMsgTbl; + /* 0x718 */ f32 m718; /* 0x71C */ f32 m71C; - /* 0x720 */ u8 m720[0x72A - 0x720]; + /* 0x720 */ f32 m720; + /* 0x724 */ s32 mItemNo; + /* 0x728 */ bool m728; + /* 0x729 */ u8 m729; /* 0x72A */ s16 mMtGetItemEventIdx; - /* 0x72C */ u8 m72C[0x732 - 0x72C]; + /* 0x72C */ s16 m72C; + /* 0x72E */ s16 m72E; + /* 0x730 */ s16 m730; /* 0x732 */ s16 m732; - /* 0x734 */ u8 m734[0x742 - 0x734]; + /* 0x734 */ u16 m734; + /* 0x736 */ s16 m736; + /* 0x738 */ u8 m738[0x73A - 0x738]; + /* 0x73A */ s16 mTimer; + /* 0x73C */ s16 m73C; + /* 0x73E */ s16 m73E; + /* 0x740 */ s16 m740; /* 0x742 */ u8 m742; - /* 0x743 */ u8 m743[0x747 - 0x743]; + /* 0x743 */ u8 m743; + /* 0x744 */ u8 m744; + /* 0x745 */ u8 mFrame; + /* 0x746 */ u8 m746; /* 0x747 */ u8 m747; /* 0x748 */ u8 mPrmNpcNo; - /* 0x749 */ u8 m749[0x74A - 0x749]; + /* 0x749 */ u8 m749; /* 0x74A */ u8 m74A; - /* 0x74B */ u8 m74B[0x750 - 0x74B]; + /* 0x74B */ u8 mAnmFlag; + /* 0x74C */ s8 m74C; + /* 0x74D */ s8 m74D; + /* 0x74E */ u8 m74E; + /* 0x74F */ s8 m74F; /* 0x750 */ u8 m750; /* 0x751 */ u8 m751; - /* 0x752 */ u8 m752[0x753 - 0x752]; + /* 0x752 */ u8 m752; /* 0x753 */ bool m753; /* 0x754 */ u8 m754[0x758 - 0x754]; }; diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index f491e6988..ee23598c2 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -619,6 +619,9 @@ public: mPictureFlag &= ~mask; } u8 getPictureFormat() { return mPictureFormat; } + void setPictureFormat(u8 i) { mPictureFormat = i; } + u8 getSelectPicture() { return mSelectPicture; } + void setSelectPicture(u8 i) { mSelectPicture = i; } u8 getPictureResult() { return mPictureResult; } u8 getPictureResultDetail() { return mPictureResultDetail; } void setBossBattleData(JKRAramBlock* aramBlock, int i) { mBossBattleData[i] = aramBlock; } @@ -825,7 +828,7 @@ public: /* 0x495E */ u8 mPictureStatus; /* 0x495F */ u8 field_0x495f; /* 0x4960 */ u8 mPictureFormat; - /* 0x4961 */ u8 field_0x4961; + /* 0x4961 */ u8 mSelectPicture; /* 0x4962 */ u8 mHeapLockFlag; #if VERSION > VERSION_DEMO /* 0x4963 */ u8 mNowVibration; @@ -3192,6 +3195,18 @@ inline u8 dComIfGp_getPictureFormat() { return g_dComIfG_gameInfo.play.getPictureFormat(); } +inline void dComIfGp_setPictureFormat(u8 i) { + g_dComIfG_gameInfo.play.setPictureFormat(i); +} + +inline u8 dComIfGp_getSelectPicture() { + return g_dComIfG_gameInfo.play.getSelectPicture(); +} + +inline void dComIfGp_setSelectPicture(u8 i) { + g_dComIfG_gameInfo.play.setSelectPicture(i); +} + inline u8 dComIfGp_getPictureResult() { return g_dComIfG_gameInfo.play.getPictureResult(); } diff --git a/include/d/d_snap.h b/include/d/d_snap.h index a5e0a54c1..0350b299f 100644 --- a/include/d/d_snap.h +++ b/include/d/d_snap.h @@ -172,7 +172,7 @@ enum { /* 0xA4 */ DSNAP_TYPE_UNKA4, /* 0xA5 */ DSNAP_TYPE_UNKA5, /* 0xA6 */ DSNAP_TYPE_UNKA6, - /* 0xA7 */ DSNAP_TYPE_UNKA7, + /* 0xA7 */ DSNAP_TYPE_NPC_MT, /* 0xA8 */ DSNAP_TYPE_UNKA8, /* 0xA9 */ DSNAP_TYPE_UNKA9, /* 0xAA */ DSNAP_TYPE_BK, diff --git a/src/d/actor/d_a_npc_mt.cpp b/src/d/actor/d_a_npc_mt.cpp index 3d3aef516..3bec1b7db 100644 --- a/src/d/actor/d_a_npc_mt.cpp +++ b/src/d/actor/d_a_npc_mt.cpp @@ -1,14 +1,306 @@ -// -// Generated by dtk -// Translation Unit: d_a_npc_mt.cpp -// +/** + * d_a_npc_mt.cpp + * NPC - Carlov + */ #include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_npc_mt.h" +#include "d/d_com_lib_game.h" #include "d/d_com_inf_game.h" +#include "d/d_snap.h" +#include "d/d_picture_box.h" +#include "res/Object/Niten.h" #define TOTAL_FIGURE_COUNT 0x86 +const char daNpcMt_c::m_arcname[] = "Niten"; + +static char* l_npc_staff_id[] = { + "Mt" +}; + +static const char* l_arcname_tbl[] = { + "Niten" +}; + +static const int l_bmd_ix_tbl[] = { + dRes_ID_NITEN_BDL_MT_e, +}; + +static const int l_bck_ix_tbl[] = { + dRes_ID_NITEN_BCK_MT_WAIT01_e, + dRes_ID_NITEN_BCK_MT_TALK01_e, + dRes_ID_NITEN_BCK_MT_TALK02_e, + dRes_ID_NITEN_BCK_MT_TALK03_e, + dRes_ID_NITEN_BCK_MT_TALK04_e, + dRes_ID_NITEN_BCK_MT_TUKURU_e, +}; + +static const int l_btp_ix_tbl[] = { + dRes_ID_NITEN_BTP_MT_MABA_e, +}; + +static sMtAnmDat l_npc_anm_wait[] = { + { + 0x00, + 0x08, + 0xFF, + }, +}; + +static sMtAnmDat l_npc_anm_talk[] = { + { + 0x01, + 0x08, + 0xFF, + }, +}; + +static sMtAnmDat l_npc_anm_talk2[] = { + { + 0x02, + 0x08, + 0xFF, + }, +}; + +static sMtAnmDat l_npc_anm_talk3[] = { + { + 0x03, + 0x08, + 0xFF, + }, +}; + +static sMtAnmDat l_npc_anm_talk4[] = { + { + 0x04, + 0x08, + 0xFF, + }, +}; + +static sMtAnmDat l_npc_anm_talk5[] = { + { + 0x04, + 0x08, + 0x02, + }, + + { + 0x01, + 0x08, + 0xFF, + }, +}; + +static sMtAnmDat l_npc_anm_tukuru[] = { + { + 0x05, + 0x08, + 0x01, + }, + + { + 0x00, + 0x08, + 0xFF, + }, +}; + +static NpcDatStruct l_npc_dat[] = { + { + 0x0FA0, + 0x1B58, + 0, + 0, + 0xF448, + 0xE4A8, + 0, + 0, + 0x01F4, + 0, + 0, + 190.0f, + 150.0f, + 250.0f, + 400.0f, + 0x4000, + 0x0800, + 0x0190, + 0, + 60.0f, + 0.5f, + 3.0f, + 0x0006, + 0x0400, + 0x003C, + 0x005A, + 0x00C8, + 0x012C, + 0x001E, + false, + true, + }, +}; + +static u32 l_msg_mt_1st_talk[] = { + 0x365E, + 0x365F, + 0x3660, + 0x3661, + 0x3662, + 0x3663, + 0x3664, + 0x0000, +}; + +static u32 l_msg_mt_2nd_talk[] = { + 0x3665, + 0x3666, + 0x3667, + 0x0000, +}; + +static u32 l_msg_mt_3rd_talk[] = { + 0x3668, + 0x0000, +}; + +static u32 l_msg_mt_4th_talk[] = { + 0x3669, + 0x0000, +}; + +static u32 l_msg_mt_making[] = { + 0x3654, + 0x0000, +}; + +static u32 l_msg_mt_1st_kansei[] = { + 0x364D, + 0x364E, + 0x3650, + 0x0001, + 0x0000, +}; + +static u32 l_msg_mt_2nd_kansei[] = { + 0x364D, + 0x364F, + 0x3650, + 0x0001, + 0x0000, +}; + +static u32 l_msg_mt_room[] = { + 0x366B, + 0x366B, + 0x366C, + 0x366D, + 0x366E, + 0x366F, + 0x3670, + 0x3671, +}; + +static u32 l_msg_mt_gallery[] = { + 0x3651, + 0x0000, +}; + +static u32 l_msg_mt_room_in[] = { + 0x3652, + 0x0000, +}; + +static u32 l_msg_mt_kansei_end[] = { + 0x3653, + 0x0000, +}; + +static u32 l_msg_mt_no_color[] = { + 0x3655, + 0x0000, +}; + +static u32 l_msg_mt_no_figure[] = { + 0x3656, + 0x0000, +}; + +static u32 l_msg_mt_maked[] = { + 0x3658, + 0x0000, +}; + +static u32 l_msg_mt_face_ng[] = { + 0x3659, + 0x0000, +}; + +static u32 l_msg_mt_body_ng[] = { + 0x365A, + 0x0000, +}; + +static u32 l_msg_mt_make_1st[] = { + 0x365B, + 0x3674, + 0x365C, + 0x0002, +}; + +static u32 l_msg_mt_make_2nd[] = { + 0x365B, + 0x3674, + 0x365D, + 0x0002, +}; + +static u32 l_msg_mt_make_1st_mt[] = { + 0x3672, + 0x3674, + 0x365C, + 0x0002, +}; + +static u32 l_msg_mt_make_2nd_mt[] = { + 0x3672, + 0x3674, + 0x365D, + 0x0002, +}; + +static u32 l_msg_mt_make_1st_mn[] = { + 0x3673, + 0x3674, + 0x365C, + 0x0002, +}; + +static u32 l_msg_mt_make_2nd_mn[] = { + 0x3673, + 0x3674, + 0x365D, + 0x0002, +}; + +static u32* l_msg_mt_make[] = { + l_msg_mt_make_1st, + l_msg_mt_make_2nd, +}; + +static u32* l_msg_mt_make_mt[] = { + l_msg_mt_make_1st_mt, + l_msg_mt_make_2nd_mt, +}; + +static u32* l_msg_mt_make_mn[] = { + l_msg_mt_make_1st_mn, + l_msg_mt_make_2nd_mn, +}; + static u16 l_figure_comp[] = { dSv_event_flag_c::UNK_95FF, dSv_event_flag_c::UNK_94FF, @@ -29,224 +321,1019 @@ static u16 l_figure_comp[] = { dSv_event_flag_c::UNK_80FF, }; +static char* l_figure_room_name[] = { + "Pfigure", + "figureA", + "figureB", + "figureC", + "figureD", + "figureE", + "figureF", + "figureG", +}; + /* 00000078-00000228 .text __ct__9daNpcMt_cFv */ daNpcMt_c::daNpcMt_c() { - /* Nonmatching */ + mPrmNpcNo = getPrmNpcNo(); + m747 = 0; + m746 = 0; + m718 = 0.0f; + m72C = 0; + m71C = -1.0f; + m74F = 0; + m728 = 1; + m732 = home.angle.y; + m74A = 0; + m736 = 0; } /* 000005D8-000006F4 .text daNpc_Mt_nodeCallBack__FP7J3DNodei */ -static BOOL daNpc_Mt_nodeCallBack(J3DNode*, int) { - /* Nonmatching */ +static BOOL daNpc_Mt_nodeCallBack(J3DNode* node, int calcTiming) { + if (calcTiming == 0) { + J3DModel* model = j3dSys.getModel(); + daNpcMt_c* i_this = (daNpcMt_c*)model->getUserArea(); + J3DJoint* joint = (J3DJoint*)node; + s32 jntNo = joint->getJntNo(); + + cMtx_copy(model->getAnmMtx(jntNo), *calc_mtx); + + if(jntNo == i_this->m_jnt.getHeadJntNum()) { + mDoMtx_XrotM(*calc_mtx, i_this->m_jnt.getHead_y()); + mDoMtx_ZrotM(*calc_mtx, -i_this->m_jnt.getHead_x()); + } + + else if(jntNo == i_this->m_jnt.getBackboneJntNum()) { + mDoMtx_XrotM(*calc_mtx, i_this->m_jnt.getBackbone_y()); + mDoMtx_ZrotM(*calc_mtx, -i_this->m_jnt.getBackbone_x()); + } + + model->setAnmMtx(jntNo, *calc_mtx); + cMtx_copy(*calc_mtx, J3DSys::mCurrentMtx); + } + return TRUE; } /* 000006F4-00000714 .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(); } /* 00000714-00000858 .text phase_1__FP9daNpcMt_c */ -void phase_1(daNpcMt_c*) { - /* Nonmatching */ +static cPhs_State phase_1(daNpcMt_c* i_this) { + BOOL bVar1 = FALSE; + cPhs_State phase_state = cPhs_NEXT_e; + + fopAcM_ct(i_this, daNpcMt_c); + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_3D08)) { + bVar1 = TRUE; + } + else if (!dComIfGp_getStartStagePoint()) { + if (i_this->isComp()) { + bVar1 = TRUE; + dComIfGs_onEventBit(dSv_event_flag_c::UNK_3D08); + } + else { + dComIfGs_offTmpBit(dSv_event_tmp_flag_c::UNK_0202); + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_4080)) { + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_2F01); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3F01); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4040); + } + } + } + + if (bVar1) { + i_this->setFigure(0x40); + phase_state = cPhs_STOP_e; + } + else { + i_this->m747 = 1; + phase_state = cPhs_NEXT_e; + } + return phase_state; } /* 00000858-000008D8 .text phase_2__FP9daNpcMt_c */ -void phase_2(daNpcMt_c*) { - /* Nonmatching */ +static cPhs_State phase_2(daNpcMt_c* i_this) { + cPhs_State phase_state = dComIfG_resLoad(&i_this->mPhsArcname, l_arcname_tbl[i_this->mPrmNpcNo]); + if (phase_state == cPhs_COMPLEATE_e) { + if (fopAcM_entrySolidHeap(i_this, CheckCreateHeap, 0x2900)) { + return i_this->createInit(); + } else { + i_this->mpMorf = NULL; + return cPhs_ERROR_e; + } + } + return phase_state; } /* 000008D8-00000908 .text _create__9daNpcMt_cFv */ cPhs_State daNpcMt_c::_create() { - /* Nonmatching */ + static cPhs__Handler l_method[] = { + (cPhs__Handler)phase_1, + (cPhs__Handler)phase_2, + NULL, + }; + return dComLbG_PhaseHandler(&mPhs, l_method, this); } /* 00000908-00000B98 .text createHeap__9daNpcMt_cFv */ -void daNpcMt_c::createHeap() { - /* Nonmatching */ +BOOL daNpcMt_c::createHeap() { + J3DModelData* modelData = (J3DModelData *)dComIfG_getObjectIDRes(l_arcname_tbl[mPrmNpcNo], l_bmd_ix_tbl[mPrmNpcNo]); + mpMorf = new mDoExt_McaMorf( + modelData, + NULL, NULL, + (J3DAnmTransform*)dComIfG_getObjectIDRes(l_arcname_tbl[mPrmNpcNo], l_bck_ix_tbl[m74A]), + J3DFrameCtrl::EMode_LOOP, 1.0f, 0, -1, 1, NULL, + 0x80000, 0x11020022 + ); + + m_jnt.setHeadJntNum(modelData->getJointName()->getIndex("head")); + JUT_ASSERT(0x389, m_jnt.getHeadJntNum() >= 0); + m_jnt.setBackboneJntNum(modelData->getJointName()->getIndex("backbone")); + JUT_ASSERT(0x38D, m_jnt.getBackboneJntNum() >= 0); + + if (!initTexPatternAnm(false)) { + return FALSE; + } + + for(u16 i = 0; i < modelData->getJointNum(); i++) { + if(i == m_jnt.getHeadJntNum() || i == m_jnt.getBackboneJntNum()) { + modelData->getJointNodePointer(i)->setCallBack(daNpc_Mt_nodeCallBack); + } + } + + mpMorf->getModel()->setUserArea((u32)this); + mAcchCir.SetWall(30.0f, 30.0f); + mObjAcch.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, fopAcM_GetSpeed_p(this), fopAcM_GetAngle_p(this), fopAcM_GetShapeAngle_p(this)); + return TRUE; } /* 00000B98-00000BB8 .text daNpcMt_XyCheckCB__FPvi */ -static s16 daNpcMt_XyCheckCB(void*, int) { - /* Nonmatching */ +static s16 daNpcMt_XyCheckCB(void* i_this, int i_itemBtn) { + return ((daNpcMt_c*)i_this)->XyCheckCB(i_itemBtn); } /* 00000BB8-00000DEC .text createInit__9daNpcMt_cFv */ -void daNpcMt_c::createInit() { - /* Nonmatching */ +cPhs_State daNpcMt_c::createInit() { + gravity = -9.0f; + setAnmTbl(l_npc_anm_wait); + mMtGetItemEventIdx = dComIfGp_evmng_getEventIdx("MT_GET_ITEM", 0xff); + eventInfo.mpCheckCB = daNpcMt_XyCheckCB; + mEventCut.setActorInfo2(l_npc_staff_id[mPrmNpcNo], this); + m73E = 0; + m742 = 0; + m743 = 0; + m752 = 0; + attnOff(); + fopAcM_SetMtx(this, mpMorf->getModel()->getBaseTRMtx()); + fopAcM_setCullSizeBox(this, -70.0f, 0.0f, -70.0f, 70.0f, 200.0f, 70.0f); + attention_info.distances[fopAc_Attn_TYPE_TALK_e] = 0x6E; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0x6E; + attention_info.flags = fopAc_Attn_LOCKON_TALK_e | fopAc_Attn_ACTION_SPEAK_e | fopAc_Attn_UNK1000000_e; + m_jnt.setParam( + l_npc_dat[mPrmNpcNo].mMax_backbone_x, + l_npc_dat[mPrmNpcNo].mMax_backbone_y, + l_npc_dat[mPrmNpcNo].mMin_backbone_x, + l_npc_dat[mPrmNpcNo].mMin_backbone_y, + l_npc_dat[mPrmNpcNo].mMax_head_x, + l_npc_dat[mPrmNpcNo].mMax_head_y, + l_npc_dat[mPrmNpcNo].mMin_head_x, + l_npc_dat[mPrmNpcNo].mMin_head_y, + l_npc_dat[mPrmNpcNo].mMax_turn_step + ); + m750 = l_npc_dat[mPrmNpcNo].field_0x4A; + m751 = l_npc_dat[mPrmNpcNo].field_0x4B; + m720 = l_npc_dat[mPrmNpcNo].field_0x20; + m730 = l_npc_dat[mPrmNpcNo].field_0x28; + mObjAcch.CrrPos(*dComIfG_Bgsp()); + setMtx(); + mpMorf->getModel()->calc(); + mStts.Init(0xFF, 0xFF, this); + mCyl.Set(dNpc_cyl_src); + mCyl.SetStts(&mStts); + setCollision(&mCyl, current.pos, l_npc_dat[mPrmNpcNo].field_0x30, 150.0f); + return cPhs_COMPLEATE_e; } /* 00000DEC-00000F6C .text _delete__9daNpcMt_cFv */ bool daNpcMt_c::_delete() { - /* Nonmatching */ + dComIfG_resDeleteDemo(&mPhsArcname, l_arcname_tbl[mPrmNpcNo]); + if(heap != NULL && mpMorf != NULL){ + mpMorf->stopZelAnime(); + } + + if(dComIfGp_isEnableNextStage()){ + int roomId; + for(roomId = 1; roomId <= 7; roomId++) { + if(!strcmp(dComIfGp_getNextStageName(), l_figure_room_name[roomId])) { + break; + } + } + if (roomId <= 7) { + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_4080)) { + int temp = dSnap_GetFigRoomId(dComIfGs_getEventReg(dSv_event_flag_c::UNK_A9FF)); + if(temp == roomId) { + dComIfGs_onEventBit(dSv_event_flag_c::UNK_3F01); + } + } + } else { + dComIfGs_offTmpBit(dSv_event_tmp_flag_c::UNK_0202); + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_4080)) { + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_2F01); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3F01); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4040); + } + } + } + + + return true; } /* 00000F6C-0000107C .text _draw__9daNpcMt_cFv */ bool daNpcMt_c::_draw() { - /* Nonmatching */ + J3DModel* model = mpMorf->getModel(); + J3DModelData *model_data = model->getModelData(); + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType(model, &tevStr); + mBtpAnm.entry(model_data, mFrame); + mpMorf->updateDL(); + mBtpAnm.remove(model_data); + + cXyz shadowPos( + current.pos.x, + current.pos.y + 150.0f, + current.pos.z + ); + + mShadowId = dComIfGd_setShadow( + mShadowId, 1, mpMorf->getModel(), &shadowPos, 800.0f, 20.0f, + current.pos.y, mObjAcch.GetGroundH(), mObjAcch.m_gnd, &tevStr + ); + + dSnap_RegistFig(DSNAP_TYPE_NPC_MT, this, 1.0f, 1.0f, 1.0f); + return true; } +static daNpcMt_c::InitFunc_t l_execute_init[] = { + &daNpcMt_c::executeWaitInit, + &daNpcMt_c::executeTalkInit, +}; + +static daNpcMt_c::MoveFunc_t moveProc[] = { + &daNpcMt_c::executeWait, + &daNpcMt_c::executeTalk, +}; + /* 0000107C-000011D0 .text _execute__9daNpcMt_cFv */ bool daNpcMt_c::_execute() { - /* Nonmatching */ + chkAttention(); + checkOrder(); + + if (!dComIfGp_event_runCheck() || eventInfo.checkCommandTalk()) { + (this->*moveProc[m746])(); + } else { + eventMove(); + } + + eventOrder(); + playTexPatternAnm(); + playAnm(); + + setCollision(&mCyl, current.pos, l_npc_dat[mPrmNpcNo].field_0x30, 150.0f); + + attention_info.position.set(current.pos.x, current.pos.y + l_npc_dat[mPrmNpcNo].field_0x18, current.pos.z); + eyePos.set(current.pos.x, current.pos.y + l_npc_dat[mPrmNpcNo].field_0x1C, current.pos.z); + + lookBack(); + setMtx(); + return false; } /* 000011D0-00001240 .text executeCommon__9daNpcMt_cFv */ -void daNpcMt_c::executeCommon() { - /* Nonmatching */ +BOOL daNpcMt_c::executeCommon() { + if (m743) { + m744 = 1; + } + else { + m744 = 0; + } + + if (m742 == 1 && m746 != 1) { + executeSetMode(1); + } + + return m742; } /* 00001240-00001294 .text executeSetMode__9daNpcMt_cFUc */ -void daNpcMt_c::executeSetMode(u8) { - /* Nonmatching */ +void daNpcMt_c::executeSetMode(u8 param_1) { + m718 = 0.0f; + m746 = (this->*l_execute_init[param_1])(); } /* 00001294-00001320 .text executeWaitInit__9daNpcMt_cFv */ -void daNpcMt_c::executeWaitInit() { - /* Nonmatching */ +s32 daNpcMt_c::executeWaitInit() { + speedF = 0.0f; + setAnmTbl(l_npc_anm_wait); + m_jnt.setParam( + l_npc_dat[mPrmNpcNo].mMax_backbone_x, + l_npc_dat[mPrmNpcNo].mMax_backbone_y, + l_npc_dat[mPrmNpcNo].mMin_backbone_x, + l_npc_dat[mPrmNpcNo].mMin_backbone_y, + l_npc_dat[mPrmNpcNo].mMax_head_x, + l_npc_dat[mPrmNpcNo].mMax_head_y, + l_npc_dat[mPrmNpcNo].mMin_head_x, + l_npc_dat[mPrmNpcNo].mMin_head_y, + l_npc_dat[mPrmNpcNo].mMax_turn_step + ); + return FALSE; } /* 00001320-00001368 .text executeWait__9daNpcMt_cFv */ void daNpcMt_c::executeWait() { - /* Nonmatching */ + executeCommon(); + if(m74A) { + setAnmTbl(l_npc_anm_wait); + } } /* 00001368-00001370 .text executeTalkInit__9daNpcMt_cFv */ -void daNpcMt_c::executeTalkInit() { - /* Nonmatching */ +s32 daNpcMt_c::executeTalkInit() { + return TRUE; } /* 00001370-000013E8 .text executeTalk__9daNpcMt_cFv */ void daNpcMt_c::executeTalk() { - /* Nonmatching */ + executeCommon(); + if(talk2(1) == fopMsgStts_BOX_CLOSED_e) { + m742 = 0; + executeSetMode(0); + dComIfGp_event_reset(); + } + else { + setAnmFromMsgTag(); + } } /* 000013E8-00001480 .text checkOrder__9daNpcMt_cFv */ void daNpcMt_c::checkOrder() { - /* Nonmatching */ + if(eventInfo.checkCommandDemoAccrpt()) { + if(dComIfGp_evmng_startCheck(mMtGetItemEventIdx) && m744 == 3) { + m744 = 0; + } + } + else if (eventInfo.checkCommandTalk() && (m744 == 2 || m744 == 1)) { + m742 = 1; + executeSetMode(1); + } } /* 00001480-0000150C .text eventOrder__9daNpcMt_cFv */ void daNpcMt_c::eventOrder() { - /* Nonmatching */ + if(m744 == 2 || m744 == 1) { + eventInfo.onCondition(dEvtCnd_CANTALK_e); + eventInfo.onCondition(dEvtCnd_CANTALKITEM_e); + if(m744 == 2) { + fopAcM_orderSpeakEvent(this); + } + } + else if(m744 == 3) { + fopAcM_orderChangeEventId(dComIfGp_getPlayer(0), this, mMtGetItemEventIdx, 0, 0xffff); + } } /* 0000150C-00001580 .text eventMove__9daNpcMt_cFv */ void daNpcMt_c::eventMove() { - /* Nonmatching */ + if(!chkEndEvent()) { + bool oldFlag = mEventCut.getAttnFlag(); + if(mEventCut.cutProc()) { + if(!mEventCut.getAttnFlag()) { + mEventCut.setAttnFlag(oldFlag); + } + } + else { + privateCut(); + setAnmFromMsgTag(); + } + } } /* 00001580-000016B0 .text privateCut__9daNpcMt_cFv */ void daNpcMt_c::privateCut() { - /* Nonmatching */ + static char* cut_name_tbl[] = { + "MES_SET", + "GET_ITEM", + }; + + int staffIdx = dComIfGp_evmng_getMyStaffId(l_npc_staff_id[mPrmNpcNo]); + if(staffIdx != -1) { + m74D = dComIfGp_evmng_getMyActIdx(staffIdx, cut_name_tbl, ARRAY_SIZE(cut_name_tbl), TRUE, 0); + if(m74D == -1) { + dComIfGp_evmng_cutEnd(staffIdx); + return; + } + + if(dComIfGp_evmng_getIsAddvance(staffIdx)) { + switch(m74D) { + case 0: + eventMesSetInit(staffIdx); + break; + case 1: + eventGetItemInit(); + break; + } + } + + bool temp; + switch(m74D) { + case 0: + temp = eventMesSet(); + break; + default: + temp = true; + } + + if(temp) { + dComIfGp_evmng_cutEnd(staffIdx); + } + } } /* 000016B0-00001788 .text eventMesSetInit__9daNpcMt_cFi */ -void daNpcMt_c::eventMesSetInit(int) { - /* Nonmatching */ +void daNpcMt_c::eventMesSetInit(int staffIdx) { + int* pData = dComIfGp_evmng_getMyIntegerP(staffIdx, "MsgNo"); + if(pData) { + mpMsgTbl = NULL; + + int msg = *pData; + switch(msg){ + case 1: + break; + case 0: + setMessage(getMsg()); + break; + default: + setMessage(msg); + } + + if (mpMsgTbl != NULL) { + setMessage(*mpMsgTbl); + } + } + else { + mpMsgTbl++; + setMessage(*mpMsgTbl); + } } /* 00001788-0000181C .text eventMesSet__9daNpcMt_cFv */ -void daNpcMt_c::eventMesSet() { - /* Nonmatching */ +bool daNpcMt_c::eventMesSet() { + u16 temp = talk2(0); + if (temp == fopMsgStts_BOX_CLOSED_e) { + if(m749 & 1) { + m749 &= ~1; + mItemNo = 7; + m744 = 3; + } + else if (m749 & 2) { + m749 &= ~2; + mItemNo = 5; + m744 = 3; + } + } + return temp == fopMsgStts_BOX_CLOSED_e; } /* 0000181C-00001874 .text eventGetItemInit__9daNpcMt_cFv */ void daNpcMt_c::eventGetItemInit() { - /* Nonmatching */ + fpc_ProcID itemID = fopAcM_createItemForPresentDemo(¤t.pos, mItemNo, 0, -1, -1); + if (itemID != fpcM_ERROR_PROCESS_ID_e) { + dComIfGp_event_setItemPartnerId(itemID); + } } /* 00001874-000019BC .text talk2__9daNpcMt_cFi */ -void daNpcMt_c::talk2(int) { - /* Nonmatching */ +u16 daNpcMt_c::talk2(int i_param) { + u16 status = 0xFF; + if(mCurrMsgBsPcId == fpcM_ERROR_PROCESS_ID_e) { + + if(i_param == 1) { + mCurrMsgNo = getMsg(); + } + + mCurrMsgBsPcId = fopMsgM_messageSet(mCurrMsgNo, this); + mpCurrMsg = NULL; + m734 = -1; + } + else if(mpCurrMsg) { + status = mpCurrMsg->mStatus; + switch(status) { + case fopMsgStts_MSG_DISPLAYED_e: + mpCurrMsg->mStatus = next_msgStatus(&mCurrMsgNo); + + if(mpCurrMsg->mStatus == fopMsgStts_MSG_CONTINUES_e) { + fopMsgM_messageSet(mCurrMsgNo); + } + break; + + case fopMsgStts_MSG_TYPING_e: + if (m734 == fopMsgStts_MSG_CONTINUES_e) { + chkMsg(); + } + break; + + case fopMsgStts_BOX_CLOSED_e: + mpCurrMsg->mStatus = fopMsgStts_MSG_DESTROYED_e; + mCurrMsgBsPcId = -1; + break; + } + + m734 = status; + anmAtr(status); + } else { + mpCurrMsg = fopMsgM_SearchByID(mCurrMsgBsPcId); + } + return status; } /* 000019BC-00001A8C .text next_msgStatus__9daNpcMt_cFPUl */ -u16 daNpcMt_c::next_msgStatus(u32*) { - /* Nonmatching */ +u16 daNpcMt_c::next_msgStatus(u32* pMsgNo) { + u16 status = fopMsgStts_MSG_CONTINUES_e; + if (mpMsgTbl) { + mpMsgTbl++; + switch(*mpMsgTbl) { + case 2: + dPb_erasePicture(); + case 0: + mpMsgTbl = NULL; + status = fopMsgStts_MSG_ENDS_e; + break; + case 1: + *pMsgNo = l_msg_mt_room[dSnap_GetFigRoomId(dComIfGs_getEventReg(dSv_event_flag_c::UNK_A9FF))]; + break; + default: + *pMsgNo = *mpMsgTbl; + break; + } + } + else { + status = fopMsgStts_MSG_ENDS_e; + } + + return status; } /* 00001A8C-00001FC8 .text getMsg__9daNpcMt_cFv */ u32 daNpcMt_c::getMsg() { - /* Nonmatching */ + u8 uVar2; + + u32 msgNo = 0; + mpMsgTbl = NULL; + if (g_dComIfG_gameInfo.play.getEvent()->chkPhoto()){ + uVar2 = changePhotoNo(dComIfGp_getPictureResult()); + if ((uVar2 <= 0x48) || (uVar2 >= 0xcf)) { + uVar2 = 0xff; + } + else { + uVar2 = dSnap_PhotoIndex2TableIndex(uVar2) & 0xff; + } + if (dComIfGp_getPictureFormat() == 0 || dComIfGp_getPictureFormat() == 1) { + mpMsgTbl = l_msg_mt_no_color; + } + else if (uVar2 == 0xff) { + mpMsgTbl = l_msg_mt_no_figure; + } + else if (isFigureGet(uVar2)) { + mpMsgTbl = l_msg_mt_maked; + } + else if (dComIfGp_getPictureResultDetail() == 1) { + mpMsgTbl = l_msg_mt_face_ng; + } + else if (dComIfGp_getPictureResultDetail() == 2) { + mpMsgTbl = l_msg_mt_body_ng; + } + else { + dComIfGs_onEventBit(dSv_event_flag_c::UNK_2F01); + dComIfGs_onEventBit(dSv_event_flag_c::UNK_3401); + dComIfGs_setEventReg(dSv_event_flag_c::UNK_A9FF, uVar2); + s32 bVar1 = 0; + if(dComIfGs_isEventBit(dSv_event_flag_c::UNK_3A01)) { + bVar1 = 1; + } + switch(uVar2) { + case 0x5e: + mpMsgTbl = l_msg_mt_make_mt[bVar1]; + break; + case 0x5f: + mpMsgTbl = l_msg_mt_make_mn[bVar1]; + break; + default: + mpMsgTbl = l_msg_mt_make[bVar1]; + } + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_4080)) { + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3F01); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4040); + } + } + } + else if (dComIfGp_event_chkTalkXY()) { + + } else if(dComIfGs_isEventBit(dSv_event_flag_c::UNK_3080)) { + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_4080) == 0) { + if(!dComIfGs_isEventBit(dSv_event_flag_c::UNK_3A01)) { + mpMsgTbl = l_msg_mt_1st_kansei; + } + else { + mpMsgTbl = l_msg_mt_2nd_kansei; + } + + u8 evReg = dComIfGs_getEventReg(dSv_event_flag_c::UNK_A9FF); + setFigure(evReg); + + if (evReg == (u8)dSnap_PhotoIndex2TableIndex(0x4a)) { + setFigure(dSnap_PhotoIndex2TableIndex(0x49)); + } + else if (evReg == (u8)dSnap_PhotoIndex2TableIndex(0x72)) { + setFigure(dSnap_PhotoIndex2TableIndex(0x73)); + setFigure(dSnap_PhotoIndex2TableIndex(0x74)); + setFigure(dSnap_PhotoIndex2TableIndex(0x75)); + setFigure(dSnap_PhotoIndex2TableIndex(0x76)); + setFigure(dSnap_PhotoIndex2TableIndex(0x77)); + setFigure(dSnap_PhotoIndex2TableIndex(0x78)); + } + else if (evReg == (u8)dSnap_PhotoIndex2TableIndex(0x8c)) { + setFigure(dSnap_PhotoIndex2TableIndex(0x8d)); + } + else if (evReg == (u8)dSnap_PhotoIndex2TableIndex(0x88)) { + setFigure(dSnap_PhotoIndex2TableIndex(0x87)); + } + dComIfGs_onEventBit(dSv_event_flag_c::UNK_4080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_2F01); + } + else if(!dComIfGs_isEventBit(dSv_event_flag_c::UNK_3F01)) { + mpMsgTbl = l_msg_mt_gallery; + } + else if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_4040) == 0) { + dComIfGs_onEventBit(dSv_event_flag_c::UNK_4040); + mpMsgTbl = l_msg_mt_room_in; + } + else { + mpMsgTbl = l_msg_mt_kansei_end; + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4080); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_3F01); + dComIfGs_offEventBit(dSv_event_flag_c::UNK_4040); + dComIfGs_onTmpBit(dSv_event_tmp_flag_c::UNK_0202); + } + } + else if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_2F01)) { + mpMsgTbl = l_msg_mt_making; + } + else if(!dComIfGs_isEventBit(dSv_event_flag_c::UNK_2F02)) { + dComIfGs_onEventBit(dSv_event_flag_c::UNK_2F02); + mpMsgTbl = l_msg_mt_1st_talk; + } + else if(!dComIfGs_isEventBit(dSv_event_flag_c::UNK_3A01)) { + mpMsgTbl = l_msg_mt_2nd_talk; + } + else if(!dComIfGs_isTmpBit(dSv_event_tmp_flag_c::UNK_0202)) { + dComIfGs_onTmpBit(dSv_event_tmp_flag_c::UNK_0202); + mpMsgTbl = l_msg_mt_3rd_talk; + } + else { + mpMsgTbl = l_msg_mt_4th_talk; + } + + if (mpMsgTbl != NULL) { + msgNo = *mpMsgTbl; + } + + return msgNo; } /* 00001FC8-00001FCC .text chkMsg__9daNpcMt_cFv */ void daNpcMt_c::chkMsg() { - /* Nonmatching */ + return; } /* 00001FCC-00001FD4 .text setMessage__9daNpcMt_cFUl */ -void daNpcMt_c::setMessage(u32) { - /* Nonmatching */ +void daNpcMt_c::setMessage(u32 msgNo) { + mCurrMsgNo = msgNo; } /* 00001FD4-00002084 .text setAnmFromMsgTag__9daNpcMt_cFv */ void daNpcMt_c::setAnmFromMsgTag() { - /* Nonmatching */ + switch(dComIfGp_getMesgAnimeAttrInfo()) { + case 0: + setAnmTbl(l_npc_anm_wait); + break; + case 1: + setAnmTbl(l_npc_anm_talk); + break; + case 2: + setAnmTbl(l_npc_anm_talk2); + break; + case 3: + setAnmTbl(l_npc_anm_talk3); + break; + case 4: + setAnmTbl(l_npc_anm_talk4); + break; + case 5: + setAnmTbl(l_npc_anm_talk5); + break; + case 6: + setAnmTbl(l_npc_anm_tukuru); + } + dComIfGp_setMesgAnimeAttrInfo(0xff); } /* 00002084-000020A4 .text getPrmNpcNo__9daNpcMt_cFv */ -void daNpcMt_c::getPrmNpcNo() { - /* Nonmatching */ +u8 daNpcMt_c::getPrmNpcNo() { + if(0 <= argument && argument < 1) { + return argument; + } + return 0; } /* 000020A4-0000212C .text setMtx__9daNpcMt_cFv */ void daNpcMt_c::setMtx() { - /* Nonmatching */ + mpMorf->getModel()->setBaseScale(scale); + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::YrotM(current.angle.y); + mpMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); } /* 0000212C-00002474 .text chkAttention__9daNpcMt_cFv */ void daNpcMt_c::chkAttention() { - /* Nonmatching */ + m752 = 0; + + if(mEventCut.getAttnFlag()) { + mLookAtPos = mEventCut.getAttnPos(); + m74F = 1; + if(m750 != 0) { + m728 = false; + m_jnt.setTrn(); + } + else { + m728 = true; + } + + if(m743 == 0) { + m743 = 1; + } + } + else { + fopAc_ac_c* player = dComIfGp_getLinkPlayer(); + + f32 temp = m720; + int temp2 = m730; + f32 temp4; + s16 temp5; + + dNpc_calc_DisXZ_AngY(current.pos, player->current.pos, &temp4, &temp5); + + if(m743 != 0) { + temp += 40.0f; + temp2 += 0x71C; + } + + temp5 -= shape_angle.y; + if(temp > temp4 && temp2 > abs(temp5)) { + mLookAtPos = dNpc_playerEyePos(l_npc_dat[mPrmNpcNo].field_0x14); + m74F = 1; + if(m750 != 0) { + m728 = false; + } + else { + m728 = true; + } + + if(m751 == 0) { + m740 = m732; + m728 = false; + m74F = 2; + m_jnt.setTrn(); + } + + if (m743 == 0) { + m743 = 1; + } + } + else { + if(m743 == 1) { + m743 = 0; + m72E = l_npc_dat[mPrmNpcNo].field_0x48; + } + if(l_npc_dat[mPrmNpcNo].field_0x24 > temp4 || m753 != 0){ + mLookAtPos = dNpc_playerEyePos(l_npc_dat[mPrmNpcNo].field_0x14); + m74F = 1; + if (m750 != 0) { + m728 = 0; + } else { + m728 = 1; + } + if (m751 == 0) { + m740 = m732; + m728 = 0; + m74F = 2; + m_jnt.setTrn(); + } + m752 = 1; + } else { + m74F = 0; + if(m6F0 == 0) { + if(m72E) { + m72E--; + } + else { + m740 = m732; + m728 = false; + m74F = 2; + m_jnt.setTrn(); + } + } + } + } + } + + m73C = l_npc_dat[mPrmNpcNo].field_0x2A; } /* 00002474-000025C0 .text lookBack__9daNpcMt_cFv */ void daNpcMt_c::lookBack() { - /* Nonmatching */ + short target = m73C; + short desiredYRot = current.angle.y; + cXyz* dstTemp = NULL; + cXyz temp2; + cXyz dstPos = eyePos; + bool headOnlyFollow = m728; + + switch(m74F) { + case 1: + temp2 = mLookAtPos; + dstTemp = &temp2; + break; + case 2: + desiredYRot = m740; + break; + case 0: + default: + break; + } + + if (m742 && m750) { + headOnlyFollow = false; + m_jnt.setTrn(); + } + + if (m_jnt.trnChk()) { + if(mEventCut.getTurnSpeed() != 0) { + target = mEventCut.getTurnSpeed(); + } + cLib_addCalcAngleS2(&m73E, target, 4, 0x800); + } else { + m73E = 0; + } + + m_jnt.lookAtTarget(¤t.angle.y, dstTemp, dstPos, desiredYRot, m73E, headOnlyFollow); + shape_angle = current.angle; } /* 000025C0-000026D8 .text initTexPatternAnm__9daNpcMt_cFb */ -void daNpcMt_c::initTexPatternAnm(bool) { - /* Nonmatching */ +BOOL daNpcMt_c::initTexPatternAnm(bool i_modify) { + J3DModelData *modelData = mpMorf->getModel()->getModelData(); + m_head_tex_pattern = (J3DAnmTexPattern*)dComIfG_getObjectIDRes(l_arcname_tbl[mPrmNpcNo], l_btp_ix_tbl[mPrmNpcNo]); + JUT_ASSERT(0x801, m_head_tex_pattern != NULL); + + if(!mBtpAnm.init(modelData, m_head_tex_pattern, TRUE, J3DFrameCtrl::EMode_LOOP, 1.0f, 0, -1, i_modify, FALSE)) { + return FALSE; + } + + mFrame = 0; + mTimer = 0; + return TRUE; } /* 000026D8-00002744 .text playTexPatternAnm__9daNpcMt_cFv */ void daNpcMt_c::playTexPatternAnm() { - /* Nonmatching */ + if(cLib_calcTimer(&mTimer) == 0) { + if(mFrame >= m_head_tex_pattern->getFrameMax()) { + mFrame -= m_head_tex_pattern->getFrameMax(); + mTimer = 0x78; + } + else { + mFrame++; + } + } } /* 00002744-0000280C .text playAnm__9daNpcMt_cFv */ void daNpcMt_c::playAnm() { - /* Nonmatching */ + mAnmFlag &= ~1; + if(mpMorf->play(0, 0, 0)) { + if(mpAnmDat) { + if(m74C > 0) { + m74C--; + if(m74C == 0) { + mpAnmDat++; + if(setAnmTbl(mpAnmDat)) { + mAnmFlag |= 1; + } + } + else { + setAnm(mpAnmDat->field_0x00, 0, 0.0f); + } + } + } + } } /* 0000280C-000028E4 .text setAnm__9daNpcMt_cFUcif */ -void daNpcMt_c::setAnm(u8, int, f32) { - /* Nonmatching */ +void daNpcMt_c::setAnm(u8 param_1, int param_2, f32 morf) { + if (m71C >= 0.0f) { + morf = m71C; + m71C = -1.0f; + } + + J3DAnmTransformKey* pAnm = (J3DAnmTransformKey*)dComIfG_getObjectIDRes(l_arcname_tbl[mPrmNpcNo], l_bck_ix_tbl[param_1]); + mpMorf->setAnm(pAnm, param_2, morf, 1.0f, 0.0f, -1.0f, NULL); + m74A = param_1; } /* 000028E4-00002984 .text setAnmTbl__9daNpcMt_cFP9sMtAnmDat */ -void daNpcMt_c::setAnmTbl(sMtAnmDat*) { - /* Nonmatching */ +bool daNpcMt_c::setAnmTbl(sMtAnmDat* anmDat) { + if (anmDat->field_0x00 == 0xFF) { + mpAnmDat = NULL; + return true; + } + else { + mpAnmDat = anmDat; + m74C = mpAnmDat->field_0x02; + + int temp = 2; + if (m74C > 0) { + temp = 0; + } + + if (m74A != mpAnmDat->field_0x00 || temp == 0) { + setAnm(mpAnmDat->field_0x00, temp, mpAnmDat->field_0x01); + } + return false; + } } /* 00002984-00002A28 .text XyCheckCB__9daNpcMt_cFi */ -void daNpcMt_c::XyCheckCB(int) { - /* Nonmatching */ +s16 daNpcMt_c::XyCheckCB(int i_itemBtn) { + if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_2F02) && !dComIfGs_isEventBit(dSv_event_flag_c::UNK_2F01)) { + u8 itemNo = dComIfGp_getSelectItem(i_itemBtn); + if(itemNo == dItemNo_PICTO_BOX_e || itemNo == dItemNo_DELUXE_PICTO_BOX_e){ + if(dComIfGs_getPictureNum()){ + return true; + } + } + } + return false; } /* 00002A28-00002AA0 .text setCollision__9daNpcMt_cFP8dCcD_Cyl4cXyzff */ -void daNpcMt_c::setCollision(dCcD_Cyl*, cXyz, f32, f32) { - /* Nonmatching */ +void daNpcMt_c::setCollision(dCcD_Cyl* cyl, cXyz center, f32 radius, f32 height) { + cyl->SetC(center); + cyl->SetR(radius); + cyl->SetH(height); + dComIfG_Ccsp()->Set(cyl); } /* 00002AA0-00002AFC .text chkEndEvent__9daNpcMt_cFv */ -void daNpcMt_c::chkEndEvent() { - /* Nonmatching */ +BOOL daNpcMt_c::chkEndEvent() { + if (dComIfGp_evmng_endCheck(mMtGetItemEventIdx)) { + g_dComIfG_gameInfo.play.getEvent()->onEventFlag(8); + return TRUE; + } + return FALSE; } /* 00002AFC-00002B98 .text isFigureGet__9daNpcMt_cFUc */ -bool daNpcMt_c::isFigureGet(u8) { - /* Nonmatching */ +u8 daNpcMt_c::isFigureGet(u8 figureNo) { + if(figureNo >= TOTAL_FIGURE_COUNT){ + return false; + } + + if(figureNo / 8 < 0x11) { + int r31 = (figureNo % 8); + u8 reg = dComIfGs_getEventReg(l_figure_comp[figureNo / 8]); + u32 ret = reg & (1 << r31); + return ret; + } + return false; } /* 00002B98-00002C38 .text setFigure__9daNpcMt_cFUc */ @@ -273,7 +1360,7 @@ int daNpcMt_c::getFigureMakeNum() { } /* 00002CA0-00002D08 .text isComp__9daNpcMt_cFv */ -bool daNpcMt_c::isComp() { +BOOL daNpcMt_c::isComp() { int ownedNum = getFigureMakeNum(); int totalNum = 0x84; if(isFigureGet(0x32)) { @@ -288,8 +1375,18 @@ bool daNpcMt_c::isComp() { } /* 00002D08-00002D4C .text changePhotoNo__9daNpcMt_cFUc */ -void daNpcMt_c::changePhotoNo(u8) { - /* Nonmatching */ +u8 daNpcMt_c::changePhotoNo(u8 photoNo) { + switch(photoNo) { + case 2: + photoNo = 0x69; + break; + case 4: + photoNo = 0x67; + break; + case 6: + photoNo = 0x6d; + } + return photoNo; } /* 00002D4C-00002D6C .text daNpc_MtCreate__FPv */ diff --git a/src/d/d_com_inf_game.cpp b/src/d/d_com_inf_game.cpp index 28fcfa9a6..fdebd4f76 100644 --- a/src/d/d_com_inf_game.cpp +++ b/src/d/d_com_inf_game.cpp @@ -159,7 +159,7 @@ void dComIfG_play_c::itemInit() { mPictureStatus = 0; field_0x495f = 0; mPictureFormat = 0; - field_0x4961 = 0; + mSelectPicture = 0; mHeapLockFlag = 0; field_0x4965 = 0; diff --git a/src/d/d_picture_box.cpp b/src/d/d_picture_box.cpp index c3584d391..d1df8febd 100644 --- a/src/d/d_picture_box.cpp +++ b/src/d/d_picture_box.cpp @@ -6,10 +6,17 @@ #include "d/dolzel.h" // IWYU pragma: keep #include "d/d_picture_box.h" #include "f_op/f_op_msg.h" +#include "d/d_com_inf_game.h" /* 802258C8-80225954 .text dPb_erasePicture__Fv */ void dPb_erasePicture() { - /* Nonmatching */ + u8 selectPicture = dComIfGp_getSelectPicture(); + u8 evReg = dComIfGs_getEventReg(dSv_event_flag_c::UNK_89FF); + if (selectPicture < 3) { + dComIfGs_setEventReg(dSv_event_flag_c::UNK_89FF, evReg | (1 << (selectPicture))); + dComIfGp_setItemPictureNumCount(-1); + } + } /* 80225954-80225E88 .text screenSet__9dJle_Pb_cFv */