From a42fd39a9f85b86d593158bf7ba0a6b78a48ddd0 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 7 Sep 2024 16:16:17 -0400 Subject: [PATCH] d_a_att OK, d_a_bgn header work fixes #89 --- configure.py | 2 +- include/d/actor/d_a_att.h | 10 +- include/d/actor/d_a_bgn.h | 69 ++++++++++-- include/m_Do/m_Do_ext.h | 12 +++ src/d/actor/d_a_andsw0.cpp | 6 +- src/d/actor/d_a_att.cpp | 216 ++++++++++++++++++++++++++++++++++--- src/d/actor/d_a_bgn.cpp | 4 +- 7 files changed, 295 insertions(+), 24 deletions(-) diff --git a/configure.py b/configure.py index 863984040..b19d1b52b 100644 --- a/configure.py +++ b/configure.py @@ -1294,7 +1294,7 @@ def JSystemLib(lib_name, objects): ActorRel(Matching, "d_a_agbsw0", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_andsw0"), ActorRel(Matching, "d_a_andsw2"), - ActorRel(NonMatching, "d_a_att"), + ActorRel(Matching, "d_a_att", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_bflower", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_bita", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_branch"), diff --git a/include/d/actor/d_a_att.h b/include/d/actor/d_a_att.h index e3d12cab3..05a168b8d 100644 --- a/include/d/actor/d_a_att.h +++ b/include/d/actor/d_a_att.h @@ -2,10 +2,18 @@ #define D_A_ATT_H #include "f_op/f_op_actor.h" +#include "d/d_cc_d.h" class att_class : public fopAc_ac_c { public: - /* Place member variables here */ + /* 0x290 */ request_of_phase_process_class mPhase; + /* 0x298 */ u8 m298[0x02B5 - 0x0298]; + /* 0x2B5 */ u8 m2B5; + /* 0x2B6 */ u8 m2B6[0x02B8 - 0x02B6]; + /* 0x2B8 */ dCcD_Stts mStts; + /* 0x2F4 */ dCcD_Cyl mCyl; + /* 0x424 */ dCcD_Sph mSph; + /* 0x550 */ s8 m550; }; #endif /* D_A_ATT_H */ diff --git a/include/d/actor/d_a_bgn.h b/include/d/actor/d_a_bgn.h index ee3739332..db61e731b 100644 --- a/include/d/actor/d_a_bgn.h +++ b/include/d/actor/d_a_bgn.h @@ -2,19 +2,76 @@ #define D_A_BGN_H #include "f_op/f_op_actor.h" +#include "m_Do/m_Do_ext.h" +#include "d/d_cc_d.h" +#include "d/d_particle.h" struct part_s { - -}; + /* 0x000 */ u8 m000[0x004 - 0x000]; + /* 0x004 */ mDoExt_J3DModelPacketS m004; + /* 0x014 */ u8 m014[0x018 - 0x014]; + /* 0x018 */ J3DLightObj m018; + /* 0x08C */ u8 m08C[0x0F8 - 0x08C]; + /* 0x0F8 */ dCcD_Sph m0F8; + /* 0x224 */ u8 m224[0x23C - 0x224]; +}; // Size: 0x23C struct move_s { - -}; + /* 0x000 */ cXyz m000[60]; + /* 0x2D0 */ u8 m2D0; + /* 0x2D1 */ u8 m2D1[0x2EC - 0x2D1]; + /* 0x2EC */ f32 m2EC; + /* 0x2F0 */ u8 m2F0[0x300 - 0x2F0]; + /* 0x300 */ s16 m300; + /* 0x302 */ u8 m302[0x304 - 0x302]; + /* 0x304 */ f32 m304; + /* 0x308 */ s8 m308; + /* 0x309 */ u8 m309[0x30C - 0x309]; +}; // Size: 0x30C class bgn_class : public fopAc_ac_c { public: - /* Place member variables here */ -}; + /* 0x0290 */ u8 m0290[0x02B5 - 0x0290]; + /* 0x02B5 */ s8 m02B5; + /* 0x02B6 */ u8 m02B6[0x02C0 - 0x02B6]; + /* 0x02C0 */ mDoExt_J3DModelPacketS m02C0; + /* 0x02D0 */ u8 m02D0[0x0314 - 0x02D0]; + /* 0x0314 */ part_s m0314[2]; + /* 0x078C */ part_s m078C[2]; + /* 0x0C04 */ part_s m0C04[21]; + /* 0x3AF0 */ part_s m3AF0[21]; + /* 0x69DC */ part_s m69DC[4]; + /* 0x72CC */ part_s m72CC[4]; + /* 0x7BBC */ part_s m7BBC[21]; + /* 0xAAA8 */ move_s mAAA8[8]; + /* 0xC308 */ u8 mC308[0xC33C - 0xC308]; + /* 0xC33C */ cXyz mC33C[8]; + /* 0xC39C */ mDoExt_3DlineMat1_c mC39C; + /* 0xC3D8 */ mDoExt_3DlineMat1_c mC3D8; + /* 0xC414 */ mDoExt_3DlineMat1_c mC414; + /* 0xC450 */ cXyz mC450[60]; + /* 0xC720 */ u8 mC720[0xC748 - 0xC720]; + /* 0xC748 */ s16 mC748; + /* 0xC74A */ u8 mC74A[0xC74C - 0xC74A]; + /* 0xC74C */ s16 mC74C; + /* 0xC74E */ u8 mC74E[0xC7B0 - 0xC74E]; + /* 0xC7B0 */ u16 mC7B0; + /* 0xC7B2 */ u8 mC7B2[0xC7C0 - 0xC7B2]; + /* 0xC7C0 */ dCcD_Stts mC7C0; + /* 0xC7FC */ dCcD_Sph mC7FC; + /* 0xC928 */ dCcD_Sph mC928; + /* 0xCA54 */ u8 mCA54[0xCAAC - 0xCA54]; + /* 0xCAAC */ J3DLightObj mCAAC; + /* 0xCB20 */ u8 mCB20[0xCB60 - 0xCB20]; + /* 0xCB60 */ mDoExt_J3DModelPacketS mCB60; + /* 0xCB70 */ u8 mCB70[0xCB74 - 0xCB70]; + /* 0xCB74 */ J3DLightObj mCB74; + /* 0xCBE8 */ u8 mCBE8[0xCC24 - 0xCBE8]; + /* 0xCC24 */ mDoExt_J3DModelPacketS mCC24; + /* 0xCC34 */ u8 mCC34[0xCC3C - 0xCC34]; + /* 0xCC3C */ dPa_smokeEcallBack mCC3C[2]; + /* 0xCC7C */ u8 mCC7C[0xCC94 - 0xCC7C]; +}; // Size: 0xCC94 class daBgn_HIO_c { public: diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h index d67d917e9..d8f848598 100644 --- a/include/m_Do/m_Do_ext.h +++ b/include/m_Do/m_Do_ext.h @@ -558,6 +558,18 @@ class mDoExt_onCupOffAupPacket : public J3DPacket { void entryOpa() { j3dSys.getDrawBuffer(0)->entryImm(this, 0); } }; +class mDoExt_J3DModelPacketS : public J3DPacket { +public: + mDoExt_J3DModelPacketS() {} + ~mDoExt_J3DModelPacketS() {} + + void setModel(J3DModel*) {} + void update() {} + + void draw(); + void setMaterial(); +}; + class mDoExt_3Dline_c { public: mDoExt_3Dline_c(); diff --git a/src/d/actor/d_a_andsw0.cpp b/src/d/actor/d_a_andsw0.cpp index ad6004181..bba802cd2 100644 --- a/src/d/actor/d_a_andsw0.cpp +++ b/src/d/actor/d_a_andsw0.cpp @@ -186,11 +186,11 @@ static void* bk_s_sub3(void* i_this, void*) { } /* 0000055C-000005D4 .text bb_s_sub__FPvPv */ -static void* bb_s_sub(void* i_this, void*) { - if(fopAcM_IsActor(i_this) && fopAcM_GetName(i_this) == PROC_BB) { +static void* bb_s_sub(void* search, void*) { + if(fopAcM_IsActor(search) && fopAcM_GetName(search) == PROC_BB) { s32 count = check_count; //regswaps without this if(count < 7) { - ac[check_count] = i_this; + ac[check_count] = search; check_count++; } diff --git a/src/d/actor/d_a_att.cpp b/src/d/actor/d_a_att.cpp index 87e85b73e..2734f6434 100644 --- a/src/d/actor/d_a_att.cpp +++ b/src/d/actor/d_a_att.cpp @@ -5,35 +5,227 @@ #include "d/actor/d_a_att.h" #include "d/d_procname.h" +#include "d/d_com_inf_game.h" +#include "f_op/f_op_actor_mng.h" +#include "d/actor/d_a_bgn.h" + +// Needed for the .data section to match. +static Vec dummy_2100 = {1.0f, 1.0f, 1.0f}; +static Vec dummy_2080 = {1.0f, 1.0f, 1.0f}; +static u8 dummy_1811[] = {0x02, 0x00, 0x02, 0x01}; +static f64 dummy4[2] = {3.0, 0.5}; + +static bgn_class* boss; +static cXyz non_pos(-30000.0f, -30000.0f, -30000.0f); /* 000000EC-000000F4 .text daAtt_Draw__FP9att_class */ -static BOOL daAtt_Draw(att_class*) { - /* Nonmatching */ +static BOOL daAtt_Draw(att_class* i_this) { + return TRUE; } /* 000000F4-00000140 .text boss_s_sub__FPvPv */ -void boss_s_sub(void*, void*) { - /* Nonmatching */ +static void* boss_s_sub(void* search, void*) { + if (fopAcM_IsActor(search) && fopAcM_GetName(search) == PROC_BGN) { + return search; + } + return NULL; } /* 00000140-0000052C .text daAtt_Execute__FP9att_class */ -static BOOL daAtt_Execute(att_class*) { - /* Nonmatching */ +static BOOL daAtt_Execute(att_class* i_this) { + if (i_this->m2B5 == 101) { + i_this->attention_info.position = i_this->eyePos = i_this->current.pos; + fopAcM_OffStatus(i_this, 0); + i_this->attention_info.flags = 0; + i_this->mSph.SetC(i_this->current.pos); + dComIfG_Ccsp()->Set(&i_this->mSph); + } + if (i_this->m2B5 == 100) { + i_this->attention_info.position = i_this->eyePos = i_this->current.pos; + } else { + boss = (bgn_class*)fpcM_Search(&boss_s_sub, i_this); + if (boss == NULL) { + return TRUE; + } + int r30 = i_this->m2B5; + + if (i_this->m550 != 0) { + i_this->m550--; + } + + if (i_this->m550 == 0 && (i_this->mCyl.ChkTgHit() || i_this->mSph.ChkTgHit())) { + i_this->m550 = 10; + boss->mAAA8[r30].m308--; + if (boss->mAAA8[r30].m308 <= 0) { + boss->mAAA8[r30].m2D0 = 1; + boss->mAAA8[r30].m304 = 6000.0f; + mDoAud_seStart(JA_SE_LK_W_WEP_HIT, NULL, 0x21, dComIfGp_getReverb(fopAcM_GetRoomNo(i_this))); + if (r30 <= 1) { + if (boss->mAAA8[1-r30].m2D0 != 0) { + boss->mC7B0 = 600; + } + } + } else { + boss->mAAA8[r30].m300 = 15; + mDoAud_seStart(JA_SE_CM_BGN_D_STRING_PLINK, NULL, 0, dComIfGp_getReverb(fopAcM_GetRoomNo(i_this))); + } + } + + i_this->current.pos = boss->mC33C[r30]; + cXyz sp08 = i_this->current.pos; + + if ( + boss->m02B5 == 0 + && + (boss->mC748 != 0 || boss->mC74C != 0 || r30 != 7) + && + (boss->mAAA8[r30].m2D0 == 0 && boss->mAAA8[r30].m2EC < 1.0f) + ) { + i_this->attention_info.flags = fopAc_Attn_LOCKON_BATTLE_e; + i_this->mCyl.SetR(200.0f); + i_this->mCyl.SetC(sp08); + sp08.y += 1000.0f; + i_this->mSph.SetC(sp08); + i_this->eyePos = sp08; + i_this->attention_info.position = sp08; + } else { + fopAcM_OffStatus(i_this, 0); + i_this->attention_info.flags = 0; + i_this->mCyl.SetC(non_pos); + i_this->mSph.SetC(non_pos); + } + + dComIfG_Ccsp()->Set(&i_this->mCyl); + dComIfG_Ccsp()->Set(&i_this->mSph); + } + return TRUE; } /* 00000568-00000570 .text daAtt_IsDelete__FP9att_class */ -static BOOL daAtt_IsDelete(att_class*) { - /* Nonmatching */ +static BOOL daAtt_IsDelete(att_class* i_this) { + return TRUE; } /* 00000570-00000578 .text daAtt_Delete__FP9att_class */ -static BOOL daAtt_Delete(att_class*) { - /* Nonmatching */ +static BOOL daAtt_Delete(att_class* i_this) { + return TRUE; } /* 00000578-00000768 .text daAtt_Create__FP10fopAc_ac_c */ -static s32 daAtt_Create(fopAc_ac_c*) { - /* Nonmatching */ +static s32 daAtt_Create(fopAc_ac_c* i_this) { + static dCcD_SrcSph sita_sph_src = { + // dCcD_SrcGObjInf + { + /* Flags */ 0, + /* SrcObjAt Type */ 0, + /* SrcObjAt Atp */ 0, + /* SrcObjAt SPrm */ AT_SPRM_SET | AT_SPRM_VS_PLAYER, + /* SrcObjTg Type */ AT_TYPE_HOOKSHOT, + /* SrcObjTg SPrm */ TG_SPRM_SET | TG_SPRM_IS_ENEMY, + /* 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 */ 0, + /* SrcGObjCo SPrm */ 0, + }, + // cM3dGSphS + { + /* Center */ 0.0f, 0.0f, 0.0f, + /* Radius */ 90.0f, + }, + }; + static dCcD_SrcCyl cc_cyl_src = { + // dCcD_SrcGObjInf + { + /* Flags */ 0, + /* SrcObjAt Type */ 0, + /* SrcObjAt Atp */ 0, + /* SrcObjAt SPrm */ 0, + /* SrcObjTg Type */ ~(AT_TYPE_WATER | AT_TYPE_UNK20000 | AT_TYPE_WIND | AT_TYPE_UNK400000 | AT_TYPE_LIGHT), + /* SrcObjTg SPrm */ TG_SPRM_SET | TG_SPRM_IS_ENEMY, + /* SrcObjCo SPrm */ CO_SPRM_SET | CO_SPRM_IS_UNK4 | CO_SPRM_VSGRP, + /* 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 */ 0, + /* SrcGObjCo SPrm */ 0, + }, + // cM3dGCylS + { + /* Center */ 0.0f, 0.0f, 0.0f, + /* Radius */ 200.0f, + /* Height */ 2000.0f, + }, + }; + static dCcD_SrcSph bm_sph_src = { + // dCcD_SrcGObjInf + { + /* Flags */ 0, + /* SrcObjAt Type */ 0, + /* SrcObjAt Atp */ 0, + /* SrcObjAt SPrm */ AT_SPRM_SET | AT_SPRM_VS_PLAYER, + /* SrcObjTg Type */ ~(AT_TYPE_WATER | AT_TYPE_UNK20000 | AT_TYPE_WIND | AT_TYPE_UNK400000 | AT_TYPE_LIGHT), + /* SrcObjTg SPrm */ TG_SPRM_SET | TG_SPRM_IS_ENEMY, + /* 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 */ 0, + /* SrcGObjCo SPrm */ 0, + }, + // cM3dGSphS + { + /* Center */ 0.0f, 0.0f, 0.0f, + /* Radius */ 200.0f, + }, + }; + + att_class* a_this = (att_class*)i_this; + fopAcM_SetupActor(i_this, att_class); + + a_this->m2B5 = fopAcM_GetParam(a_this) & 0xFF; + a_this->attention_info.distances[fopAc_Attn_TYPE_BATTLE_e] = 4; + + if (a_this->m2B5 == 101) { + fopAcM_OnStatus(a_this, fopAcStts_UNK10000000_e); + a_this->mStts.Init(0xFF, 0xFF, a_this); + + a_this->mSph.Set(sita_sph_src); + a_this->mSph.SetStts(&a_this->mStts); + } + + if (a_this->m2B5 < 10) { + boss = NULL; + + a_this->mStts.Init(0xFF, 0xFF, a_this); + + a_this->mCyl.Set(cc_cyl_src); + a_this->mCyl.SetStts(&a_this->mStts); + + a_this->mSph.Set(bm_sph_src); + a_this->mSph.SetStts(&a_this->mStts); + } + + return cPhs_COMPLEATE_e; } static actor_method_class l_daAtt_Method = { diff --git a/src/d/actor/d_a_bgn.cpp b/src/d/actor/d_a_bgn.cpp index 1f436566f..a5fe94bae 100644 --- a/src/d/actor/d_a_bgn.cpp +++ b/src/d/actor/d_a_bgn.cpp @@ -7,6 +7,7 @@ #include "d/actor/d_a_bgn2.h" #include "d/actor/d_a_bgn3.h" #include "d/d_procname.h" +#include "f_op/f_op_actor_mng.h" /* 000000EC-000003F0 .text __ct__11daBgn_HIO_cFv */ daBgn_HIO_c::daBgn_HIO_c() { @@ -269,8 +270,9 @@ static BOOL useHeapInit(fopAc_ac_c*) { } /* 0000B9DC-0000CA80 .text daBgn_Create__FP10fopAc_ac_c */ -static s32 daBgn_Create(fopAc_ac_c*) { +static s32 daBgn_Create(fopAc_ac_c* i_this) { /* Nonmatching */ + fopAcM_SetupActor(i_this, bgn_class); } static actor_method_class l_daBgn_Method = {