From 094a297809d702b640554a60da92641f25d5f353 Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Sun, 18 May 2025 21:40:09 -0400 Subject: [PATCH 01/10] 100% d_a_kui (#756) * 45% d_a_kui * 97% d_a_kui * 100% d_a_kui match * Fix easy issues from PR review * Use s16[3] for field_0x2DC --- configure.py | 2 +- include/d/actor/d_a_btd.h | 4 +- include/d/actor/d_a_dr2.h | 6 +- include/d/actor/d_a_kui.h | 26 +- src/d/actor/d_a_kui.cpp | 517 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 528 insertions(+), 27 deletions(-) diff --git a/configure.py b/configure.py index 5f91627f4..06b5b6537 100755 --- a/configure.py +++ b/configure.py @@ -1353,7 +1353,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_kanban"), ActorRel(NonMatching, "d_a_ki"), ActorRel(NonMatching, "d_a_knob00"), - ActorRel(NonMatching, "d_a_kui"), + ActorRel(Matching, "d_a_kui"), ActorRel(Matching, "d_a_kytag00"), ActorRel(Matching, "d_a_kytag01"), ActorRel(NonMatching, "d_a_kytag02"), diff --git a/include/d/actor/d_a_btd.h b/include/d/actor/d_a_btd.h index d310831f4..2039f2f1d 100644 --- a/include/d/actor/d_a_btd.h +++ b/include/d/actor/d_a_btd.h @@ -6,7 +6,9 @@ class btd_class : public fopAc_ac_c { public: /* Place member variables here */ - /* 0x0290 */ u8 field_0x290[0x6e16 - 0x290]; + /* 0x0290 */ u8 field_0x290[0x2e4 - 0x290]; + /* 0x02E4 */ s16 field_0x2e4; + /* 0x02E6 */ u8 field_0x2e6[0x6e16 - 0x2e6]; /* 0x6E16 */ s16 field_0x6e16; }; diff --git a/include/d/actor/d_a_dr2.h b/include/d/actor/d_a_dr2.h index 2a5d7eb2e..a20eeea15 100644 --- a/include/d/actor/d_a_dr2.h +++ b/include/d/actor/d_a_dr2.h @@ -5,7 +5,11 @@ class dr2_class : public fopAc_ac_c { public: - /* Place member variables here */ + /* 0x290 */ u8 field_0x290[0x3B0 - 0x290]; + /* 0x3B0 */ cXyz field_0x3B0; + /* 0x3BC */ u8 field_0x3BC[0x4BA - 0x3BC]; + /* 0x4BA */ s16 field_0x4BA; + /* 0x4BC */ u8 field_0x4BC[0x50C - 0x4BC]; }; class daDr2_HIO_c { diff --git a/include/d/actor/d_a_kui.h b/include/d/actor/d_a_kui.h index be62c6072..ae02d62ad 100644 --- a/include/d/actor/d_a_kui.h +++ b/include/d/actor/d_a_kui.h @@ -3,9 +3,33 @@ #include "f_op/f_op_actor.h" +class dBgW; + class kui_class : public fopAc_ac_c { public: - /* Place member variables here */ + /* 0x290 */ request_of_phase_process_class mPhs; + /* 0x298 */ J3DModel* mpModel2; + /* 0x29C */ J3DModel* mpModel; + /* 0x2A0 */ u8 type; + /* 0x2A1 */ u8 field_0x2A1; + /* 0x2A2 */ u8 field_0x2A2; + /* 0x2A3 */ u8 mSwitchNo; + /* 0x2A4 */ u8 field_0x2A4[0x2A8 - 0x2A4]; + /* 0x2A8 */ Mtx field_0x2A8; + /* 0x2D8 */ dBgW* field_0x2D8; + /* 0x2DC */ s16 field_0x2DC[3]; + /* 0x2E2 */ s16 field_0x2E2; + /* 0x2E4 */ s16 field_0x2E4; + /* 0x2E6 */ s16 field_0x2E6; + /* 0x2E8 */ s8 field_0x2E8; + /* 0x2E9 */ u8 field_0x2E9[0x2EA - 0x2E9]; + /* 0x2EA */ s16 field_0x2EA; + /* 0x2EC */ cXyz field_0x2EC; + /* 0x2F8 */ cXyz field_0x2F8; + /* 0x304 */ u8 field_0x304[0x308 - 0x304]; + /* 0x308 */ s16 field_0x308; + /* 0x30A */ u8 field_0x30A[0x30C - 0x30A]; + /* 0x30C */ f32 field_0x30C; }; #endif /* D_A_KUI_H */ diff --git a/src/d/actor/d_a_kui.cpp b/src/d/actor/d_a_kui.cpp index 9e413d9e0..f8553d3ab 100644 --- a/src/d/actor/d_a_kui.cpp +++ b/src/d/actor/d_a_kui.cpp @@ -4,68 +4,539 @@ // #include "d/actor/d_a_kui.h" +#include "d/actor/d_a_player.h" +#include "d/actor/d_a_btd.h" +#include "d/actor/d_a_dr2.h" +#include "d/d_bg_s_movebg_actor.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo_rain.h" #include "d/d_procname.h" +#include "d/d_s_play.h" +#include "d/res/res_kui.h" +#include "f_op/f_op_camera.h" +#include "f_op/f_op_actor_mng.h" +#include "f_pc/f_pc_executor.h" +#include "JSystem/JUtility/JUTReport.h" class J3DModelData; /* 00000078-000000C4 .text s_a_i_sub__FPvPv */ -void s_a_i_sub(void*, void*) { - /* Nonmatching */ +static void* s_a_i_sub(void* search, void*) { + if (fopAcM_IsActor(search) && fopAcM_GetName(search) == PROC_DR2) { + return search; + } + return NULL; } /* 000000C4-000000F0 .text search_dragontail__FP9kui_class */ -void search_dragontail(kui_class*) { - /* Nonmatching */ +static dr2_class* search_dragontail(kui_class* i_this) { + return (dr2_class*)fpcM_Search(&s_a_i_sub, i_this); } /* 000000F0-0000013C .text b_a_i_sub__FPvPv */ -void b_a_i_sub(void*, void*) { - /* Nonmatching */ +static void* b_a_i_sub(void* search, void*) { + if (fopAcM_IsActor(search) && fopAcM_GetName(search) == PROC_BTD) { + return search; + } + return NULL; } /* 0000013C-00000168 .text search_btd__FP9kui_class */ -void search_btd(kui_class*) { - /* Nonmatching */ +static btd_class* search_btd(kui_class* i_this) { + return (btd_class*)fpcM_Search(&b_a_i_sub, i_this); } /* 00000168-0000037C .text setEffectMtx__FP10fopAc_ac_cP12J3DModelDataf */ -void setEffectMtx(fopAc_ac_c*, J3DModelData*, float) { - /* Nonmatching */ +static void setEffectMtx(fopAc_ac_c* a_this, J3DModelData* modelData, float scale) { + static Mtx mtx_adj = { + 0.5f, 0.0f, 0.0f, 0.5f, + 0.0f, -0.5f, 0.0f, 0.5f, + 0.0f, 0.0f, 1.0f, 0.0f, + }; + cXyz& eyePos = a_this->eyePos; + camera_class* camera = dCam_getCamera(); + + cXyz look_dir = eyePos - camera->mLookat.mEye; + + cXyz light_dir; + dKyr_get_vectle_calc(&a_this->tevStr.mLightPosWorld, &eyePos, &light_dir); + + cXyz refl; + C_VECHalfAngle(&look_dir, &light_dir, &refl); + Mtx reflMtx; + C_MTXLookAt(reflMtx, &cXyz::Zero, &cXyz::BaseY, &refl); + + mDoMtx_stack_c::scaleS(scale, scale, 1.0f); + mDoMtx_stack_c::concat(mtx_adj); + mDoMtx_stack_c::concat(reflMtx); + MtxP mtx = mDoMtx_stack_c::get(); + mtx[0][3] = 0.0f; + mtx[1][3] = 0.0f; + mtx[2][3] = 0.0f; + + Mtx now_copy; + PSMTXCopy(mDoMtx_stack_c::get(), now_copy); + + for (u16 i = 0; i < modelData->getMaterialNum(); i++) { + J3DMaterial* mat = modelData->getMaterialNodePointer(i); + for (u32 j = 0; j < 8; j++) { + J3DTexMtx* texMtx = mat->getTexMtx(j); + if (texMtx != NULL) { + switch (texMtx->getTexMtxInfo().mInfo) { + case 10: + case 11: + texMtx->getTexMtxInfo().setEffectMtx(now_copy); + break; + } + } + } + } } /* 0000037C-00000540 .text daKui_Draw__FP9kui_class */ -static BOOL daKui_Draw(kui_class*) { - /* Nonmatching */ +static BOOL daKui_Draw(kui_class* i_this) { + if (i_this->type == 3) { + u32 light_type = 0; + if (REG0_S(0) != 0) { + light_type = 1; + } + + i_this->eyePos = i_this->current.pos; + i_this->eyePos.y += REG0_F(10); + + g_env_light.settingTevStruct(light_type, &i_this->eyePos, &i_this->tevStr); + g_env_light.setLightTevColorType(i_this->mpModel2, &i_this->tevStr); + g_env_light.setLightTevColorType(i_this->mpModel, &i_this->tevStr); + + setEffectMtx(i_this, i_this->mpModel2->getModelData(), REG0_F(11) + 1.0f); + setEffectMtx(i_this, i_this->mpModel->getModelData(), REG0_F(12) + 1.0f); + + mDoExt_modelUpdateDL(i_this->mpModel2); + mDoExt_modelUpdateDL(i_this->mpModel); + } else if (i_this->type != 1) { + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->current.pos, &i_this->tevStr); + g_env_light.setLightTevColorType(i_this->mpModel2, &i_this->tevStr); + + dComIfGd_setListBG(); + mDoExt_modelUpdateDL(i_this->mpModel2); + dComIfGd_setList(); + + if (i_this->mpModel) { + g_env_light.setLightTevColorType(i_this->mpModel, &i_this->tevStr); + mDoExt_modelUpdateDL(i_this->mpModel); + } + } + return TRUE; } /* 00000540-00000920 .text demo_camera__FP9kui_class */ -void demo_camera(kui_class*) { - /* Nonmatching */ +static void demo_camera(kui_class* i_this) { + camera_class* camera = dComIfGp_getCamera(dComIfGp_getPlayerCameraID(0)); + s8 bVar2 = true; + + switch ((s8)i_this->field_0x2E8) { + case 0: + break; + case 1: + if (!i_this->eventInfo.checkCommandDemoAccrpt()) { + fopAcM_orderPotentialEvent(i_this, dEvtFlag_STAFF_ALL_e, 0xFFFF, 0); + i_this->eventInfo.onCondition(dEvtCnd_UNK2_e); + bVar2 = false; + break; + } + i_this->field_0x2E8 = i_this->field_0x2E8 + 1; + camera->mCamera.Stop(); + camera->mCamera.SetTrimSize(2); + i_this->field_0x2EA = 0; + // fallthrough + case 2: + i_this->current.pos.y = i_this->home.pos.y + i_this->field_0x30C; + + s32 uVar3 = (s32) i_this->field_0x2EA; + if (uVar3 < 20) { + f32 sin_result = cM_ssin((uVar3 & 0x1F) * 0x800); + i_this->field_0x30C = sin_result * 5.0f; + } else if (uVar3 <= 27) { + if (uVar3 == 27) { + fopAcM_seStartCurrent(i_this, JA_SE_OBJ_ROPE_SW_ON, 0); + dComIfGp_getVibration().StartShock(3, -33, cXyz(0.0f, 1.0f, 0.0f)); + } + cLib_addCalc2(&i_this->field_0x30C, -70.0f, 1.0f, 10.0f); + } else if (uVar3 < 42) { + f32 sin_result = cM_ssin(uVar3 * 0x3A00); + i_this->field_0x30C = sin_result * 5.0f + (-70.0f); + } + + i_this->field_0x2F8 = i_this->home.pos; + i_this->field_0x2F8.y += REG8_F(0) + 200.0f; + cMtx_YrotS(*calc_mtx, i_this->current.angle.y); + + cXyz vec(REG8_F(1) + 800.f, REG8_F(2), REG8_F(3) + 100.0f); + cXyz posVec; + MtxPosition(&vec, &posVec); + + i_this->field_0x2EC = i_this->home.pos + posVec; + + if (i_this->field_0x2EA == 70) { + i_this->field_0x2E8 = 0; + + camera->mCamera.Reset(i_this->field_0x2F8, i_this->field_0x2EC); + camera->mCamera.Start(); + camera->mCamera.SetTrimSize(0); + + dComIfGp_event_reset(); + + dComIfGs_onSwitch(i_this->mSwitchNo, fopAcM_GetRoomNo(i_this)); + mDoAud_seStart(JA_SE_READ_RIDDLE_1); + } + break; + } + + if ((i_this->field_0x2E8 != 0) && bVar2) { + camera->mCamera.Set(i_this->field_0x2F8, i_this->field_0x2EC); + JUTReport(0x19a, 0x1ae, "K SUB COUNT %d", i_this->field_0x2EA); + i_this->field_0x2EA++; + } } /* 00000920-000012E4 .text daKui_Execute__FP9kui_class */ -static BOOL daKui_Execute(kui_class*) { - /* Nonmatching */ +static BOOL daKui_Execute(kui_class* i_this) { + fopAc_ac_c* actor = i_this; + static s16 bure_xa_d[2] = {0x1000, 0xF000}; + + cXyz temp2; + cXyz temp; + daPy_py_c* player; + s16 target_x_angle; + Mtx local_mtx; + + player = (daPy_py_c*)dComIfGp_getPlayer(0); + + if (i_this->field_0x2A2 != 0) { + dr2_class* dragon_tail = search_dragontail(i_this); + btd_class* btd = search_btd(i_this); + + if (dragon_tail != NULL && btd != NULL) { + if ((dragon_tail->field_0x4BA == 0 || dragon_tail->field_0x4BA >= 10) && btd->field_0x2e4 < 10) { + actor->current.pos = dragon_tail->field_0x3B0; + actor->current.angle = dragon_tail->current.angle; + } else { + actor->current.pos.set(0.0f, -10000.0f, 0.0f); + } + } else { + actor->current.pos.set(0.0f, -10000.0f, 0.0f); + } + } + + if (i_this->type == 3) { + if (actor->health == 3) { + temp2 = player->getLeftHandPos() - actor->home.pos; + cMtx_YrotS(*calc_mtx, -player->shape_angle.y); + + MtxPosition(&temp2, &temp); + temp.z *= REG0_F(1) + 1.0f; + + if (REG0_S(0) == 0) { + target_x_angle = -cM_atan2s(temp.z, -temp.y); + } else { + target_x_angle = (s32) cM_atan2s(temp.z, -temp.y); + } + s16 unk = std::fabsf((REG0_F(2) + 3000.0f) * cM_ssin(actor->shape_angle.y)); + + s8 unk_flag = 0; + if (target_x_angle > unk) { + target_x_angle = unk; + unk_flag = 1; + } else if (target_x_angle < (s16)-unk) { + target_x_angle = -unk; + unk_flag = 2; + } + + if (unk_flag != 0 && unk > 2000) { + if (i_this->field_0x2DC[unk_flag] == 0) { + i_this->field_0x2DC[unk_flag] = 0x50; + i_this->field_0x2DC[0] = REG0_S(3) + 40; + + dComIfGp_getVibration().StartShock(REG0_S(2) + 5, -0x21, cXyz(0.0f, 1.0f, 0.0f)); + fopAcM_seStartCurrent(actor, JA_SE_OBJ_ST_CHIME, 0); + + i_this->field_0x2E4 = *(s16*) (bure_xa_d + unk_flag - 1); + i_this->field_0x2E4 *= (s16) (REG17_S(4) + 1); + i_this->field_0x2E6 = REG17_S(5) + 0x400; + } + } + + if (REG0_S(1) == 0) { + actor->shape_angle.y = -(actor->current.angle.y - player->shape_angle.y); + } else { + actor->shape_angle.y = actor->current.angle.y - player->shape_angle.y; + } + } + else { + target_x_angle = 0; + } + + cLib_addCalcAngleS2(&actor->current.angle.x, target_x_angle, 4, REG0_S(1) + 0x200); + if (i_this->field_0x2DC[1] != 0) { + i_this->field_0x2DC[1]--; + } + if (i_this->field_0x2DC[2] != 0) { + i_this->field_0x2DC[2]--; + } + + s16 x = 0; + s16 z = 0; + f32 unk_f = 1.0f; + + if (i_this->field_0x2DC[0] != 0) { + i_this->field_0x2DC[0]--; + + s32 iVar10 = (s32) i_this->field_0x2DC[0]; + f32 fVar1 = iVar10 * (REG0_F(16) + 40.0f); + + x = (s16) (fVar1 * cM_ssin(iVar10 * (REG0_S(4) + 0x1900))); + z = (s16) (fVar1 * cM_scos(iVar10 * (REG0_S(5) + 0x2100)) * 0.25f); + + if ((iVar10 & 1) != 0) { + unk_f = (iVar10 * (REG0_F(17) + 0.001f)) + 1.0f; + } + + if (i_this->field_0x2DC[0] == 0 && actor->health == 3 && REG0_S(3) == 0) { + dComIfGs_onSwitch(i_this->mSwitchNo, fopAcM_GetRoomNo(actor)); + } + } + + cLib_addCalcAngleS2(&i_this->field_0x2E2, i_this->field_0x2E4, 4, i_this->field_0x2E6); + cLib_addCalcAngleS2(&i_this->field_0x2E4, 0, 1, REG17_S(6) + 0x80); + cLib_addCalcAngleS2(&i_this->field_0x2E6, REG17_S(7) + 0x100, 1, REG17_S(8) + 0x40); + + MtxTrans(actor->home.pos.x, actor->home.pos.y, actor->home.pos.z, FALSE); + mDoMtx_YrotM(*calc_mtx, actor->current.angle.y); + + MtxPush(); + mDoMtx_YrotM(*calc_mtx, actor->shape_angle.y); + mDoMtx_XrotM(*calc_mtx, x + i_this->field_0x2E2); + mDoMtx_ZrotM(*calc_mtx, z); + mDoMtx_YrotM(*calc_mtx, -actor->shape_angle.y); + MtxScale(unk_f, unk_f, unk_f, TRUE); + i_this->mpModel->setBaseTRMtx(*calc_mtx); + + + MtxPull(); + mDoMtx_YrotM(*calc_mtx, actor->shape_angle.y + REG0_S(5)); + mDoMtx_XrotM(*calc_mtx, actor->current.angle.x + REG0_S(6)); + mDoMtx_YrotM(*calc_mtx, -(actor->shape_angle.y + REG0_S(5) + 0x4000)); + + MtxScale(unk_f, 1.0, unk_f, TRUE); + i_this->mpModel2->setBaseTRMtx(*calc_mtx); + MtxTrans(0.0, REG0_F(6) + -850.0f, 0.0, TRUE); + + temp2.setall(0.0f); + MtxPosition(&temp2, &actor->current.pos); + + MtxTrans(actor->current.pos.x, actor->current.pos.y, actor->current.pos.z, FALSE); + mDoMtx_YrotM(*calc_mtx, actor->current.angle.y); + MtxScale(actor->scale.x, actor->scale.y, actor->scale.z, TRUE); + cMtx_copy(*calc_mtx, i_this->field_0x2A8); + i_this->field_0x2D8->Move(); + } else { + MtxTrans(actor->current.pos.x, actor->current.pos.y, actor->current.pos.z, FALSE); + mDoMtx_YrotM(*calc_mtx, actor->current.angle.y); + if (i_this->type == 2 || i_this->type == 4) { + i_this->mpModel->setBaseTRMtx(*calc_mtx); + } + + i_this->mpModel2->setBaseScale(actor->scale); + i_this->mpModel2->setBaseTRMtx(*calc_mtx); + if (i_this->field_0x2A2) { + cMtx_scale(local_mtx, 4.0f, 4.0f, 4.0f); + } else { + cMtx_scale(local_mtx, actor->scale.x, actor->scale.y, actor->scale.z); + } + + cMtx_concat(*calc_mtx, local_mtx, i_this->field_0x2A8); + i_this->field_0x2D8->Move(); + } + + if (i_this->type == 2 || i_this->type == 4) { + BOOL is_switch = dComIfGs_isSwitch(i_this->mSwitchNo, dComIfGp_roomControl_getStayNo()); + + if (!is_switch) { + if (actor->health == 3 && i_this->field_0x308 == 0) { + i_this->field_0x308 = 1000; + } + } else { + actor->current.pos.y = actor->home.pos.y - 70.0f; + } + + if (i_this->field_0x308 != 0) { + i_this->field_0x308--; + + s16 finished = REG8_S(3) + 970; + if (i_this->field_0x308 == finished) { + if (i_this->type == 2) { + i_this->field_0x2E8 = 1; + } else { + fopAcM_seStartCurrent(actor, JA_SE_OBJ_ROPE_SW_ON, 0); + dComIfGs_onSwitch(i_this->mSwitchNo, fopAcM_GetRoomNo(actor)); + mDoAud_seStart(JA_SE_READ_RIDDLE_1); + } + } + } + demo_camera(i_this); + } + + actor->eyePos = actor->current.pos; + return TRUE; } /* 000012E4-000012EC .text daKui_IsDelete__FP9kui_class */ static BOOL daKui_IsDelete(kui_class*) { - /* Nonmatching */ + return TRUE; } /* 000012EC-00001340 .text daKui_Delete__FP9kui_class */ -static BOOL daKui_Delete(kui_class*) { - /* Nonmatching */ +static BOOL daKui_Delete(kui_class* i_this) { + dComIfG_resDelete(&i_this->mPhs, "Kui"); + dComIfG_Bgsp()->Release(i_this->field_0x2D8); + return TRUE; } /* 00001340-00001664 .text daKui_CreateHeap__FP10fopAc_ac_c */ -static BOOL daKui_CreateHeap(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL daKui_CreateHeap(fopAc_ac_c* a_this) { + kui_class* i_this = (kui_class*)a_this; + J3DModelData* modelData; + + if (i_this->type == 3) { + // Bell body + modelData = (J3DModelData*)dComIfG_getObjectRes("Kui", KUI_BDL_HKANE1); + JUT_ASSERT(0x353, modelData != NULL); + + i_this->mpModel = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (!i_this->mpModel) { + return FALSE; + } + + // Bell handle + modelData = (J3DModelData*)dComIfG_getObjectRes("Kui", KUI_BDL_HKANE2); + JUT_ASSERT(0x35F, modelData != NULL); + + i_this->mpModel2 = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (!i_this->mpModel2) { + return FALSE; + } + } else { + // Rope + modelData = (J3DModelData*)dComIfG_getObjectRes("Kui", KUI_BDL_OBI_ROPETAG); + JUT_ASSERT(0x36B, modelData != NULL); + + i_this->mpModel2 = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000002); + if (!i_this->mpModel2) { + return FALSE; + } + + if (i_this->type == 2 || i_this->type == 4) { + // Rope swing attachment + modelData = (J3DModelData*)dComIfG_getObjectRes("Kui", KUI_BDL_MROPESW); + JUT_ASSERT(0x377, modelData != NULL); + + i_this->mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000002); + if (!i_this->mpModel) { + return FALSE; + } + } + } + + dBgW* bgw = new dBgW(); + i_this->field_0x2D8 = bgw; + if (!i_this->field_0x2D8) { + return FALSE; + } + + cBgD_t* pData = (cBgD_t*)dComIfG_getObjectRes("Kui", KUI_DZB_OBI_ROPETAG); + if (i_this->field_0x2D8->Set(pData, cBgW::MOVE_BG_e, &i_this->field_0x2A8) == true) { + return FALSE; + } + + i_this->field_0x2D8->SetCrrFunc(dBgS_MoveBGProc_Typical); + + return TRUE; } /* 00001664-000018C8 .text daKui_Create__FP10fopAc_ac_c */ -static cPhs_State daKui_Create(fopAc_ac_c*) { - /* Nonmatching */ +static cPhs_State daKui_Create(fopAc_ac_c* a_this) { + kui_class* i_this; + cPhs_State result; + + fopAcM_SetupActor(a_this, kui_class); + i_this = (kui_class*) a_this; + + result = dComIfG_resLoad(&i_this->mPhs, "Kui"); + if (result == cPhs_COMPLEATE_e) { + if (fopAcM_GetParam(a_this) == -1) { + return cPhs_ERROR_e; + } + + i_this->type = fopAcM_GetParam(a_this) & 0xF; + i_this->field_0x2A2 = fopAcM_GetParam(a_this) & 0xF0; + i_this->field_0x2A1 = fopAcM_GetParam(a_this) >> 8; + i_this->mSwitchNo = fopAcM_GetParam(a_this) >> 0x18; + + if (i_this->mSwitchNo == 0xFF) { + i_this->mSwitchNo = 0; + } + if (i_this->type == 3) { + i_this->field_0x2A1 = 4; + } + + switch (i_this->field_0x2A1) { + case 0: + i_this->scale.x = 0.5f; + i_this->scale.y = 0.5f; + break; + case 1: + i_this->scale.x = 2.0f; + i_this->scale.y = 2.0f; + break; + case 2: + i_this->scale.z = 2.0f; + break; + case 3: + i_this->scale.x = 0.5f; + i_this->scale.y = 0.5f; + i_this->scale.z = 2.0f; + break; + case 4: + i_this->scale.setall(2.0f); + break; + case 5: + i_this->scale.x = 4.0f; + i_this->scale.y = REG0_F(2) + 2.0f; + i_this->scale.z = 4.0f; + break; + case 0xff: + default: + break; + } + + if (!fopAcM_entrySolidHeap(i_this, &daKui_CreateHeap, 0x29f4)) { + return cPhs_ERROR_e; + } + + if (dComIfG_Bgsp()->Regist(i_this->field_0x2D8, i_this)) { + return cPhs_ERROR_e; + } + + fopAcM_SetMtx(i_this, i_this->mpModel2->getBaseTRMtx()); + if (i_this->type >= 2) { + fopAcM_SetMin(i_this, -200.0f, -1000.0f, -200.0f); + fopAcM_SetMax(i_this, 200.0f, 2000.0f, 200.0f); + } else { + fopAcM_SetMin(i_this, -200.0f, -200.0f, -200.0f); + fopAcM_SetMax(i_this, 200.0f, 200.0f, 200.0f); + } + } + return result; } static actor_method_class l_daKui_Method = { From 28f3c8425e792179c79408c82b285444b74de59c Mon Sep 17 00:00:00 2001 From: WilliamArnett <149556961+WilliamArnett@users.noreply.github.com> Date: Sun, 18 May 2025 20:42:29 -0500 Subject: [PATCH 02/10] d_a_tag_kk1 (#755) * 99% match * Rewrote _execute to increase accuracy. Only issue in .text is a label not loading correctly. I have no idea how to fix this. * Equivalent. Weak func ordering. * Update src/d/actor/d_a_tag_kk1.cpp Co-authored-by: LagoLunatic * Update src/d/actor/d_a_tag_kk1.cpp Co-authored-by: LagoLunatic * Remove explicit `this` Co-authored-by: LagoLunatic * Implemented hio_prm_c struct --------- Co-authored-by: LagoLunatic --- configure.py | 2 +- include/d/actor/d_a_tag_kk1.h | 33 +++++++++---- src/d/actor/d_a_tag_kk1.cpp | 92 ++++++++++++++++++++++++++++------- 3 files changed, 99 insertions(+), 28 deletions(-) diff --git a/configure.py b/configure.py index 06b5b6537..2fb0a01fd 100755 --- a/configure.py +++ b/configure.py @@ -1432,7 +1432,7 @@ config.libs = [ ActorRel(Matching, "d_a_tag_ghostship"), ActorRel(NonMatching, "d_a_tag_hint"), ActorRel(Matching, "d_a_tag_kb_item"), - ActorRel(NonMatching, "d_a_tag_kk1"), + ActorRel(Equivalent, "d_a_tag_kk1", extra_cflags=['-pragma "nosyminline on"']), # weak func order ActorRel(NonMatching, "d_a_tag_light"), ActorRel(Matching, "d_a_tag_msg"), ActorRel(NonMatching, "d_a_tag_photo"), diff --git a/include/d/actor/d_a_tag_kk1.h b/include/d/actor/d_a_tag_kk1.h index 96cb1240e..bd0a219e1 100644 --- a/include/d/actor/d_a_tag_kk1.h +++ b/include/d/actor/d_a_tag_kk1.h @@ -1,26 +1,39 @@ #ifndef D_A_TAG_KK1_H #define D_A_TAG_KK1_H -#include "f_op/f_op_actor.h" +#include "d/d_npc.h" +#include "m_Do/m_Do_hostIO.h" -class daTag_Kk1_c : public fopAc_ac_c { +class daTag_Kk1_c : public fopNpc_npc_c { public: - void createInit(); + BOOL createInit(); bool _draw(); bool _execute(); bool _delete(); cPhs_State _create(); public: - /* Place member variables here */ -}; + /* 0x6C4 */ u8 padding_0x6C4; + /* 0x6C5 */ bool mTagSet; + /* 0x6C6 */ bool mNameIsWrong; +}; // Size: 0x6C8 -class daTag_Kk1_HIO_c { -public: - daTag_Kk1_HIO_c(); -public: - /* Place member variables here */ +class daTag_Kk1_HIO_c : public JORReflexible{ + + public: + daTag_Kk1_HIO_c(); + virtual ~daTag_Kk1_HIO_c(){}; + + public: + struct hio_prm_c { + /* 0x08 */ f32 mHorizontalDistance; + /* 0x0C */ f32 mVerticalDistance; + /* 0x10 */ u8 field_0x10; + }; + + /* 0x04 */ s8 mNo; + /* 0x08 */ hio_prm_c prm; }; #endif /* D_A_TAG_KK1_H */ diff --git a/src/d/actor/d_a_tag_kk1.cpp b/src/d/actor/d_a_tag_kk1.cpp index 0bc9bb0bf..0e171ca80 100644 --- a/src/d/actor/d_a_tag_kk1.cpp +++ b/src/d/actor/d_a_tag_kk1.cpp @@ -3,64 +3,122 @@ // Translation Unit: d_a_tag_kk1.cpp // + #include "d/actor/d_a_tag_kk1.h" +#include "d/d_com_inf_game.h" #include "d/d_procname.h" + +static daTag_Kk1_HIO_c l_HIO; + +static const u8 dummy5[] = { 0x00, 0xFF, 0x00, 0x80}; + /* 000000EC-00000120 .text __ct__15daTag_Kk1_HIO_cFv */ daTag_Kk1_HIO_c::daTag_Kk1_HIO_c() { - /* Nonmatching */ + static hio_prm_c a_prm_tbl = { + 350.0f, + 30.0f, + 0, + }; + prm = a_prm_tbl; + mNo = -1; } /* 00000120-00000128 .text createInit__11daTag_Kk1_cFv */ -void daTag_Kk1_c::createInit() { - /* Nonmatching */ +BOOL daTag_Kk1_c::createInit() { + return TRUE; } /* 00000128-00000130 .text _draw__11daTag_Kk1_cFv */ bool daTag_Kk1_c::_draw() { - /* Nonmatching */ + return true; } /* 00000130-0000024C .text _execute__11daTag_Kk1_cFv */ bool daTag_Kk1_c::_execute() { - /* Nonmatching */ + + f32 distance = current.pos.abs(dComIfGp_getPlayer(0)->current.pos); + f32 vert_distance = dComIfGp_getPlayer(0)->current.pos.y - current.pos.y; + mTagSet = false; + if ( + (distance < l_HIO.prm.mHorizontalDistance) && (vert_distance< l_HIO.prm.mVerticalDistance) + ){ + s16 angle_deviation = dComIfGp_getPlayer(0)->shape_angle.y - current.angle.y; + angle_deviation =abs(angle_deviation); + if(angle_deviation < 0x1000){ + mTagSet = true; + } + } + return true; } + /* 0000024C-000002A0 .text _delete__11daTag_Kk1_cFv */ bool daTag_Kk1_c::_delete() { - /* Nonmatching */ + + if (l_HIO.mNo >= 0) { + mDoHIO_deleteChild(l_HIO.mNo); + l_HIO.mNo = -1; + } + return TRUE; } /* 000002A0-0000046C .text _create__11daTag_Kk1_cFv */ cPhs_State daTag_Kk1_c::_create() { - /* Nonmatching */ + + u32 name_int = 0; + s32 o_phsState = cPhs_COMPLEATE_e; + + fopAcM_SetupActor(this, daTag_Kk1_c); + + switch(fopAcM_GetName(this)){ + case PROC_TAG_KK1: + mNameIsWrong = false; + break; + default: + return cPhs_ERROR_e; + } + + if(l_HIO.mNo < 0){ + //Poor Muuru (Mila) chase startup tag + l_HIO.mNo = mDoHIO_createChild("貧乏ム−ル追跡起動タグ",&l_HIO); + } + + if(!createInit()){ + o_phsState = cPhs_ERROR_e; + } + + fpcM_GetName(&name_int); + return o_phsState; } /* 00000694-000006B4 .text daTag_Kk1_Create__FP10fopAc_ac_c */ -static cPhs_State daTag_Kk1_Create(fopAc_ac_c*) { - /* Nonmatching */ +static cPhs_State daTag_Kk1_Create(fopAc_ac_c* obj) { + (static_cast(obj))->_create(); } /* 000006B4-000006D4 .text daTag_Kk1_Delete__FP11daTag_Kk1_c */ -static BOOL daTag_Kk1_Delete(daTag_Kk1_c*) { - /* Nonmatching */ +static BOOL daTag_Kk1_Delete(daTag_Kk1_c* obj) { + (static_cast(obj))->_delete(); } /* 000006D4-000006F4 .text daTag_Kk1_Execute__FP11daTag_Kk1_c */ -static BOOL daTag_Kk1_Execute(daTag_Kk1_c*) { - /* Nonmatching */ +static BOOL daTag_Kk1_Execute(daTag_Kk1_c* obj) { + (static_cast(obj))->_execute(); } /* 000006F4-00000714 .text daTag_Kk1_Draw__FP11daTag_Kk1_c */ -static BOOL daTag_Kk1_Draw(daTag_Kk1_c*) { - /* Nonmatching */ +static BOOL daTag_Kk1_Draw(daTag_Kk1_c* obj) { + (static_cast(obj))->_draw(); + } /* 00000714-0000071C .text daTag_Kk1_IsDelete__FP11daTag_Kk1_c */ -static BOOL daTag_Kk1_IsDelete(daTag_Kk1_c*) { - /* Nonmatching */ +static BOOL daTag_Kk1_IsDelete(daTag_Kk1_c* obj) { + return TRUE; } + static actor_method_class l_daTag_Kk1_Method = { (process_method_func)daTag_Kk1_Create, (process_method_func)daTag_Kk1_Delete, From 3f9a041528cff4aedca58a7526894cc9b2367742 Mon Sep 17 00:00:00 2001 From: Azurpourpre <100833633+Azurpourpre@users.noreply.github.com> Date: Mon, 19 May 2025 03:00:00 +0000 Subject: [PATCH 03/10] D_a_kita matching (#751) * ride_call_back progress * daKita_Draw match * kita_move progress * ride_call_back match * daKita_Execute will match * daKita_Delete & daKita_IsDelete match * CallbackCreateHeap match * daKita_Create progress * himo_create progress * d_a_kita : small overall progress * hand_draw match * daShand_Draw match * d_a_shand/control1 match except regalloc * control2 almost done (regalloc issue) * control3 match * cut_control progress * cut_control3 match * normal progress * cut match * hand_move progress * daShand_Execute match * daShand_Delete & daShand_IsDelete match * daShand_Create progress * daShand_solidHeapCB match & useHeapInit progress * daShand_HIO_c::daShand_HIO_c match * control1 match * control2 match * cut_control match * hand_move progress * daShand_Create progress * useHeapInit match * Minor fixing * renaming fields * Merge with upstream now compiling * cleaning up & minor fixes * fixing string * adding suggestions (PR #751) * d_a_shand integration & kita_move gndchk position fix * Removing awful cap_min_val inline * 100% match * Adding match to configure.py --- configure.py | 2 +- include/d/actor/d_a_kita.h | 46 +++- src/d/actor/d_a_kita.cpp | 445 +++++++++++++++++++++++++++++++++++-- 3 files changed, 473 insertions(+), 20 deletions(-) diff --git a/configure.py b/configure.py index 2fb0a01fd..c5421c4c1 100755 --- a/configure.py +++ b/configure.py @@ -1547,7 +1547,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_icelift"), ActorRel(NonMatching, "d_a_kb"), ActorRel(NonMatching, "d_a_kddoor"), - ActorRel(NonMatching, "d_a_kita"), + ActorRel(Matching, "d_a_kita", extra_cflags=['-pragma "sym off"']), ActorRel(NonMatching, "d_a_klft"), ActorRel(NonMatching, "d_a_kmon"), ActorRel(Matching, "d_a_komore", extra_cflags=['-pragma "nosyminline on"']), diff --git a/include/d/actor/d_a_kita.h b/include/d/actor/d_a_kita.h index a6559e50c..b64eda6b8 100644 --- a/include/d/actor/d_a_kita.h +++ b/include/d/actor/d_a_kita.h @@ -1,11 +1,53 @@ #ifndef D_A_KITA_H #define D_A_KITA_H +#include "JSystem/JParticle/JPAEmitter.h" +#include "SSystem/SComponent/c_phase.h" +#include "d/d_bg_s_acch.h" +#include "d/d_bg_w.h" +#include "d/d_cc_d.h" #include "f_op/f_op_actor.h" class kita_class : public fopAc_ac_c { -public: - /* Place member variables here */ +public: // Methods + kita_class() {}; + +public: // Attributes + /* 0x290 */ request_of_phase_process_class mPhs; + /* 0x298 */ short mMoveCounter; + /* 0x29A */ short field_29A; + /* 0x29C */ J3DModel* mModel; + /* 0x2A0 */ u8 field_2A0; + /* 0x2A1 */ u8 field_2A1; + /* 0x2A4 */ cXyz mPosRel; + /* 0x2A8 */ cXyz field_2B0; + /* 0x2B4 */ cXyz field_2BC; + /* 0x2C8 */ csXyz field_2C8; + /* 0x2D0 */ float mHeight; + /* 0x2D4 */ fpc_ProcID field_2D4[4]; + /* 0x2E4 */ u8 field_2E4[4]; + /* 0x2E8 */ cXyz field_2E8[4]; + /* 0x318 */ u8 field_318[4]; + /* 0x31C */ short mRotY; + /* 0x31E */ short mRotX; + /* 0x320 */ float field_320; + /* 0x324 */ int unused_324; + /* 0x328 */ Mtx mBgwMtx; + /* 0x358 */ dBgW* pm_bgw; + /* 0x35C */ float field_35C; + /* 0x360 */ u8 field_360; + /* 0x362 */ short mPlayerAngle; + /* 0x364 */ float field_364; + /* 0x368 */ float mAngleYSpeed; + /* 0x36C */ float field_36C; + /* 0x370 */ float field_370; + /* 0x374 */ short field_374; + /* 0x376 */ short mExecuteCount; + /* 0x378 */ JPABaseEmitter* mBaseEmitter; + /* 0x37C */ dCcD_Stts mStts; + /* 0x3B8 */ dCcD_Sph mSph; + /* 0x4E4 */ dBgS_AcchCir mAcchCir; + /* 0x524 */ dBgS_ObjAcch mAcch; }; #endif /* D_A_KITA_H */ diff --git a/src/d/actor/d_a_kita.cpp b/src/d/actor/d_a_kita.cpp index 18db92641..81d916488 100644 --- a/src/d/actor/d_a_kita.cpp +++ b/src/d/actor/d_a_kita.cpp @@ -4,52 +4,463 @@ // #include "d/actor/d_a_kita.h" +#include "SSystem/SComponent/c_phase.h" +#include "d/actor/d_a_player.h" +#include "d/actor/d_a_shand.h" #include "d/d_bg_w.h" +#include "d/d_com_inf_game.h" #include "d/d_procname.h" +#include "d/d_s_play.h" +#include "d/res/res_kita.h" +#include "dolphin/types.h" +#include "f_op/f_op_actor.h" +#include "f_op/f_op_actor_mng.h" +#include "d/d_bg_s_movebg_actor.h" + +#include "weak_data_1811.h" // IWYU pragma: keep + /* 00000078-0000032C .text ride_call_back__FP4dBgWP10fopAc_ac_cP10fopAc_ac_c */ -void ride_call_back(dBgW*, fopAc_ac_c*, fopAc_ac_c*) { - /* Nonmatching */ +void ride_call_back(dBgW* bgw, fopAc_ac_c* i_ac, fopAc_ac_c* i_pt) { + kita_class* pActor = static_cast(i_ac); + + cXyz delta_pos, local_44, local_50; + if (!pActor->field_29A || (pActor->field_360 != 0)) { + mDoMtx_YrotS(*calc_mtx, -pActor->current.angle.y); + delta_pos = i_pt->current.pos - pActor->current.pos; + MtxPosition(&delta_pos,&local_44); + delta_pos = i_pt->old.pos - pActor->current.pos; + MtxPosition(&delta_pos, &local_50); + if (fopAcM_GetName(i_pt) == PROC_PLAYER) { + pActor->mExecuteCount = 10; + } + short zAngle_target = -local_44.x * ((REG0_F(0) + 10.0f) / pActor->scale.x); + short xAngle_target = local_44.z * ((REG0_F(0) + 10.0f) / pActor->scale.z); + cLib_addCalcAngleS2(&pActor->current.angle.x,xAngle_target,10,0x800); + cLib_addCalcAngleS2(&pActor->current.angle.z,zAngle_target,10,0x800); + + f32 min_val_x = (REG0_F(4) + 50.0f) * std::abs(local_44.z - local_50.z); + if(pActor->field_2BC.x < min_val_x) pActor->field_2BC.x = min_val_x; + + f32 min_val_z = (REG0_F(4) + 50.0f) * std::abs(local_44.x - local_50.x); + if(pActor->field_2BC.z < min_val_z) pActor->field_2BC.z = min_val_z; + + float fVar1 = (REG0_F(8) + 5.0f) * std::abs(local_44.x - local_50.x); + if (fVar1 > 10.0f && pActor->field_2B0.x < fVar1) { + cLib_addCalc2(&pActor->field_2B0.x,fVar1,1.0,REG0_F(7) + 1.2f); + } + fVar1 = (REG0_F(8) + 5.0f) * std::abs(local_44.z - local_50.z); + if (fVar1 > 10.0f && pActor->field_2B0.z < fVar1) { + cLib_addCalc2(&pActor->field_2B0.z,fVar1,1.0,REG0_F(7) + 1.2f); + } + cLib_addCalc2(&pActor->mPosRel.y,REG0_F(2) + -100.0f,0.1,REG0_F(3) + 10.0f); + } } /* 00000368-00000408 .text daKita_Draw__FP10kita_class */ -static BOOL daKita_Draw(kita_class*) { - /* Nonmatching */ +static BOOL daKita_Draw(kita_class* i_this) { + dKy_getEnvlight().settingTevStruct(TEV_TYPE_BG0, &i_this->current.pos, &i_this->tevStr); + dKy_getEnvlight().setLightTevColorType(i_this->mModel, &i_this->tevStr); + dComIfGd_setListBG(); + mDoExt_modelUpdateDL(i_this->mModel); + dComIfGd_setList(); + return TRUE; } /* 00000408-0000126C .text kita_move__FP10kita_class */ -void kita_move(kita_class*) { - /* Nonmatching */ +void kita_move(kita_class* i_this) { + fopAc_ac_c* actor = static_cast(i_this); + static u8 himo_off_check[4] = {1,2,4, 8}; + static short himo_off_ya[16] = {1, 0xA000, 0x6000, 0x8000, 0xE000, 0xC000, 0xE000, 0xA000, 0x2000, 0x2000, 0x4000, 0x6000, 0, 0xE000, 0x2000, 1}; + static short himo_off_xa[16] = {0, 0xF000, 0xF000, 0xC800, 0xF000, 0xC800, 0, 0xC000, 0xF000, 0, 0xC800, 0xC000, 0xC800, 0xC000, 0xC000, 0}; + static short himo_off_yp[16] = {0, 0x96, 0x96, 0x190, 0x96, 0x190, 0x190,0x1F4, 0x96, 0x190, 0x190, 0x1F4, 0x190, 0x1F4, 0x1F4, 0}; + + daPy_py_c* player_actor = daPy_getPlayerActorClass(); + i_this->mMoveCounter++; + switch(i_this->field_29A){ + case 0: + s32 mask = 0; + for(int i = 0; i < 4; i++){ + if(i_this->field_318[i] == 2){ + i_this->field_318[i] = 0; + i_this->field_320 = 0; + } + if(i_this->field_318[i] != 0){ + if(i_this->field_318[i] == 1){ + i_this->field_320 = 0; + i_this->field_318[i] = 5; + } + mask |= himo_off_check[i]; + } + } + + short xa_offset, ya_offset; + ya_offset = himo_off_ya[mask]; + xa_offset = himo_off_xa[mask]; + cLib_addCalc2(&i_this->mHeight, REG0_F(4) + (-static_cast(himo_off_yp[mask]) * 0.3f), 0.05, i_this->field_320 * 250.0f); + if(mask == 0b1111){ + i_this->field_29A = 1; + + dBgS_GndChk solid_ground_check; + Vec sgc_pos; + f32 sgc_c = actor->current.pos.x, sgc_y = actor->current.pos.y, sgc_z = actor->current.pos.z; + sgc_y -= 200.0f; + sgc_pos.x = sgc_c; sgc_pos.y = sgc_y; sgc_pos.z = sgc_z; + solid_ground_check.SetPos(&sgc_pos); + float solid_ground_cross = REG0_F(13) + dComIfG_Bgsp()->GroundCross(&solid_ground_check); + if (i_this->field_35C < solid_ground_cross) i_this->field_35C = solid_ground_cross; + + dBgS_ObjGndChk_Spl liquid_ground_check; + Vec lgc_pos; + f32 lgc_x = i_this->current.pos.x, lgc_y = i_this->current.pos.y, lgc_z = i_this->current.pos.z; + lgc_y -= 200.0f; + lgc_pos.x = lgc_x; lgc_pos.y = lgc_y; lgc_pos.z = lgc_z; + liquid_ground_check.SetPos(&lgc_pos); + float liquid_gnd_cross = dComIfG_Bgsp()->GroundCross(&liquid_ground_check); + if(liquid_gnd_cross != C_BG_MIN_HEIGHT && liquid_gnd_cross > i_this->field_35C){ + i_this->field_35C = liquid_gnd_cross + 40.0f + REG0_F(17); + i_this->field_360 = 1; + } + actor->health = 0; + } + short maxSpeed = i_this->field_320 * 10000.0f; + cLib_addCalcAngleS2(&i_this->mRotX, xa_offset, 16, maxSpeed); + if(xa_offset != 0) cLib_addCalcAngleS2(&i_this->mRotY, ya_offset, 4, maxSpeed * 2); + cLib_addCalc2(&i_this->field_320, 1.0, 1.0, REG0_F(14) + 0.001f); + cLib_addCalcAngleS2(&actor->current.angle.x, 0, 10, 0x200); + cLib_addCalcAngleS2(&actor->current.angle.z, 0, 10, 0x200); + i_this->field_2C8.x = i_this->field_2BC.x * JMASSin(i_this->mMoveCounter * 1500); + i_this->field_2C8.z = i_this->field_2BC.z * JMASSin(i_this->mMoveCounter * 1300); + cLib_addCalc2(&i_this->field_2BC.x, REG0_F(9) + 300.0f, 1.0, REG0_F(3) + 20.0f); + cLib_addCalc2(&i_this->field_2BC.z, REG0_F(9) + 300.0f, 1.0, REG0_F(3) + 20.0f); + i_this->mPosRel.x = i_this->field_2B0.x * JMASSin(i_this->mMoveCounter * 750); + i_this->mPosRel.z = i_this->field_2B0.z * JMASSin(i_this->mMoveCounter * 900); + cLib_addCalc0(&i_this->field_2B0.x, 1.0, REG0_F(6) + 0.25f); + cLib_addCalc0(&i_this->field_2B0.z, 1.0, REG0_F(6) + 0.25f); + actor->shape_angle = actor->current.angle + i_this->field_2C8; + actor->current.pos = actor->home.pos + i_this->mPosRel; + actor->current.pos.y += i_this->mHeight; + cLib_addCalc0(&i_this->mPosRel.y, 0.05f, REG0_F(7) + 2.0f); + + break; + + case 1: + if(i_this->field_360 == 2){ + i_this->mSph.SetC(actor->current.pos); + dComIfG_Ccsp()->Set(&i_this->mSph); + if(i_this->mSph.ChkTgHit() != 0){ + if(i_this->mExecuteCount != 0){ + s16 angleY_kita_player = fopAcM_searchPlayerAngleY(actor) - player_actor->shape_angle.y; + i_this->field_36C = (REG0_F(2) + -6.0f) * JMASCos(angleY_kita_player); + float fVar3 = fopAcM_searchPlayerDistance(actor) * 0.003f; + if(fVar3 > 1.0f) fVar3 = 1.0f; + i_this->field_370 = (REG0_F(3) + 200.0f) * JMASSin(angleY_kita_player) * fVar3; + i_this->mPlayerAngle = fopAcM_searchPlayerAngleY(actor); + i_this->field_374 = 20; + } + else { + short angle = fopAcM_searchPlayerAngleY(actor) - player_actor->shape_angle.y; + i_this->field_36C = (REG0_F(12) + 6.0f) * JMASCos(angle); + i_this->field_370 = cM_rndFX(100.0); + i_this->mPlayerAngle = fopAcM_searchPlayerAngleY(actor); + i_this->field_374 = 20; + } + fopAcM_seStartCurrent(actor, JA_SE_LK_FLIFT_GO_WATER, 0); + } + mDoMtx_YrotS(*calc_mtx, i_this->mPlayerAngle); + cXyz pos_offset2, pos_offset; + pos_offset2.x = 0.0f; + pos_offset2.y = 0.0f; + pos_offset2.z = i_this->field_364 * 2.0f; + MtxPosition(&pos_offset2, &pos_offset); + i_this->current.pos += pos_offset; + i_this->current.angle.y += static_cast(i_this->mAngleYSpeed); + if(i_this->field_374 != 0){ + i_this->field_374--; + cLib_addCalc2(&i_this->field_364, i_this->field_36C, 1.0, REG0_F(5) + 0.3f); + cLib_addCalc2(&i_this->mAngleYSpeed, i_this->field_370, 1.0, REG0_F(6) + 5.0f); + } + else{ + cLib_addCalc0(&i_this->field_364, 1.0, REG0_F(0) + 0.1f); + cLib_addCalc0(&i_this->mAngleYSpeed, 1.0, REG0_F(1) + 1.0f); + } + } + else { + cLib_addCalc2(&actor->current.pos.x, actor->home.pos.x, 0.5, 10.0); + cLib_addCalc2(&actor->current.pos.z, actor->home.pos.z, 0.5, 10.0); + } + cLib_addCalcAngleS2(&actor->current.angle.x, 0, 10, 0x300); + cLib_addCalcAngleS2(&actor->current.angle.z, 0, 10, 0x300); + cLib_addCalcAngleS2(&i_this->mRotX, 0, 4, 0x200); + + float fVar4; + short local29A; + if(i_this->field_360 == 2){ + fVar4 = 1.0; + local29A = 800; + } + else { + fVar4 = 0.0; + local29A = 2500; + } + i_this->field_2C8.x = i_this->field_2BC.x * JMASSin(i_this->mMoveCounter * local29A); + i_this->field_2C8.z = i_this->field_2BC.z * JMASSin(i_this->mMoveCounter * (local29A - 200)); + cLib_addCalc2(&i_this->field_2BC.x, (REG0_F(9) + 400.0f) * fVar4, 1.0, REG0_F(3) + 20.0f); + cLib_addCalc2(&i_this->field_2BC.z, (REG0_F(9) + 400.0f) * fVar4, 1.0, REG0_F(3) + 20.0f); + + actor->shape_angle = actor->current.angle + i_this->field_2C8; + actor->current.pos.y += actor->speed.y; + actor->speed.y -= 5.0f; + if(actor->speed.y < -150.0f) actor->speed.y = -150.0f; + + if(actor->current.pos.y <= i_this->field_35C){ + actor->current.pos.y = i_this->field_35C; + if(i_this->speed.y < -50.0f){ + i_this->field_2BC.z= 2000.0f; + i_this->field_2BC.x = 2000.0f; + if(i_this->field_360 != 0){ + i_this->field_360 = 2; + fopAcM_seStart(actor, JA_SE_OBJ_P_FLOWER_LAND_W, 0); + cXyz particle_scale(3.0, 3.0, 3.0); + dComIfGp_particle_set(dPa_name::ID_SCENE_828C, &actor->current.pos); + dComIfGp_particle_set(dPa_name::ID_COMMON_003F, &actor->current.pos, 0, &particle_scale); + + dComIfGp_getVibration().StartShock(REG0_S(2) + 4, -0x21, cXyz(0.0, 1.0, 0.0)); + } + else{ + fopAcM_seStart(actor, JA_SE_OBJ_KOKIRI_H_LANDING, 0); + } + } + actor->speed.y = 0; + cLib_addCalcAngleS2(&i_this->mRotX, 0, 2, 0x2000); + } + if(i_this->field_360 != 0){ + i_this->mAcch.CrrPos(*dComIfG_Bgsp()); + } + break; + } } /* 00001894-000019F8 .text himo_create__FP10kita_class */ -cPhs_State himo_create(kita_class*) { - /* Nonmatching */ +cPhs_State himo_create(kita_class* i_this) { + static short yad[4] = {0x2000, 0xE000, 0x6000, 0xA000}; + int shand_count = 0; + fopAcM_prm_class *param; + shand_class* shand_i; + + for(int i = 0; i < 4; i++){ + switch(i_this->field_2E4[i]){ + case 0: + param = fopAcM_CreateAppend(); + param->base.position = i_this->current.pos; + param->base.angle.y = yad[i]; + param->base.parameters = 0xFFFFFF35; + param->room_no = i_this->current.roomNo; + i_this->field_2D4[i] = fopAcM_Create(PROC_SHAND, NULL, param); + i_this->field_2E4[i]++; + + case 1: + shand_i = static_cast(fopAcM_SearchByID(i_this->field_2D4[i])); + if(shand_i != NULL){ + shand_i->field_308 = fopAcM_GetID(i_this); + shand_i->field_310 = &i_this->field_2E8[i]; + shand_i->field_314 = &i_this->field_318[i]; + i_this->field_2E4[i]++; + shand_count++; + } + break; + + case 2: + break; + } + } + + return (shand_count < 4); } /* 000019F8-00001CB8 .text daKita_Execute__FP10kita_class */ -static BOOL daKita_Execute(kita_class*) { - /* Nonmatching */ +static BOOL daKita_Execute(kita_class* i_this) { + static float xd[4] = {130, -130, 130, -130}; + static float zd[4] = {130, 130, -130, -130}; + + if(i_this->mExecuteCount != 0) i_this->mExecuteCount--; + kita_move(i_this); + + MtxTrans(i_this->current.pos.x, i_this->current.pos.y, i_this->current.pos.z, false); + mDoMtx_YrotM(*calc_mtx, i_this->shape_angle.y); + mDoMtx_YrotM(*calc_mtx, i_this->mRotY); + MtxTrans(0.0f, 0.0f, (REG0_F(11) + -150.0f) * JMASSin(i_this->mRotX), true); + mDoMtx_XrotM(*calc_mtx, i_this->mRotX); + mDoMtx_YrotM(*calc_mtx, -i_this->mRotY); + mDoMtx_XrotM(*calc_mtx, i_this->shape_angle.x); + mDoMtx_ZrotM(*calc_mtx, i_this->shape_angle.z); + i_this->mModel->setBaseTRMtx(*calc_mtx); + + cXyz local48[1]; + for(int i = 0; i < 4; i++){ + MtxPush(); + local48->x = i_this->scale.x * xd[i]; + local48->y = REG0_F(5) + -15.0f; + local48->z = i_this->scale.z * zd[i]; + MtxPosition(local48, &i_this->field_2E8[i]); + MtxPull(); + } + mDoMtx_copy(*calc_mtx, i_this->mBgwMtx); + i_this->pm_bgw->Move(); + if(i_this->field_360 == 2){ + if(i_this->mBaseEmitter == NULL){ + i_this->mBaseEmitter = dComIfGp_particle_set(dPa_name::ID_SCENE_828D, &i_this->current.pos); + } + else { + i_this->mBaseEmitter->setGlobalTranslation(i_this->current.pos.x, i_this->current.pos.y - (REG0_F(17) + 40.0f), i_this->current.pos.z); + } + } + else { + if(i_this->mBaseEmitter != NULL){ + i_this->mBaseEmitter->becomeInvalidEmitter(); + i_this->mBaseEmitter = NULL; + } + } + + return TRUE; } /* 00001CB8-00001CC0 .text daKita_IsDelete__FP10kita_class */ static BOOL daKita_IsDelete(kita_class*) { - /* Nonmatching */ + return TRUE; } /* 00001CC0-00001D3C .text daKita_Delete__FP10kita_class */ -static BOOL daKita_Delete(kita_class*) { - /* Nonmatching */ +static BOOL daKita_Delete(kita_class* i_this) { + dComIfG_resDelete(&i_this->mPhs, "Kita"); + if(i_this->heap != NULL){ + dComIfG_Bgsp()->Release(i_this->pm_bgw); + } + if(i_this->mBaseEmitter != NULL){ + i_this->mBaseEmitter->becomeInvalidEmitter(); + } + + return TRUE; } /* 00001D3C-00001EB0 .text CallbackCreateHeap__FP10fopAc_ac_c */ -static BOOL CallbackCreateHeap(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL CallbackCreateHeap(fopAc_ac_c* i_this) { + BOOL ret; + kita_class* actor = static_cast(i_this); + + J3DModelData* modelData = static_cast(dComIfG_getObjectRes("Kita", KITA_BDL_VHLIF_00)); + actor->mModel = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + + if(actor->mModel == NULL){ + ret = FALSE; + } + else { + JUT_ASSERT(0x3b2, modelData != NULL); + actor->pm_bgw = new dBgW(); + JUT_ASSERT(0x3b7, actor->pm_bgw != NULL); + actor->pm_bgw->Set(static_cast(dComIfG_getObjectRes("Kita", KITA_DZB_HLIF_00)), cBgW::MOVE_BG_e, &actor->mBgwMtx); + actor->pm_bgw->SetCrrFunc(dBgS_MoveBGProc_Typical); + actor->pm_bgw->SetRideCallback(ride_call_back); + ret = TRUE; + } + + return ret; } /* 00001EB0-00002224 .text daKita_Create__FP10fopAc_ac_c */ -static cPhs_State daKita_Create(fopAc_ac_c*) { - /* Nonmatching */ +static cPhs_State daKita_Create(fopAc_ac_c* a_this) { + /* Nonmatching - regalloc */ + static dCcD_SrcSph utiwa_sph_src = { + // dCcD_SrcGObjInf + { + /* Flags */ 0, + /* SrcObjAt Type */ 0, + /* SrcObjAt Atp */ 0, + /* SrcObjAt SPrm */ dCcG_AtSPrm_StopNoConHit_e | dCcG_AtSPrm_NoConHit_e, + /* SrcObjTg Type */ AT_TYPE_WIND, + /* SrcObjTg SPrm */ cCcD_TgSPrm_Set_e | cCcD_TgSPrm_IsEnemy_e, + /* SrcObjCo SPrm */ 0, + /* SrcGObjAt Se */ 0, + /* SrcGObjAt HitMark */ 0, + /* SrcGObjAt Spl */ 0, + /* SrcGObjAt Mtrl */ 0, + /* SrcGObjAt SPrm */ 0, + /* SrcGObjTg Se */ 0, + /* SrcGObjTg HitMark */ 0, + /* SrcGObjTg Spl */ 0, + /* SrcGObjTg Mtrl */ 0, + /* SrcGObjTg SPrm */ dCcG_TgSPrm_NoConHit_e, + /* SrcGObjCo SPrm */ 0, + }, + // cM3dGSphS + { + /* Center */ 0.0f, 0.0f, 0.0f, + /* Radius */ 400.0f, + }, + }; + + kita_class* i_this = static_cast(a_this); + fopAcM_SetupActor(a_this, kita_class); + cPhs_State ret; + + ret = dComIfG_resLoad(&i_this->mPhs, "Kita"); + if(ret != cPhs_COMPLEATE_e) + return ret; + + i_this->field_2A0 = fopAcM_GetParam(a_this); + i_this->field_2A1 = fopAcM_GetParam(a_this) >> 8; + + if(i_this->field_2A1 == 1){ + i_this->field_29A = 1; + i_this->field_360 = 1; + i_this->field_35C = a_this->current.pos.y + 70.0f + REG0_F(17); + } + else if(himo_create(i_this) != cPhs_INIT_e) + return cPhs_INIT_e; + + if(i_this->field_2A0 == 0xff) + i_this->field_2A0 = 0; + + if(fopAcM_entrySolidHeap(i_this, CallbackCreateHeap, 0x10000) == false) + return cPhs_ERROR_e; + + if(i_this->pm_bgw != NULL && dComIfG_Bgsp()->Regist(i_this->pm_bgw, i_this) != 0) + return cPhs_ERROR_e; + + + switch(i_this->field_2A0){ + case 1: + i_this->scale.x = 1.25f; + i_this->scale.z = 1.25f; + break; + + case 2: + i_this->scale.x = 1.5f; + i_this->scale.z = 1.5f; + break; + + default: + i_this->scale.z = 1.0f; + i_this->scale.x = 1.0f; + break; + } + i_this->scale.y = 1.0f; + fopAcM_SetMtx(i_this, i_this->mModel->getBaseTRMtx()); + fopAcM_SetMin( i_this, i_this->scale.x * -200.0f, -200.0f, i_this->scale.z * -200.0f); + fopAcM_SetMax(i_this, i_this->scale.x * 200.0f, 200.0f, i_this->scale.z * 200.0f); + i_this->mModel->setBaseScale(i_this->scale); + i_this->health = 1; + i_this->mAcch.Set(&i_this->current.pos, &i_this->old.pos, i_this, 1, &i_this->mAcchCir, &i_this->speed); + i_this->mAcchCir.SetWall(50.0f, 300.0f); + i_this->mStts.Init(0xff, 0xff, i_this); + i_this->mSph.Set(utiwa_sph_src); + i_this->mSph.SetStts(&i_this->mStts); + + // Regalloc for i + for(int i = 0; i < 2; i++) + daKita_Execute(i_this); + + return ret; } static actor_method_class l_daKita_Method = { From 661f53bc8a296d917c71b0ad494c62ae281ce75f Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Mon, 19 May 2025 14:49:44 -0400 Subject: [PATCH 04/10] d_a_hys 100% equivalent with weak func order (#758) * Start matching d_a_hys * Add d_a_hys 100% except for weak func ordering * Enable nosyminline * Address PR comments --- configure.py | 2 +- include/d/actor/d_a_hys.h | 20 +++- src/d/actor/d_a_hys.cpp | 188 +++++++++++++++++++++++++++++++++----- 3 files changed, 187 insertions(+), 23 deletions(-) diff --git a/configure.py b/configure.py index c5421c4c1..a9ed35239 100755 --- a/configure.py +++ b/configure.py @@ -1463,7 +1463,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_gy_ctrl"), ActorRel(NonMatching, "d_a_himo3"), ActorRel(NonMatching, "d_a_hmlif"), - ActorRel(NonMatching, "d_a_hys"), + ActorRel(Equivalent, "d_a_hys", extra_cflags=['-pragma "nosyminline on"']), # weak func order ActorRel(NonMatching, "d_a_kamome"), ActorRel(NonMatching, "d_a_kantera"), ActorRel(NonMatching, "d_a_kn"), diff --git a/include/d/actor/d_a_hys.h b/include/d/actor/d_a_hys.h index 31ca8d0f3..38f30e68f 100644 --- a/include/d/actor/d_a_hys.h +++ b/include/d/actor/d_a_hys.h @@ -2,6 +2,8 @@ #define D_A_HYS_H #include "d/d_bg_s_movebg_actor.h" +#include "d/d_cc_d.h" +#include "m_Do/m_Do_ext.h" class daHys_c : public dBgS_MoveBgActor { public: @@ -19,8 +21,24 @@ public: void mode_wait_init(); virtual BOOL Draw(); + static const char* m_arcname[]; + static const s16 m_bdlidx[]; + static const s16 m_btpidx[]; + static const s16 m_dzbidx[]; + static const u32 m_heapsize[]; + static const f32 m_tg_r[]; + public: - /* Place member variables here */ + /* 0x2C8 */ request_of_phase_process_class mPhs; + /* 0x2D0 */ J3DModel* mpModel; + /* 0x2D4 */ mDoExt_btpAnm mBtpAnm; + /* 0x2E8 */ dCcD_Stts mStts; + /* 0x324 */ dCcD_Sph mSph; + /* 0x450 */ u32 field_0x450; + /* 0x454 */ u32 mSwitchNo; + /* 0x458 */ u8 field_0x458; + /* 0x459 */ u8 mType; + /* 0x45A */ u8 field_0x45A[0x45C - 0x45A]; }; #endif /* D_A_HYS_H */ diff --git a/src/d/actor/d_a_hys.cpp b/src/d/actor/d_a_hys.cpp index 0f671467b..03a763fcc 100644 --- a/src/d/actor/d_a_hys.cpp +++ b/src/d/actor/d_a_hys.cpp @@ -4,86 +4,232 @@ // #include "d/actor/d_a_hys.h" +#include "d/res/res_hys.h" +#include "d/d_com_inf_game.h" +#include "m_Do/m_Do_mtx.h" #include "d/d_procname.h" +#include "weak_data_1811.h" // IWYU pragma: keep + +const char* daHys_c::m_arcname[2] = {"Hys", "Hys"}; + +/* Model file indexes. */ +const s16 daHys_c::m_bdlidx[2] = {HYS_BDL_HYS, HYS_BDL_HYS}; +/* Texture file indexes. */ +const s16 daHys_c::m_btpidx[2] = {HYS_BTP_HYS, HYS_BTP_HYS}; +const s16 daHys_c::m_dzbidx[2] = {HYS_DZB_HYS, HYS_DZB_HYS}; +const u32 daHys_c::m_heapsize[2] = {0xA00, 0xA00}; +const f32 daHys_c::m_tg_r[2] = {35.0f, 70.0f}; + +static dCcD_SrcSph l_sph_src = { + // dCcD_SrcGObjInf + { + /* Flags */ 0, + /* SrcObjAt Type */ 0, + /* SrcObjAt Atp */ 0, + /* SrcObjAt SPrm */ 0, + /* SrcObjTg Type */ AT_TYPE_NORMAL_ARROW | AT_TYPE_FIRE_ARROW | AT_TYPE_ICE_ARROW | AT_TYPE_LIGHT_ARROW, + /* SrcObjTg SPrm */ cCcD_TgSPrm_Set_e | cCcD_TgSPrm_IsOther_e, + /* SrcObjCo SPrm */ 0, + /* SrcGObjAt Se */ 0, + /* SrcGObjAt HitMark */ 0, + /* SrcGObjAt Spl */ 0, + /* SrcGObjAt Mtrl */ 0, + /* SrcGObjAt SPrm */ 0, + /* SrcGObjTg Se */ 0, + /* SrcGObjTg HitMark */ 0, + /* SrcGObjTg Spl */ 0, + /* SrcGObjTg Mtrl */ 0, + /* SrcGObjTg SPrm */ dCcG_TgSPrm_NoHitMark_e, + /* SrcGObjCo SPrm */ 0, + }, + // cM3dGSphS + { + /* Center */ 0.0f, 0.0f, 0.0f, + /* Radius */ 30.0f, + }, +}; + /* 00000078-000000B8 .text Delete__7daHys_cFv */ BOOL daHys_c::Delete() { - /* Nonmatching */ + dComIfG_resDelete(&mPhs, m_arcname[mType]); + return TRUE; } /* 000000B8-00000250 .text CreateHeap__7daHys_cFv */ BOOL daHys_c::CreateHeap() { - /* Nonmatching */ + J3DModelData* modelData = (J3DModelData *)dComIfG_getObjectRes(m_arcname[mType], m_bdlidx[mType]); + JUT_ASSERT(0x106, modelData != NULL); + + mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11020022); + if (mpModel == NULL) { + return FALSE; + } + + J3DAnmTexPattern* pbtp = (J3DAnmTexPattern *)dComIfG_getObjectRes(m_arcname[mType], m_btpidx[mType]); + JUT_ASSERT(0x114, pbtp != NULL); + + if (!mBtpAnm.init(modelData, pbtp, 0, 0, 1.0, 0, -1, FALSE, FALSE)) { + return FALSE; + } + field_0x458 = 0; + return TRUE; +} + +cPhs_State daHys_c::_create() { + // Inlined into daHys_Create + fopAcM_SetupActor(this, daHys_c); + + mType = fopAcM_GetParam(this) >> 8; + cPhs_State res = dComIfG_resLoad(&mPhs, m_arcname[mType]); + if (res == cPhs_COMPLEATE_e) { + res = MoveBGCreate(m_arcname[mType], m_dzbidx[mType], dBgS_MoveBGProc_TypicalRotY, m_heapsize[mType]); + if (res == cPhs_ERROR_e) { + return cPhs_ERROR_e; + } + } + + return res; } /* 00000250-00000368 .text Create__7daHys_cFv */ BOOL daHys_c::Create() { - /* Nonmatching */ + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + fopAcM_setCullSizeBox(this, -240.0f, -240.0f, -90.0f, 240.0f, 240.0f, 90.0f); + + mStts.Init(255, 255, this); + mSph.Set(l_sph_src); + mSph.SetStts(&mStts); + mSph.SetR(m_tg_r[mType]); + + set_mtx(); + mSwitchNo = fopAcM_GetParam(this) & 0xFF; + + if (fopAcM_isSwitch(this, mSwitchNo)) { + field_0x450 = 1; + field_0x458 = 3; + } else { + field_0x450 = 0; + field_0x458 = 0; + } + + if (mType == 1) { + scale.setall(2.0f); + } + + return TRUE; } /* 00000368-000003F8 .text set_mtx__7daHys_cFv */ void daHys_c::set_mtx() { - /* Nonmatching */ + mpModel->setBaseScale(scale); + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::YrotM(current.angle.y); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + mDoMtx_copy(mDoMtx_stack_c::get(), mBgMtx); } /* 000003F8-000004A4 .text Execute__7daHys_cFPPA3_A4_f */ -BOOL daHys_c::Execute(Mtx**) { - /* Nonmatching */ +BOOL daHys_c::Execute(Mtx** mtx) { + mode_proc_call(); + + mpModel->setBaseScale(scale); + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::YrotM(current.angle.y); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + cMtx_copy(mDoMtx_stack_c::get(), mBgMtx); + + *mtx = &mBgMtx; + return TRUE; } /* 000004A4-00000560 .text mode_proc_call__7daHys_cFv */ void daHys_c::mode_proc_call() { - /* Nonmatching */ + typedef void (daHys_c::*ModeFunc)(); + static const ModeFunc mode_proc[2] = { + &daHys_c::mode_wait, + &daHys_c::mode_sw_on, + }; + + (this->*mode_proc[field_0x450])(); + mSph.SetC(current.pos); + dComIfG_Ccsp()->Set(&mSph); } /* 00000560-00000600 .text mode_wait__7daHys_cFv */ void daHys_c::mode_wait() { - /* Nonmatching */ + if (mSph.ChkTgHit()) { + cCcD_Obj* obj = mSph.GetTgHitObj(); + if (obj != NULL && (obj->ChkAtType(AT_TYPE_NORMAL_ARROW) || + obj->ChkAtType(AT_TYPE_FIRE_ARROW) || + obj->ChkAtType(AT_TYPE_ICE_ARROW) || + obj->ChkAtType(AT_TYPE_LIGHT_ARROW))) { + mSph.ClrTgHit(); + mode_sw_on_init(); + return; + } + } + + if (field_0x458 != 0) { + field_0x458--; + } } /* 00000600-00000690 .text mode_sw_on_init__7daHys_cFv */ void daHys_c::mode_sw_on_init() { - /* Nonmatching */ + fopAcM_onSwitch(this, mSwitchNo); + field_0x450 = 1; + fopAcM_seStart(this, JA_SE_OBJ_ARROW_SW_ON, 0); } /* 00000690-000006F8 .text mode_sw_on__7daHys_cFv */ void daHys_c::mode_sw_on() { - /* Nonmatching */ + if (!fopAcM_isSwitch(this, mSwitchNo)) { + mode_wait_init(); + } else { + if (field_0x458 < 3) { + field_0x458++; + } + } } /* 000006F8-00000704 .text mode_wait_init__7daHys_cFv */ void daHys_c::mode_wait_init() { - /* Nonmatching */ + field_0x450 = 0; } /* 00000704-00000778 .text Draw__7daHys_cFv */ BOOL daHys_c::Draw() { - /* Nonmatching */ + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType(mpModel, &tevStr); + mBtpAnm.entry(mpModel->getModelData(), field_0x458); + mDoExt_modelUpdateDL(mpModel); + return TRUE; } /* 00000778-00000904 .text daHys_Create__FPv */ -static cPhs_State daHys_Create(void*) { - /* Nonmatching */ +static cPhs_State daHys_Create(void* i_this) { + return ((daHys_c*)i_this)->_create(); } /* 00000BBC-00000BDC .text daHys_Delete__FPv */ -static BOOL daHys_Delete(void*) { - /* Nonmatching */ +static BOOL daHys_Delete(void* i_this) { + return ((daHys_c*)i_this)->MoveBGDelete(); } /* 00000BDC-00000C08 .text daHys_Draw__FPv */ -static BOOL daHys_Draw(void*) { - /* Nonmatching */ +static BOOL daHys_Draw(void* i_this) { + return ((daHys_c*)i_this)->Draw(); } /* 00000C08-00000C28 .text daHys_Execute__FPv */ -static BOOL daHys_Execute(void*) { - /* Nonmatching */ +static BOOL daHys_Execute(void* i_this) { + return ((daHys_c*)i_this)->MoveBGExecute(); } /* 00000C28-00000C30 .text daHys_IsDelete__FPv */ static BOOL daHys_IsDelete(void*) { - /* Nonmatching */ + return TRUE; } static actor_method_class daHysMethodTable = { From e4878608689dd25ad18c2a24736ee6c7ef5de911 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 19 May 2025 15:09:58 -0400 Subject: [PATCH 05/10] Update dtk-template --- .github/workflows/build.yml | 16 +------- configure.py | 16 +++++--- tools/project.py | 48 +++++----------------- tools/upload_progress.py | 79 ------------------------------------- 4 files changed, 21 insertions(+), 138 deletions(-) delete mode 100755 tools/upload_progress.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4cab970de..2ebab4274 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,21 +40,7 @@ jobs: run: | python configure.py --map --version ${{ matrix.version }} \ --binutils /binutils --compilers /compilers - ninja diff - ninja all_source build/${{ matrix.version }}/progress.json \ - build/${{ matrix.version }}/report.json - - # Upload progress if we're on the main branch - - name: Upload progress - if: github.ref == 'refs/heads/main' - continue-on-error: true - env: - PROGRESS_SLUG: tww - PROGRESS_API_KEY: ${{ secrets.PROGRESS_API_KEY }} - run: | - python tools/upload_progress.py -b https://progress.decomp.club/ \ - -p $PROGRESS_SLUG -v ${{ matrix.version }} \ - build/${{ matrix.version }}/progress.json + ninja all_source progress build/${{ matrix.version }}/report.json # Upload map files - name: Upload map diff --git a/configure.py b/configure.py index a9ed35239..0d272e553 100755 --- a/configure.py +++ b/configure.py @@ -151,10 +151,10 @@ if args.no_asm: # Tool versions config.binutils_tag = "2.42-1" config.compilers_tag = "20240706" -config.dtk_tag = "v1.4.1" -config.objdiff_tag = "v3.0.0-beta.6" -config.sjiswrap_tag = "v1.2.0" -config.wibo_tag = "0.6.11" +config.dtk_tag = "v1.5.1" +config.objdiff_tag = "v3.0.0-beta.8" +config.sjiswrap_tag = "v1.2.1" +config.wibo_tag = "0.6.16" # Project config.config_path = Path("config") / config.version / "config.yml" @@ -1823,6 +1823,12 @@ config.progress_categories = [ ProgressCategory("third_party", "Third Party"), ] config.progress_each_module = args.verbose +# Optional extra arguments to `objdiff-cli report generate` +config.progress_report_args = [ + # Marks relocations as mismatching if the target value is different + # Default is "functionRelocDiffs=none", which is most lenient + # "--config functionRelocDiffs=data_value", +] # Disable missing return type warnings for incomplete objects for lib in config.libs: @@ -1834,7 +1840,7 @@ if args.mode == "configure": # Write build.ninja and objdiff.json generate_build(config) elif args.mode == "progress": - # Print progress and write progress.json + # Print progress information calculate_progress(config) else: sys.exit("Unknown mode: " + args.mode) diff --git a/tools/project.py b/tools/project.py index 6d65daa06..47e9f9d10 100644 --- a/tools/project.py +++ b/tools/project.py @@ -196,9 +196,8 @@ class ProjectConfig: None # Callback to add/remove/reorder units within a module ) - # Progress output, progress.json and report.json config + # Progress output and report.json config self.progress = True # Enable report.json generation and CLI progress output - self.progress_all: bool = True # Include combined "all" category self.progress_modules: bool = True # Include combined "modules" category self.progress_each_module: bool = ( False # Include individual modules, disable for large numbers of modules @@ -207,6 +206,9 @@ class ProjectConfig: self.print_progress_categories: Union[bool, List[str]] = ( True # Print additional progress categories in the CLI progress output ) + self.progress_report_args: Optional[List[str]] = ( + None # Flags to `objdiff-cli report generate` + ) # Progress fancy printing self.progress_use_fancy: bool = False @@ -423,6 +425,7 @@ def generate_build_ninja( if config.linker_version is None: sys.exit("ProjectConfig.linker_version missing") n.variable("mw_version", Path(config.linker_version)) + n.variable("objdiff_report_args", make_flags_str(config.progress_report_args)) n.newline() ### @@ -431,7 +434,6 @@ def generate_build_ninja( n.comment("Tooling") build_path = config.out_path() - progress_path = build_path / "progress.json" report_path = build_path / "report.json" build_tools_path = config.build_dir / "tools" download_tool = config.tools_dir / "download_tool.py" @@ -1188,7 +1190,7 @@ def generate_build_ninja( description="PROGRESS", ) n.build( - outputs=progress_path, + outputs="progress", rule="progress", implicit=[ ok_path, @@ -1205,7 +1207,7 @@ def generate_build_ninja( n.comment("Generate progress report") n.rule( name="report", - command=f"{objdiff} report generate -o $out", + command=f"{objdiff} report generate $objdiff_report_args -o $out", description="REPORT", ) n.build( @@ -1385,7 +1387,7 @@ def generate_build_ninja( if config.non_matching: n.default(link_outputs) elif config.progress: - n.default(progress_path) + n.default("progress") else: n.default(ok_path) else: @@ -1825,7 +1827,7 @@ def generate_compile_commands( json.dump(clangd_config, w, indent=2, default=default_format) -# Calculate, print and write progress to progress.json +# Print progress information from objdiff report def calculate_progress(config: ProjectConfig) -> None: config.validate() out_path = config.out_path() @@ -1917,35 +1919,3 @@ def calculate_progress(config: ProjectConfig) -> None: if summary_file: summary_file.write("```\n") summary_file.close() - - # Generate and write progress.json - progress_json: Dict[str, Any] = {} - - def add_category(id: str, measures: Dict[str, Any]) -> None: - progress_json[id] = { - "code": measures.get("complete_code", 0), - "code/total": measures.get("total_code", 0), - "data": measures.get("complete_data", 0), - "data/total": measures.get("total_data", 0), - "matched_code": measures.get("matched_code", 0), - "matched_code/total": measures.get("total_code", 0), - "matched_data": measures.get("matched_data", 0), - "matched_data/total": measures.get("total_data", 0), - "matched_functions": measures.get("matched_functions", 0), - "matched_functions/total": measures.get("total_functions", 0), - "fuzzy_match": int(measures.get("fuzzy_match_percent", 0) * 100), - "fuzzy_match/total": 10000, - "units": measures.get("complete_units", 0), - "units/total": measures.get("total_units", 0), - } - - if config.progress_all: - add_category("all", report_data["measures"]) - else: - # Support for old behavior where "dol" was the main category - add_category("dol", report_data["measures"]) - for category in report_data.get("categories", []): - add_category(category["id"], category["measures"]) - - with open(out_path / "progress.json", "w", encoding="utf-8") as w: - json.dump(progress_json, w, indent=2) diff --git a/tools/upload_progress.py b/tools/upload_progress.py deleted file mode 100755 index dc61d156e..000000000 --- a/tools/upload_progress.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 - -### -# Uploads progress information to https://github.com/decompals/frogress. -# -# Usage: -# python3 tools/upload_progress.py -b https://progress.decomp.club/ -p [project] -v [version] build/[version]/progress.json -# -# If changes are made, please submit a PR to -# https://github.com/encounter/dtk-template -### - -import argparse -import json -import os -import requests -import subprocess -import sys - - -def get_git_commit_timestamp() -> int: - return int( - subprocess.check_output(["git", "show", "-s", "--format=%ct"]) - .decode("ascii") - .rstrip() - ) - - -def get_git_commit_sha() -> str: - return subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip() - - -def generate_url(args: argparse.Namespace) -> str: - url_components = [args.base_url.rstrip("/"), "data"] - - for arg in [args.project, args.version]: - if arg != "": - url_components.append(arg) - - return str.join("/", url_components) + "/" - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Upload progress information.") - parser.add_argument("-b", "--base_url", help="API base URL", required=True) - parser.add_argument("-a", "--api_key", help="API key (env var PROGRESS_API_KEY)") - parser.add_argument("-p", "--project", help="Project slug", required=True) - parser.add_argument("-v", "--version", help="Version slug", required=True) - parser.add_argument("input", help="Progress JSON input") - - args = parser.parse_args() - api_key = args.api_key or os.environ.get("PROGRESS_API_KEY") - if not api_key: - raise KeyError("API key required") - url = generate_url(args) - - entries = [] - with open(args.input, "r") as f: - data = json.load(f) - entries.append( - { - "timestamp": get_git_commit_timestamp(), - "git_hash": get_git_commit_sha(), - "categories": data, - } - ) - - print("Publishing entry to", url) - json.dump(entries[0], sys.stdout, indent=4) - print() - r = requests.post( - url, - json={ - "api_key": api_key, - "entries": entries, - }, - ) - r.raise_for_status() - print("Done!") From bad1a7c7b222ff333071e4de17399c6f89d3b379 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 19 May 2025 15:27:34 -0400 Subject: [PATCH 06/10] Progress reports: Enable diffing functions by relocations and data value --- configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.py b/configure.py index 0d272e553..3a7aaf6bf 100755 --- a/configure.py +++ b/configure.py @@ -1827,7 +1827,7 @@ config.progress_each_module = args.verbose config.progress_report_args = [ # Marks relocations as mismatching if the target value is different # Default is "functionRelocDiffs=none", which is most lenient - # "--config functionRelocDiffs=data_value", + "--config functionRelocDiffs=data_value", ] # Disable missing return type warnings for incomplete objects From d906d5cf9650f8df094542194901521542453284 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 19 May 2025 15:29:25 -0400 Subject: [PATCH 07/10] Fix some relocation mismatches --- include/JSystem/JAudio/JAISequenceMgr.h | 2 +- src/d/d_kankyo_rain.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/JSystem/JAudio/JAISequenceMgr.h b/include/JSystem/JAudio/JAISequenceMgr.h index fe15deaf0..f15f7b9d6 100644 --- a/include/JSystem/JAudio/JAISequenceMgr.h +++ b/include/JSystem/JAudio/JAISequenceMgr.h @@ -94,7 +94,7 @@ namespace JAInter { /* 0x0660 */ MoveParaSet mTrackPitches[32]; /* 0x0860 */ MoveParaSetInitZero mTrackFxmixes[32]; /* 0x0A60 */ MoveParaSetInitZero mTrackDolbys[32]; - /* 0x0C60 */ MoveParaSet field_0xc60[32]; + /* 0x0C60 */ MoveParaSetInitZero field_0xc60[32]; /* 0x0E60 */ u8 field_0xe60[0x1261 - 0xe60]; /* 0x1261 */ u8 field_0x1261; /* 0x1262 */ u8 field_0x1262[0x1268 - 0x1262]; diff --git a/src/d/d_kankyo_rain.cpp b/src/d/d_kankyo_rain.cpp index 82a7e16f1..4598bef3c 100644 --- a/src/d/d_kankyo_rain.cpp +++ b/src/d/d_kankyo_rain.cpp @@ -2029,7 +2029,7 @@ void drawPoison(Mtx drawMtx, u8** pImg) { for (s32 i = 0; i < dKy_getEnvlight().mPoisonCount; i++) { f32 size = pPkt->mEff[i].mSize; - if (pPkt->mEff[i].mAlpha <= 0.0f) + if (pPkt->mEff[i].mAlpha <= 0.000001f) continue; GXLoadTexObj(&texObj, GX_TEXMAP0); @@ -2203,7 +2203,7 @@ void drawWave(Mtx drawMtx, u8** pImg) { f32 scaleBottom = dKy_getEnvlight().mWaveChan.mWaveScaleBottom * scale; f32 strength = pPkt->mEff[i].mStrengthEnv; f32 height = strength * scale; - f32 width = scaleBottom * (strength - 0.000015f * (i * 32) * height); + f32 width = scaleBottom * (strength - 0.00000015f * (i * 32) * height); if (height <= 0.0f) continue; From b6ba14fe0530b448909d606887fd8416ef36c49e Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 19 May 2025 15:42:16 -0400 Subject: [PATCH 08/10] Slightly improve d_a_hys weak func order --- src/d/actor/d_a_hys.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d/actor/d_a_hys.cpp b/src/d/actor/d_a_hys.cpp index 03a763fcc..bf7842afb 100644 --- a/src/d/actor/d_a_hys.cpp +++ b/src/d/actor/d_a_hys.cpp @@ -15,8 +15,9 @@ const char* daHys_c::m_arcname[2] = {"Hys", "Hys"}; /* Model file indexes. */ const s16 daHys_c::m_bdlidx[2] = {HYS_BDL_HYS, HYS_BDL_HYS}; -/* Texture file indexes. */ +/* Texture animation file indexes. */ const s16 daHys_c::m_btpidx[2] = {HYS_BTP_HYS, HYS_BTP_HYS}; +/* Collision mesh file indexes. */ const s16 daHys_c::m_dzbidx[2] = {HYS_DZB_HYS, HYS_DZB_HYS}; const u32 daHys_c::m_heapsize[2] = {0xA00, 0xA00}; const f32 daHys_c::m_tg_r[2] = {35.0f, 70.0f}; @@ -77,7 +78,6 @@ BOOL daHys_c::CreateHeap() { } cPhs_State daHys_c::_create() { - // Inlined into daHys_Create fopAcM_SetupActor(this, daHys_c); mType = fopAcM_GetParam(this) >> 8; @@ -219,7 +219,7 @@ static BOOL daHys_Delete(void* i_this) { /* 00000BDC-00000C08 .text daHys_Draw__FPv */ static BOOL daHys_Draw(void* i_this) { - return ((daHys_c*)i_this)->Draw(); + return ((daHys_c*)i_this)->MoveBGDraw(); } /* 00000C08-00000C28 .text daHys_Execute__FPv */ From 3d5131231fa41587892780131fb04b9074881a1d Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 19 May 2025 17:37:13 -0400 Subject: [PATCH 09/10] Add brackets to arrays of struct literals --- src/d/actor/d_a_npc_people.cpp | 604 ++++++++++++++++++++------------- src/d/actor/d_a_npc_roten.cpp | 104 +++--- 2 files changed, 425 insertions(+), 283 deletions(-) diff --git a/src/d/actor/d_a_npc_people.cpp b/src/d/actor/d_a_npc_people.cpp index 6b5b330d6..faf922f8b 100644 --- a/src/d/actor/d_a_npc_people.cpp +++ b/src/d/actor/d_a_npc_people.cpp @@ -538,149 +538,194 @@ static u8 l_npc_dist_tbl[][2] = { }; static sPeopleAnmDat l_npc_anm_wait[] = { - 0x00, - 0x08, - 0x00, + { + 0x00, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_talk[] = { - 0x01, - 0x08, - 0x00, + { + 0x01, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_walk[] = { - 0x02, - 0x08, - 0x00, + { + 0x02, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_surprise[] = { - 0x03, - 0x08, - 0x01, - - 0x04, - 0x00, - 0x00, + { + 0x03, + 0x08, + 0x01, + }, + { + 0x04, + 0x00, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_bikkuri[] = { - 0x03, - 0x08, - 0x01, - - 0xFF, - 0x00, - 0x00, + { + 0x03, + 0x08, + 0x01, + }, + { + 0xFF, + 0x00, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_furue[] = { - 0x04, - 0x00, - 0x00, + { + 0x04, + 0x00, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_miburui[] = { - 0x00, - 0x08, - 0x01, - - 0x04, - 0x08, - 0x00, + { + 0x00, + 0x08, + 0x01, + }, + { + 0x04, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_kyoro[] = { - 0x03, - 0x08, - 0x01, - - 0xFF, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x01, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_letter[] = { - 0x04, - 0x08, - 0x01, - - 0xFF, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x01, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_kyoro2[] = { - 0x03, - 0x08, - 0x01, - - 0x00, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x01, + }, + { + 0x00, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_ub_anm_wait2[] = { - 0x03, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_ub_anm_yada[] = { - 0x04, - 0x08, - 0x01, - - 0x00, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x01, + }, + { + 0x00, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_ub_anm_look[] = { - 0x00, - 0x08, - 0x01, - - 0x05, - 0x08, - 0x00, + { + 0x00, + 0x08, + 0x01, + }, + { + 0x05, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_ub_anm_kuyasi[] = { - 0x05, - 0x08, - 0x00, + { + 0x05, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_ub1_wait1[] = { - 0x00, - 0x08, - 0x04, - - 0xFF, - 0x08, - 0x00, + { + 0x00, + 0x08, + 0x04, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_ub1_wait2[] = { - 0x03, - 0x08, - 0x04, - - 0xFF, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x04, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_ub1_yada[] = { - 0x04, - 0x08, - 0x01, - - 0xFF, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x01, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat* l_npc_anm_ub1_tbl[] = { @@ -695,33 +740,42 @@ static sPeopleAnmDat* l_npc_anm_ub1_tbl[] = { }; static sPeopleAnmDat l_npc_anm_ub2_wait1[] = { - 0x03, - 0x08, - 0x04, - - 0xFF, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x04, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_ub2_wait2[] = { - 0x00, - 0x08, - 0x04, - - 0xFF, - 0x08, - 0x00, + { + 0x00, + 0x08, + 0x04, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_ub2_yada[] = { - 0x04, - 0x08, - 0x01, - - 0xFF, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x01, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat* l_npc_anm_ub2_tbl[] = { @@ -736,125 +790,163 @@ static sPeopleAnmDat* l_npc_anm_ub2_tbl[] = { }; static sPeopleAnmDat l_npc_anm_talk3[] = { - 0x03, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_talk4[] = { - 0x04, - 0x08, - 0x01, - - 0x00, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x01, + }, + { + 0x00, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_talkH[] = { - 0x03, - 0x08, - 0x01, - - 0x01, - 0x0C, - 0x00, + { + 0x03, + 0x08, + 0x01, + }, + { + 0x01, + 0x0C, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_talkH2[] = { - 0x03, - 0x08, - 0xFF, - - 0x00, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0xFF, + }, + { + 0x00, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_Mojimoji[] = { - 0x04, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_happy[] = { - 0x05, - 0x08, - 0x00, + { + 0x05, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_shobon_um[] = { - 0x03, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_happy_um[] = { - 0x04, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_happy2_um[] = { - 0x05, - 0x08, - 0x00, + { + 0x05, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_um3_wait3[] = { - 0x03, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_um3_talk2[] = { - 0x01, - 0x08, - 0x00, + { + 0x01, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_um3_talk3[] = { - 0x05, - 0x08, - 0x00, + { + 0x05, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_um3_wait2[] = { - 0x00, - 0x0F, - 0x01, - - 0x00, - 0x08, - 0x03, - - 0xFF, - 0x08, - 0x00, + { + 0x00, + 0x0F, + 0x01, + }, + { + 0x00, + 0x08, + 0x03, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_um3_wait[] = { - 0x03, - 0x0F, - 0x01, - - 0x03, - 0x08, - 0x03, - - 0xFF, - 0x08, - 0x00, + { + 0x03, + 0x0F, + 0x01, + }, + { + 0x03, + 0x08, + 0x03, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_um3_tameiki[] = { - 0x04, - 0x0F, - 0x01, - - 0xFF, - 0x08, - 0x00, + { + 0x04, + 0x0F, + 0x01, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat* l_npc_anm_um3_tbl[] = { @@ -869,47 +961,61 @@ static sPeopleAnmDat* l_npc_anm_um3_tbl[] = { }; static sPeopleAnmDat l_npc_anm_talk_sa[] = { - 0x01, - 0x10, - 0x00, + { + 0x01, + 0x10, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_talk2_sa[] = { - 0x03, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_talk3_sa[] = { - 0x04, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_kiai_sa[] = { - 0x05, - 0x08, - 0x00, + { + 0x05, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_sa3_wait3[] = { - 0x00, - 0x08, - 0x04, - - 0xFF, - 0x08, - 0x00, + { + 0x00, + 0x08, + 0x04, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_sa3_laugh[] = { - 0x03, - 0x08, - 0x03, - - 0xFF, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x03, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat* l_npc_anm_sa3_tbl[] = { @@ -920,13 +1026,16 @@ static sPeopleAnmDat* l_npc_anm_sa3_tbl[] = { }; static sPeopleAnmDat l_npc_anm_sa5_drink[] = { - 0x03, - 0x08, - 0x01, - - 0xFF, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x01, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat* l_npc_anm_sa5_tbl[] = { @@ -937,27 +1046,34 @@ static sPeopleAnmDat* l_npc_anm_sa5_tbl[] = { }; static sPeopleAnmDat l_npc_anm_talk2_ug[] = { - 0x03, - 0x08, - 0x00, + { + 0x03, + 0x08, + 0x00, + }, }; static sPeopleAnmDat l_npc_anm_sit_ug[] = { - 0x04, - 0x08, - 0x01, - - 0x05, - 0x08, - 0x02, - - 0x04, - 0x08, - 0xFF, - - 0xFF, - 0x08, - 0x00, + { + 0x04, + 0x08, + 0x01, + }, + { + 0x05, + 0x08, + 0x02, + }, + { + 0x04, + 0x08, + 0xFF, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; static sPeopleAnmDat* l_npc_anm_wait_tbl[][2] = { diff --git a/src/d/actor/d_a_npc_roten.cpp b/src/d/actor/d_a_npc_roten.cpp index dc9499f59..aa760b3c7 100644 --- a/src/d/actor/d_a_npc_roten.cpp +++ b/src/d/actor/d_a_npc_roten.cpp @@ -25,72 +25,98 @@ static const char* l_arcname_tbl[] = { }; static sRotenAnmDat l_npc_anm_wait[] = { - 0x00, - 0x0E, - 0xFF, + { + 0x00, + 0x0E, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_talk[] = { - 0x01, - 0x0E, - 0xFF, + { + 0x01, + 0x0E, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_walk[] = { - 0x02, - 0x0E, - 0xFF, + { + 0x02, + 0x0E, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_talk2[] = { - 0x03, - 0x0E, - 0xFF, + { + 0x03, + 0x0E, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_talk3[] = { - 0x04, - 0x0E, - 0xFF, + { + 0x04, + 0x0E, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_talk4[] = { - 0x05, - 0x06, - 0xFF, + { + 0x05, + 0x06, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_talk5[] = { - 0x06, - 0x0A, - 0xFF, + { + 0x06, + 0x0A, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_watasu[] = { - 0x07, - 0x0E, - 0x01, - 0x08, - 0x0E, - 0xFF, + { + 0x07, + 0x0E, + 0x01, + }, + { + 0x08, + 0x0E, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_itemwait[] = { - 0x08, - 0x0E, - 0xFF, + { + 0x08, + 0x0E, + 0xFF, + }, }; static sRotenAnmDat l_npc_anm_wind[] = { - 0x09, - 0x0E, - 0x01, - 0x00, - 0x14, - 0x01, - 0x0FF, - 0x08, - 0x00, + { + 0x09, + 0x0E, + 0x01, + }, + { + 0x00, + 0x14, + 0x01, + }, + { + 0xFF, + 0x08, + 0x00, + }, }; struct NpcDatStruct { From fd6cb6e4cad33f907adcd29eba71498a60dbc9cc Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 19 May 2025 18:41:23 -0400 Subject: [PATCH 10/10] Fix weak function order of dBgS_MoveBgActor::Draw fixes #217 fixes #239 fixes #389 fixes #418 fixes #428 fixes #147 --- configure.py | 16 ++++++++-------- include/d/actor/d_a_hys.h | 2 -- include/d/actor/d_a_obj_eskban.h | 4 ---- include/d/actor/d_a_obj_ladder.h | 4 +--- include/d/actor/d_a_obj_movebox.h | 5 ++--- include/d/actor/d_a_obj_mtest.h | 3 --- include/d/actor/d_a_obj_swhammer.h | 2 -- include/d/d_bg_s_movebg_actor.h | 7 +++++++ src/d/actor/d_a_hys.cpp | 3 +++ src/d/actor/d_a_obj_eskban.cpp | 7 +++++-- src/d/actor/d_a_obj_ladder.cpp | 3 +++ src/d/actor/d_a_obj_movebox.cpp | 14 ++++++++------ src/d/actor/d_a_obj_mtest.cpp | 3 +++ src/d/actor/d_a_obj_swhammer.cpp | 3 +++ src/d/actor/d_a_player_main.cpp | 1 + 15 files changed, 44 insertions(+), 33 deletions(-) diff --git a/configure.py b/configure.py index 3a7aaf6bf..e6dec30e3 100755 --- a/configure.py +++ b/configure.py @@ -1353,7 +1353,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_kanban"), ActorRel(NonMatching, "d_a_ki"), ActorRel(NonMatching, "d_a_knob00"), - ActorRel(Matching, "d_a_kui"), + ActorRel(Matching, "d_a_kui"), ActorRel(Matching, "d_a_kytag00"), ActorRel(Matching, "d_a_kytag01"), ActorRel(NonMatching, "d_a_kytag02"), @@ -1390,7 +1390,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_obj_leaves"), ActorRel(NonMatching, "d_a_obj_lpalm"), ActorRel(Matching, "d_a_obj_monument"), - ActorRel(Equivalent, "d_a_obj_movebox", extra_cflags=['-pragma "nosyminline on"']), # weak func order + ActorRel(Matching, "d_a_obj_movebox", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_mshokki"), ActorRel(NonMatching, "d_a_obj_ohatch"), ActorRel(NonMatching, "d_a_obj_otble"), @@ -1463,7 +1463,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_gy_ctrl"), ActorRel(NonMatching, "d_a_himo3"), ActorRel(NonMatching, "d_a_hmlif"), - ActorRel(Equivalent, "d_a_hys", extra_cflags=['-pragma "nosyminline on"']), # weak func order + ActorRel(Matching, "d_a_hys", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_kamome"), ActorRel(NonMatching, "d_a_kantera"), ActorRel(NonMatching, "d_a_kn"), @@ -1485,7 +1485,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_obj_majyuu_door"), ActorRel(NonMatching, "d_a_obj_stair"), ActorRel(NonMatching, "d_a_obj_swflat"), - ActorRel(Equivalent, "d_a_obj_swhammer"), # weak func order + ActorRel(Matching, "d_a_obj_swhammer", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_obj_swheavy"), ActorRel(NonMatching, "d_a_obj_swlight"), ActorRel(NonMatching, "d_a_oq"), @@ -1547,7 +1547,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_icelift"), ActorRel(NonMatching, "d_a_kb"), ActorRel(NonMatching, "d_a_kddoor"), - ActorRel(Matching, "d_a_kita", extra_cflags=['-pragma "sym off"']), + ActorRel(Matching, "d_a_kita", extra_cflags=['-pragma "sym off"']), ActorRel(NonMatching, "d_a_klft"), ActorRel(NonMatching, "d_a_kmon"), ActorRel(Matching, "d_a_komore", extra_cflags=['-pragma "nosyminline on"']), @@ -1637,7 +1637,7 @@ config.libs = [ ActorRel(Matching, "d_a_obj_eayogn"), ActorRel(Matching, "d_a_obj_ebomzo", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_ekskz"), - ActorRel(Equivalent, "d_a_obj_eskban", extra_cflags=['-pragma "nosyminline on"']), # weak func order + ActorRel(Matching, "d_a_obj_eskban", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_obj_ferris", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_figure", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_firewall"), @@ -1666,7 +1666,7 @@ config.libs = [ ActorRel(Matching, "d_a_obj_iceisland", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_jump"), ActorRel(NonMatching, "d_a_obj_kanoke"), - ActorRel(Equivalent, "d_a_obj_ladder", extra_cflags=['-pragma "nosyminline on"']), # weak func order + ActorRel(Matching, "d_a_obj_ladder", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_light"), ActorRel(NonMatching, "d_a_obj_mkie"), ActorRel(NonMatching, "d_a_obj_mkiek"), @@ -1676,7 +1676,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_obj_msdan2"), ActorRel(NonMatching, "d_a_obj_msdan_sub"), ActorRel(NonMatching, "d_a_obj_msdan_sub2"), - ActorRel(Equivalent, "d_a_obj_mtest", extra_cflags=['-pragma "nosyminline on"']), # weak func order + ActorRel(Matching, "d_a_obj_mtest", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_nest"), ActorRel(Matching, "d_a_obj_ojtree"), ActorRel(NonMatching, "d_a_obj_ospbox"), diff --git a/include/d/actor/d_a_hys.h b/include/d/actor/d_a_hys.h index 38f30e68f..5b2097c93 100644 --- a/include/d/actor/d_a_hys.h +++ b/include/d/actor/d_a_hys.h @@ -2,8 +2,6 @@ #define D_A_HYS_H #include "d/d_bg_s_movebg_actor.h" -#include "d/d_cc_d.h" -#include "m_Do/m_Do_ext.h" class daHys_c : public dBgS_MoveBgActor { public: diff --git a/include/d/actor/d_a_obj_eskban.h b/include/d/actor/d_a_obj_eskban.h index 8197c71e4..2edebc5ec 100644 --- a/include/d/actor/d_a_obj_eskban.h +++ b/include/d/actor/d_a_obj_eskban.h @@ -1,11 +1,7 @@ #ifndef D_A_OBJ_ESKBAN_H #define D_A_OBJ_ESKBAN_H -#include "f_op/f_op_actor.h" - -#include "d/d_a_obj.h" #include "d/d_bg_s_movebg_actor.h" -#include "d/d_particle.h" namespace daObjEskban { diff --git a/include/d/actor/d_a_obj_ladder.h b/include/d/actor/d_a_obj_ladder.h index 04568d661..b76b9eb64 100644 --- a/include/d/actor/d_a_obj_ladder.h +++ b/include/d/actor/d_a_obj_ladder.h @@ -1,10 +1,8 @@ #ifndef D_A_OBJ_LADDER_H #define D_A_OBJ_LADDER_H -#include "d/d_a_obj.h" -#include "d/d_bg_s_gnd_chk.h" #include "d/d_bg_s_movebg_actor.h" -#include "f_op/f_op_actor.h" +#include "d/d_bg_s_gnd_chk.h" namespace daObjLadder { enum Type_e { diff --git a/include/d/actor/d_a_obj_movebox.h b/include/d/actor/d_a_obj_movebox.h index cd6b5337b..ac8553558 100644 --- a/include/d/actor/d_a_obj_movebox.h +++ b/include/d/actor/d_a_obj_movebox.h @@ -1,14 +1,13 @@ #ifndef D_A_OBJ_MOVEBOX_H #define D_A_OBJ_MOVEBOX_H -#include "d/d_a_obj.h" #include "d/d_bg_s_movebg_actor.h" #include "d/d_bg_s_gnd_chk.h" #include "d/d_bg_s_wtr_chk.h" #include "d/d_bg_s_lin_chk.h" -#include "d/d_particle.h" #include "d/d_bg_w.h" -#include "d/d_path.h" + +struct dPath; namespace daObjMovebox { class Act_c; diff --git a/include/d/actor/d_a_obj_mtest.h b/include/d/actor/d_a_obj_mtest.h index ce0b9d365..222359f62 100644 --- a/include/d/actor/d_a_obj_mtest.h +++ b/include/d/actor/d_a_obj_mtest.h @@ -1,10 +1,7 @@ #ifndef D_A_OBJ_MTEST_H #define D_A_OBJ_MTEST_H -#include "f_op/f_op_actor.h" #include "d/d_bg_s_movebg_actor.h" -#include "d/d_cc_d.h" -#include "d/d_a_obj.h" namespace daObjMtest { class Act_c : public dBgS_MoveBgActor { diff --git a/include/d/actor/d_a_obj_swhammer.h b/include/d/actor/d_a_obj_swhammer.h index f89b81614..362e47399 100644 --- a/include/d/actor/d_a_obj_swhammer.h +++ b/include/d/actor/d_a_obj_swhammer.h @@ -1,9 +1,7 @@ #ifndef D_A_OBJ_SWHAMMER_H #define D_A_OBJ_SWHAMMER_H -#include "d/d_a_obj.h" #include "d/d_bg_s_movebg_actor.h" -#include "d/d_particle.h" class J3DNode; diff --git a/include/d/d_bg_s_movebg_actor.h b/include/d/d_bg_s_movebg_actor.h index 503b455b2..5278a24a3 100644 --- a/include/d/d_bg_s_movebg_actor.h +++ b/include/d/d_bg_s_movebg_actor.h @@ -3,6 +3,13 @@ #include "SSystem/SComponent/c_bg_s_poly_info.h" #include "f_op/f_op_actor.h" +// Fakematch to fix weak func order/.text section splitting of some TUs that include this header. +// Some affected TUs: d_a_hys, d_a_obj_swhammer, d_a_obj_eskban, d_a_obj_mtest, d_a_obj_movebox. +#pragma push +#pragma sym off +#include "d/d_a_obj.h" +#include "d/d_particle.h" +#pragma pop class dBgW; typedef void (*MoveBGActor_SetFunc)(dBgW*, void*, cBgS_PolyInfo&, bool, cXyz*, csXyz*, csXyz*); diff --git a/src/d/actor/d_a_hys.cpp b/src/d/actor/d_a_hys.cpp index bf7842afb..b92f6652e 100644 --- a/src/d/actor/d_a_hys.cpp +++ b/src/d/actor/d_a_hys.cpp @@ -222,6 +222,9 @@ static BOOL daHys_Draw(void* i_this) { return ((daHys_c*)i_this)->MoveBGDraw(); } +// Fakematch to fix weak func order/.text section splitting of dBgS_MoveBgActor::Draw(). +#pragma nosyminline off + /* 00000C08-00000C28 .text daHys_Execute__FPv */ static BOOL daHys_Execute(void* i_this) { return ((daHys_c*)i_this)->MoveBGExecute(); diff --git a/src/d/actor/d_a_obj_eskban.cpp b/src/d/actor/d_a_obj_eskban.cpp index e3e62b277..fd4d8f734 100644 --- a/src/d/actor/d_a_obj_eskban.cpp +++ b/src/d/actor/d_a_obj_eskban.cpp @@ -3,10 +3,10 @@ // Translation Unit: d_a_obj_eskban.cpp // -#include "d/d_procname.h" -#include "d/d_com_inf_game.h" #include "d/actor/d_a_obj_eskban.h" #include "d/res/res_eskban.h" +#include "d/d_procname.h" +#include "d/d_com_inf_game.h" #include "f_op/f_op_actor_mng.h" #include "weak_bss_936_to_1036.h" // IWYU pragma: keep @@ -408,6 +408,9 @@ BOOL Mthd_Draw(void* i_this) { return ((Act_c*)i_this)->MoveBGDraw(); } +// Fakematch to fix weak func order/.text section splitting of dBgS_MoveBgActor::Draw(). +#pragma nosyminline off + /* 00001540-0000156C .text Mthd_IsDelete__Q211daObjEskban28@unnamed@d_a_obj_eskban_cpp@FPv */ BOOL Mthd_IsDelete(void* i_this) { return ((Act_c*)i_this)->MoveBGIsDelete(); diff --git a/src/d/actor/d_a_obj_ladder.cpp b/src/d/actor/d_a_obj_ladder.cpp index af2e1eb90..fef65c853 100644 --- a/src/d/actor/d_a_obj_ladder.cpp +++ b/src/d/actor/d_a_obj_ladder.cpp @@ -323,6 +323,9 @@ static BOOL Mthd_Draw(void* i_this) { return static_cast(i_this)->MoveBGDraw(); } +// Fakematch to fix weak func order/.text section splitting of dBgS_MoveBgActor::Draw(). +#pragma nosyminline off + /* 000011CC-000011F8 .text Mthd_IsDelete__Q211daObjLadder28@unnamed@d_a_obj_ladder_cpp@FPv */ static BOOL Mthd_IsDelete(void* i_this) { return static_cast(i_this)->MoveBGIsDelete(); diff --git a/src/d/actor/d_a_obj_movebox.cpp b/src/d/actor/d_a_obj_movebox.cpp index 7fd1e8929..8ba9a4af0 100644 --- a/src/d/actor/d_a_obj_movebox.cpp +++ b/src/d/actor/d_a_obj_movebox.cpp @@ -3,12 +3,6 @@ * Object - Pushable Box */ -#include "global.h" -#include "d/d_procname.h" - -#include "weak_bss_936_to_1036.h" // IWYU pragma: keep -#include "weak_data_1811.h" // IWYU pragma: keep - #include "d/actor/d_a_obj_movebox.h" #include "d/res/res_ecube.h" #include "d/res/res_hbox2.h" @@ -17,6 +11,7 @@ #include "d/res/res_mmirror.h" #include "d/res/res_mpwrb.h" #include "d/res/res_osiblk.h" +#include "d/d_path.h" #include "d/d_cc_d.h" #include "d/d_procname.h" #include "JSystem/JUtility/JUTAssert.h" @@ -28,6 +23,9 @@ #include "d/actor/d_a_obj_mkie.h" #include "d/actor/d_a_player.h" +#include "weak_bss_936_to_1036.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep + namespace daObjMovebox { dBgS_ObjGndChk Bgc_c::M_gnd_work[23]; dBgS_WtrChk Bgc_c::M_wrt_work; @@ -1894,6 +1892,10 @@ namespace daObjMovebox { cPhs_State Mthd_Create(void* i_this) { return static_cast(i_this)->Mthd_Create(); } + +// Fakematch to fix weak func order/.text section splitting of daObjMovebox::EffSmokeCB's ctor and dtor. +// Also fixes weak func order/.text section splitting of dBgS_MoveBgActor::Draw(). +#pragma nosyminline off /* 000044E0-00004544 .text Mthd_Delete__Q212daObjMovebox29@unnamed@d_a_obj_movebox_cpp@FPv */ BOOL Mthd_Delete(void* i_this) { diff --git a/src/d/actor/d_a_obj_mtest.cpp b/src/d/actor/d_a_obj_mtest.cpp index a9a5356fc..1fc1ef758 100644 --- a/src/d/actor/d_a_obj_mtest.cpp +++ b/src/d/actor/d_a_obj_mtest.cpp @@ -366,6 +366,9 @@ namespace daObjMtest { return ((Act_c*)i_this)->MoveBGDraw(); } +// Fakematch to fix weak func order/.text section splitting of dBgS_MoveBgActor::Draw(). +#pragma nosyminline off + BOOL Mthd_IsDelete(void* i_this) { return ((Act_c*)i_this)->MoveBGIsDelete(); } diff --git a/src/d/actor/d_a_obj_swhammer.cpp b/src/d/actor/d_a_obj_swhammer.cpp index cf9e21866..dd9274188 100644 --- a/src/d/actor/d_a_obj_swhammer.cpp +++ b/src/d/actor/d_a_obj_swhammer.cpp @@ -461,6 +461,9 @@ BOOL Mthd_Draw(void* i_this) { return static_cast(i_this)->MoveBGDraw(); } +// Fakematch to fix weak func order/.text section splitting of dBgS_MoveBgActor::Draw(). +#pragma nosyminline off + /* 000015F4-00001620 .text Mthd_IsDelete__Q213daObjSwhammer30@unnamed@d_a_obj_swhammer_cpp@FPv */ BOOL Mthd_IsDelete(void* i_this) { return static_cast(i_this)->MoveBGIsDelete(); diff --git a/src/d/actor/d_a_player_main.cpp b/src/d/actor/d_a_player_main.cpp index 94d9e2e9a..4093ebe19 100644 --- a/src/d/actor/d_a_player_main.cpp +++ b/src/d/actor/d_a_player_main.cpp @@ -16,6 +16,7 @@ #include "d/d_com_inf_game.h" #include "d/d_com_lib_game.h" #include "d/d_kankyo_wether.h" +#include "d/d_path.h" #include "d/d_procname.h" #include "d/d_kankyo.h" #include "JSystem/JKernel/JKRSolidHeap.h"