diff --git a/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/include/JSystem/J3DGraphAnimator/J3DAnimation.h index c2ab77ee1..f4bf513d6 100644 --- a/include/JSystem/J3DGraphAnimator/J3DAnimation.h +++ b/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -501,7 +501,7 @@ public: virtual ~J3DAnmColor(); virtual void getColor(u16, GXColor*) const; - u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; } + s32 getUpdateMaterialNum() const { return mUpdateMaterialNum; } bool isValidUpdateMaterialID(u16 id) const { return mUpdateMaterialID[id] != 0xFFFF; } u16 getUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx]; } JUTNameTab * getUpdateMaterialName() { return &mUpdateMaterialName; } diff --git a/include/d/d_attention.h b/include/d/d_attention.h index 24f3a83bf..bde7ccc9c 100644 --- a/include/d/d_attention.h +++ b/include/d/d_attention.h @@ -14,7 +14,7 @@ public: void setAnm(int, int, int); void draw(cXyz&, Mtx); - /* 0x0 */ mDoExt_McaMorf * mpMorf; + /* 0x0 */ mDoExt_McaMorf * anm; /* 0x4 */ J3DAnmColor * mpAnmClr; /* 0x8 */ J3DMatColorAnm * mpAnmMatClr; }; @@ -107,7 +107,7 @@ public: class dAttDraw_CallBack_c : public mDoExt_McaMorfCallBack1_c { public: - virtual void execute(u16, J3DTransformInfo*); + virtual bool execute(u16, J3DTransformInfo*); }; class daPy_lk_c; @@ -127,12 +127,12 @@ public: dAttList_c* getActionBtnY(); dAttList_c* getActionBtnZ(); void chkAttMask(u32, u32); - void calcWeight(int, fopAc_ac_c*, f32, s16, s16, u32*); + f32 calcWeight(int, fopAc_ac_c*, f32, s16, s16, u32*); void setLList(fopAc_ac_c*, f32, f32, u32); void setAList(fopAc_ac_c*, f32, f32, u32); void initList(u32); s32 makeList(); - void SelectAttention(fopAc_ac_c*); + int SelectAttention(fopAc_ac_c*); void sortList(); void stockAttention(u32); void nextAttention(u32); @@ -191,7 +191,7 @@ public: public: /* 0x000 */ daPy_lk_c* mpPlayer; /* 0x004 */ int mLockOnTargetBsPcID; - /* 0x008 */ dAttDraw_CallBack_c mpCallBack; + /* 0x008 */ dAttDraw_CallBack_c mCallBack; /* 0x00C */ int mPlayerNo; /* 0x010 */ u32 mFlagMask; /* 0x014 */ u8 field_0x014[0x018 - 0x014]; @@ -202,10 +202,10 @@ public: /* 0x01C */ s16 field_0x01c; /* 0x01E */ u8 field_0x01E[0x020 - 0x01E]; /* 0x020 */ u32 mFlags; - /* 0x024 */ JKRHeap* mpHeap; - /* 0x028 */ u8 field_0x028; + /* 0x024 */ JKRSolidHeap* heap; + /* 0x028 */ s8 field_0x028; /* 0x02C */ cXyz field_0x02c; - /* 0x038 */ dAttDraw_c mDraw[2]; + /* 0x038 */ dAttDraw_c draw[2]; /* 0x050 */ u32 field_0x050; /* 0x054 */ dAttList_c mLockOnList[8]; /* 0x0D4 */ int mLockOnNum; diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h index 13ca30b17..ceccacc1f 100644 --- a/include/m_Do/m_Do_ext.h +++ b/include/m_Do/m_Do_ext.h @@ -313,7 +313,7 @@ struct mDoExt_MtxCalcAnmBlendTblOld : public mDoExt_MtxCalcAnmBlendTbl { class mDoExt_McaMorfCallBack1_c { public: virtual ~mDoExt_McaMorfCallBack1_c() {} - virtual void execute(u16, J3DTransformInfo*) = 0; + virtual bool execute(u16, J3DTransformInfo*) = 0; }; class mDoExt_McaMorfCallBack2_c { diff --git a/src/d/d_attention.cpp b/src/d/d_attention.cpp index 3c15814d6..320fbec8b 100644 --- a/src/d/d_attention.cpp +++ b/src/d/d_attention.cpp @@ -6,30 +6,92 @@ #include "d/d_attention.h" #include "f_op/f_op_actor_mng.h" #include "d/d_com_inf_game.h" +#include "d/actor/d_a_player_main.h" +#include "d/d_s_play.h" +#include "m_Do/m_Do_ext.h" +#include "JSystem/JKernel/JKRSolidHeap.h" /* 8009D220-8009D268 .text __ct__11dAttParam_cFl */ dAttParam_c::dAttParam_c(long) { /* Nonmatching */ + field_0x04 = 45.0f; + field_0x08 = 30.0f; + field_0x0c = 90.0f; + field_0x00 = 1; + field_0x18 = -0.9f; + field_0x10 = 3000.0f; + field_0x14 = 1000.0f; } /* 8009D268-8009D2B0 .text __dt__11dAttParam_cFv */ dAttParam_c::~dAttParam_c() { - /* Nonmatching */ } /* 8009D2B0-8009D2E0 .text execute__19dAttDraw_CallBack_cFUsP16J3DTransformInfo */ -void dAttDraw_CallBack_c::execute(unsigned short, J3DTransformInfo*) { - /* Nonmatching */ +bool dAttDraw_CallBack_c::execute(u16 timing, J3DTransformInfo* xform) { + if (timing == 0) { + xform->mTranslate.y *= g_regHIO.mChild[6].mFloatRegs[17] + 0.6f; + } + return true; } /* 8009D2E0-8009D654 .text __ct__12dAttention_cFP10fopAc_ac_cUl */ -dAttention_c::dAttention_c(fopAc_ac_c*, unsigned long) { +dAttention_c::dAttention_c(fopAc_ac_c* player, u32 playerNo) { /* Nonmatching */ + mpPlayer = (daPy_lk_c*)player; + mPlayerNo = playerNo; + initList(0xFFFFFFFF); + mFlagMask = 0; + field_0x01c = -1; + field_0x019 = 0; + mLockOnState = 0; + field_0x01a = 0; + field_0x01b = 0; + mLockOnTargetBsPcID = -1; + heap = mDoExt_createSolidHeapFromGameToCurrent(0x3600, 0); + JUT_ASSERT(0xb9, heap != 0); + + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Always", ALWAYS_BDL_YAZIRUSHI_01); + JUT_ASSERT(0xbe, modelData != 0); + + s32 anmColNum = 0; + for (u32 i = 0; i < 5; i++) { + static u16 l_bpkIdx[] = { + ALWAYS_BPK_YJ_IN, ALWAYS_BPK_YJ_OUT, ALWAYS_BPK_YJ_SCALE, ALWAYS_BPK_YJ_LOOP, ALWAYS_BPK_YJ_DELETE, + }; + J3DAnmColor* anmCol = (J3DAnmColor*)dComIfG_getObjectRes("Always", l_bpkIdx[i]); + JUT_ASSERT(0xcc, anmCol != 0); + + anmCol->searchUpdateMaterialID(modelData); + if (anmCol->getUpdateMaterialNum() > anmColNum) + anmColNum = anmCol->getUpdateMaterialNum(); + } + + for (s32 i = 0; i < (s32)ARRAY_SIZE(draw); i++) { + draw[i].anm = new mDoExt_McaMorf(modelData, &mCallBack, NULL, (J3DAnmTransformKey*)dComIfG_getObjectRes("Always", ALWAYS_BCK_YJ_LOOP), J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, 1, NULL, 0x80000, 0x1000003); + JUT_ASSERT(0xe3, draw[i].anm != 0 && draw[i].anm->getModel() != 0); + draw[i].mpAnmClr = NULL; + draw[i].mpAnmMatClr = new J3DMatColorAnm[anmColNum]; + } + + mDoExt_restoreCurrentHeap(); + if (mDoExt_adjustSolidHeap(heap) >= 0) + DCStoreRangeNoSync(heap->getStartAddr(), heap->getSize()); + + field_0x028 = -1; + mFlags = 0; + mHint.init(); + mCatch.init(); + mLook[0].init(); + mLook[1].init(); } /* 8009D654-8009D6EC .text __dt__12dAttention_cFv */ dAttention_c::~dAttention_c() { - /* Nonmatching */ + if (heap != NULL) { + mDoExt_destroySolidHeap(heap); + heap = NULL; + } } /* 8009D6EC-8009D728 .text GetActionList__12dAttention_cFl */ @@ -113,7 +175,7 @@ void check_distace(cXyz*, short, cXyz*, float, float, float, float) { } /* 8009DE44-8009E03C .text calcWeight__12dAttention_cFiP10fopAc_ac_cfssPUl */ -void dAttention_c::calcWeight(int, fopAc_ac_c*, float, short, short, unsigned long*) { +f32 dAttention_c::calcWeight(int, fopAc_ac_c*, float, short, short, unsigned long*) { /* Nonmatching */ } @@ -191,19 +253,37 @@ void dAttention_c::initList(unsigned long flagMask) { } /* 8009E2CC-8009E2F8 .text select_attention__FP10fopAc_ac_cPv */ -void select_attention(fopAc_ac_c* pActor, void* i_attention) { +int select_attention(fopAc_ac_c* pActor, void* i_attention) { dAttention_c * pAttention = (dAttention_c*)i_attention; - pAttention->SelectAttention(pActor); + return pAttention->SelectAttention(pActor); } /* 8009E2F8-8009E33C .text makeList__12dAttention_cFv */ s32 dAttention_c::makeList() { - /* Nonmatching */ + fopAcIt_Executor((fopAcIt_ExecutorFunc)select_attention, this); + return mLockOnNum + mActionNum; } /* 8009E33C-8009E474 .text SelectAttention__12dAttention_cFP10fopAc_ac_c */ -void dAttention_c::SelectAttention(fopAc_ac_c*) { +int dAttention_c::SelectAttention(fopAc_ac_c* ac) { /* Nonmatching */ + if (ac == mpPlayer || mpPlayer == NULL) + return 0; + + mFlagMask = ac->mAttentionInfo.mFlags; + + cSGlobe globe1(ac->mAttentionInfo.mPosition - mpPlayer->mAttentionInfo.mPosition); + cSAngle angle1 = globe1.U() - mpPlayer->shape_angle.y; + + cSGlobe globe2(mpPlayer->mAttentionInfo.mPosition - ac->mAttentionInfo.mPosition); + cSAngle angle2 = globe2.U() - mpPlayer->shape_angle.y; + + u32 type; + f32 weight = calcWeight('L', ac, globe1.R(), angle1, angle2, &type); + setLList(ac, weight, globe1.R(), type); + weight = calcWeight('A', ac, globe1.R(), angle1, angle2, &type); + setAList(ac, weight, globe1.R(), type); + return 0; } /* 8009E474-8009E5C4 .text sortList__12dAttention_cFv */ diff --git a/src/d/d_s_room.cpp b/src/d/d_s_room.cpp index ed44a1c48..79afb2f1d 100644 --- a/src/d/d_s_room.cpp +++ b/src/d/d_s_room.cpp @@ -94,16 +94,16 @@ void objectSetCheck(room_of_scene_class* i_this) { /* 80236B1C-80236BAC .text dScnRoom_Execute__FP19room_of_scene_class */ BOOL dScnRoom_Execute(room_of_scene_class* i_this) { + u32 roomNo = fopScnM_GetParam(i_this); setMapImage(i_this); - u8 * pStatusFlag = &(g_dComIfG_gameInfo.play.getRoomControl()->mStatus[fopScnM_GetParam(i_this)].mFlags); - if (*pStatusFlag & 0x04) { + if (dComIfGp_roomControl_checkStatusFlag(roomNo, 0x04)) { fopScnM_DeleteReq(i_this); return TRUE; } else { - if ((*pStatusFlag & 0x02)) { - *pStatusFlag &= ~0x02; - *pStatusFlag |= 0x01; + if (dComIfGp_roomControl_checkStatusFlag(roomNo, 0x02)) { + dComIfGp_roomControl_offStatusFlag(roomNo, 0x02); + dComIfGp_roomControl_onStatusFlag(roomNo, 0x01); } else { objectSetCheck(i_this); } @@ -190,7 +190,7 @@ s32 phase_1(room_of_scene_class* i_this) { /* 80236DE8-802370A0 .text phase_2__FP19room_of_scene_class */ s32 phase_2(room_of_scene_class* i_this) { const char * arcName = setArcName(i_this); - s32 rt = dComIfG_syncObjectRes(arcName); + s32 rt = dComIfG_syncStageRes(arcName); if (rt < 0) { dStage_escapeRestart(); return cPhs_ERROR_e; @@ -204,7 +204,7 @@ s32 phase_2(room_of_scene_class* i_this) { s32 zoneNo = dComIfGp_roomControl_getZoneNo(roomNo); if (zoneNo < 0) { zoneNo = dComIfGs_createZone(roomNo); - dComIfGp_roomControl_setZoneNo(roomNo, zoneNo); + dComIfGp_roomControl_setZoneNo(roomNo, zoneNo); // this isn't getting inlined for some reason } i_this->mpRoomDt = dComIfGp_roomControl_getStatusRoomDt(roomNo); diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index 9ba336356..948f491a6 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -218,7 +218,7 @@ bool dStage_roomControl_c::checkRoomDisp(int i_roomNo) const { /* 80040E6C-80040FD8 .text loadRoom__20dStage_roomControl_cFiPUc */ int dStage_roomControl_c::loadRoom(int roomCount, u8* rooms) { for (int roomNo = 0; roomNo < ARRAY_SIZE(mStatus); roomNo++) { - if (dStage_roomControl_c::checkStatusFlag(roomNo, 0x02 | 0x04)) { + if (checkStatusFlag(roomNo, 0x02 | 0x04)) { return 0; } } @@ -227,7 +227,7 @@ int dStage_roomControl_c::loadRoom(int roomCount, u8* rooms) { for (int roomNo = 0; roomNo < (int)ARRAY_SIZE(mStatus); roomNo++) { if (dStage_roomControl_c::checkStatusFlag(roomNo, 0x01)) { if (!stayRoomCheck(roomCount, rooms, roomNo)) { - dStage_roomControl_c::onStatusFlag(roomNo, 0x04); + onStatusFlag(roomNo, 0x04); r26 = FALSE; } } @@ -239,10 +239,10 @@ int dStage_roomControl_c::loadRoom(int roomCount, u8* rooms) { for (int i = 0; i < roomCount; i++) { u8 roomNo = dStage_roomRead_dt_c_GetLoadRoomIndex(rooms[i]); dStage_roomControl_c::setZoneCount(roomNo, 2); - if (!dStage_roomControl_c::checkStatusFlag(roomNo, 0x01)) { + if (!checkStatusFlag(roomNo, 0x01)) { if (createRoomScene(roomNo)) { u8 flag = dStage_roomRead_dt_c_ChkBg(rooms[i]) ? 0x02 : 0x0A; - dStage_roomControl_c::onStatusFlag(roomNo, flag); + onStatusFlag(roomNo, flag); } return TRUE; }