diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-03-01 04:48:49 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-01 14:48:49 +0200 |
| commit | 19e18654c9866a5aa5c181c0432157995596cbcb (patch) | |
| tree | 0ebbd4697e3189bad69383cfe536db7fab93c775 /src/d/actor/d_a_swBall.cpp | |
| parent | 9c3c07575a47d64fa70561d6a2cfd166aee94ccd (diff) | |
tag_allmato almost, swhit0 treesh swball done, misc cleanup (#2312)
* d_a_tag_allmato almost done
* d_a_swhit0 done
* some SSystem cleanup
* treesh done
* swball done, some other rel cleanup
Diffstat (limited to 'src/d/actor/d_a_swBall.cpp')
| -rw-r--r-- | src/d/actor/d_a_swBall.cpp | 410 |
1 files changed, 235 insertions, 175 deletions
diff --git a/src/d/actor/d_a_swBall.cpp b/src/d/actor/d_a_swBall.cpp index 12d864bb84..6a2218c229 100644 --- a/src/d/actor/d_a_swBall.cpp +++ b/src/d/actor/d_a_swBall.cpp @@ -4,233 +4,293 @@ */ #include "d/actor/d_a_swBall.h" -#include "dol2asm.h" - - -// -// Forward References: -// - -extern "C" static void s_ball_sub__FPvPv(); -extern "C" void checkArea_sub__10daSwBall_cFP10fopAc_ac_c(); -extern "C" void checkArea__10daSwBall_cFv(); -extern "C" void search_ball__10daSwBall_cFv(); -extern "C" void Create__10daSwBall_cFv(); -extern "C" void create__10daSwBall_cFv(); -extern "C" void execute__10daSwBall_cFv(); -extern "C" void actionRun__10daSwBall_cFv(); -extern "C" void actionStop__10daSwBall_cFv(); -extern "C" void PutCrrPos__10daSwBall_cFv(); -extern "C" bool _delete__10daSwBall_cFv(); -extern "C" static void daSwBall_Execute__FP10daSwBall_c(); -extern "C" static void daSwBall_Delete__FP10daSwBall_c(); -extern "C" static void daSwBall_Create__FP10fopAc_ac_c(); -extern "C" void func_80D4E974(void* _this, u8*); - -// -// External References: -// - -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void fopAc_IsActor__FPv(); -extern "C" void fopAcIt_Judge__FPFPvPv_PvPv(); -extern "C" void fopAcM_searchActorDistanceXZ__FPC10fopAc_ac_cPC10fopAc_ac_c(); -extern "C" void fpcEx_Search__FPFPvPv_PvPv(); -extern "C" void fpcSch_JudgeByID__FPvPv(); -extern "C" void dLib_checkActorInRectangle__FP10fopAc_ac_cP10fopAc_ac_cPC4cXyzPC4cXyz(); -extern "C" void onSwitch__10dSv_info_cFii(); -extern "C" void offSwitch__10dSv_info_cFii(); -extern "C" void cLib_chaseF__FPfff(); -extern "C" void cLib_targetAngleY__FPC3VecPC3Vec(); -extern "C" void __ptmf_scall(); -extern "C" void _savegpr_25(); -extern "C" void _savegpr_28(); -extern "C" void _restgpr_25(); -extern "C" void _restgpr_28(); -extern "C" extern u8 g_dComIfG_gameInfo[122384]; - -// -// Declarations: -// - -/* ############################################################################################## */ +#include "d/actor/d_a_obj_carry.h" +#include "d/d_com_inf_game.h" +#include "d/d_lib.h" +#include "d/d_s_play.h" + /* 80D4EA50-80D4EA70 000000 0020+00 2/2 0/0 0/0 .bss l_target_info */ -static u8 l_target_info[32]; +static fopAc_ac_c* l_target_info[8]; /* 80D4EA70-80D4EA74 000020 0004+00 2/2 0/0 0/0 .bss l_target_info_count */ -static u8 l_target_info_count[4]; +static int l_target_info_count; /* 80D4DFD8-80D4E054 000078 007C+00 1/1 0/0 0/0 .text s_ball_sub__FPvPv */ -static void s_ball_sub(void* param_0, void* param_1) { - // NONMATCHING +static void* s_ball_sub(void* i_actor, void* i_data) { + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_Obj_Carry && ((daObjCarry_c*)i_actor)->getType() == daObjCarry_c::TYPE_LV8_BALL) { + if (l_target_info_count < 8) { + l_target_info[l_target_info_count] = (fopAc_ac_c*)i_actor; + l_target_info_count++; + } else { + // "Mysterious Ball Reaction Area Switch: mysterious ball count has exceeded limit!\n" + OS_REPORT("\x1b[43;30m怪しい玉反応領域スイッチ:怪しい玉対応できる数を越えてます!\n\x1b[m"); + } + } + + return NULL; } -/* ############################################################################################## */ -/* 80D4E998-80D4E99C 000000 0004+00 2/2 0/0 0/0 .rodata @3718 */ -SECTION_RODATA static f32 const lit_3718 = 10.0f; -COMPILER_STRIP_GATE(0x80D4E998, &lit_3718); - -/* 80D4E99C-80D4E9A0 000004 0004+00 0/1 0/0 0/0 .rodata @3719 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3719 = 100.0f; -COMPILER_STRIP_GATE(0x80D4E99C, &lit_3719); -#pragma pop - -/* 80D4E9A0-80D4E9A4 000008 0004+00 0/1 0/0 0/0 .rodata @3720 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3720 = -100.0f; -COMPILER_STRIP_GATE(0x80D4E9A0, &lit_3720); -#pragma pop - -/* 80D4E9A4-80D4E9A8 00000C 0004+00 0/2 0/0 0/0 .rodata @3721 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_3721[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x80D4E9A4, &lit_3721); -#pragma pop - /* 80D4E054-80D4E194 0000F4 0140+00 2/2 0/0 0/0 .text checkArea_sub__10daSwBall_cFP10fopAc_ac_c */ -void daSwBall_c::checkArea_sub(fopAc_ac_c* param_0) { - // NONMATCHING +BOOL daSwBall_c::checkArea_sub(fopAc_ac_c* i_ball) { + if (getType() == 0) { + if (i_ball->current.pos.y >= current.pos.y - 10.0f && i_ball->current.pos.y < current.pos.y + (100.0f * scale.y) && fopAcM_searchActorDistanceXZ(this, i_ball) < (100.0f * scale.x)) { + return TRUE; + } + } else if (getType() == 1) { + cXyz bound_a(-100.0f * scale.x, 0.0f, -100.0f * scale.z); + cXyz bound_b(100.0f * scale.x, 100.0f * scale.y, 100.0f * scale.z); + bound_a.y += current.pos.y - 10.0f; + bound_b.y += current.pos.y; + + if (i_ball->current.pos.y >= bound_a.y && i_ball->current.pos.y < bound_b.y && dLib_checkActorInRectangle(i_ball, this, &bound_a, &bound_b)) { + return TRUE; + } + } + + return FALSE; } /* 80D4E194-80D4E248 000234 00B4+00 2/2 0/0 0/0 .text checkArea__10daSwBall_cFv */ -void daSwBall_c::checkArea() { - // NONMATCHING +BOOL daSwBall_c::checkArea() { + fopAc_ac_c* ball_actors[8]; + + for (int i = 0; i < 8; i++) { + if (mBallIDs[i] != fpcM_ERROR_PROCESS_ID_e) { + ball_actors[i] = fopAcM_SearchByID(mBallIDs[i]); + } else { + ball_actors[i] = NULL; + } + + if (ball_actors[i] != NULL && checkArea_sub(ball_actors[i])) { + return TRUE; + } + } + + return FALSE; } /* 80D4E248-80D4E374 0002E8 012C+00 1/1 0/0 0/0 .text search_ball__10daSwBall_cFv */ void daSwBall_c::search_ball() { - // NONMATCHING + l_target_info_count = 0; + + for (int i = 0; i < 8; i++) { + l_target_info[i] = NULL; + } + + fpcM_Search(s_ball_sub, this); + + for (int i = 0; i < l_target_info_count; i++) { + if (l_target_info[i] != NULL) { + fpc_ProcID target_id = fopAcM_GetID(l_target_info[i]); + if (target_id != fpcM_ERROR_PROCESS_ID_e) { + int ball_idx = -1; + for (int j = 0; j < 8; j++) { + if (target_id == mBallIDs[j]) { + ball_idx = j; + break; + } + } + + if (ball_idx < 0) { + for (int j = 0; j < 8; j++) { + if (mBallIDs[j] == fpcM_ERROR_PROCESS_ID_e) { + mBallIDs[j] = target_id; + break; + } + } + } + } + } + } } /* 80D4E374-80D4E42C 000414 00B8+00 1/1 0/0 0/0 .text Create__10daSwBall_cFv */ -void daSwBall_c::Create() { - // NONMATCHING +int daSwBall_c::Create() { + for (int i = 0; i < 8; i++) { + mBallIDs[i] = fpcM_ERROR_PROCESS_ID_e; + } + + field_0x59c = fpcM_ERROR_PROCESS_ID_e; + + execute(); + + if (checkArea()) { + if (getArg0() == 1) { + mMode = 3; + } else { + mMode = 2; + } + + fopAcM_onSwitch(this, getSwbit()); + } else { + mMode = 0; + } + + return 1; } /* 80D4E42C-80D4E494 0004CC 0068+00 1/1 0/0 0/0 .text create__10daSwBall_cFv */ -void daSwBall_c::create() { - // NONMATCHING -} +int daSwBall_c::create() { + fopAcM_SetupActor(this, daSwBall_c); -/* ############################################################################################## */ -/* 80D4E9AC-80D4E9B8 000000 000C+00 1/1 0/0 0/0 .data cNullVec__6Z2Calc */ -SECTION_DATA static u8 cNullVec__6Z2Calc[12] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; + if (!Create()) { + return cPhs_ERROR_e; + } -/* 80D4E9B8-80D4E9CC 00000C 0004+10 0/0 0/0 0/0 .data @1787 */ -#pragma push -#pragma force_active on -SECTION_DATA static u32 lit_1787[1 + 4 /* padding */] = { - 0x02000201, - /* padding */ - 0x40080000, - 0x00000000, - 0x3FE00000, - 0x00000000, -}; -#pragma pop - -/* 80D4E9CC-80D4E9D8 -00001 000C+00 0/1 0/0 0/0 .data @3847 */ -#pragma push -#pragma force_active on -SECTION_DATA static void* lit_3847[3] = { - (void*)NULL, - (void*)0xFFFFFFFF, - (void*)actionRun__10daSwBall_cFv, -}; -#pragma pop - -/* 80D4E9D8-80D4E9E4 -00001 000C+00 0/1 0/0 0/0 .data @3848 */ -#pragma push -#pragma force_active on -SECTION_DATA static void* lit_3848[3] = { - (void*)NULL, - (void*)0xFFFFFFFF, - (void*)actionStop__10daSwBall_cFv, -}; -#pragma pop - -/* 80D4E9E4-80D4E9FC 000038 0018+00 0/1 0/0 0/0 .data l_func$3846 */ -#pragma push -#pragma force_active on -SECTION_DATA static u8 l_func[24] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -#pragma pop + return cPhs_COMPLEATE_e; +} -/* 80D4EA74-80D4EA78 000024 0004+00 1/1 0/0 0/0 .bss None */ -static u8 data_80D4EA74[4]; +UNK_REL_DATA /* 80D4E494-80D4E524 000534 0090+00 2/2 0/0 0/0 .text execute__10daSwBall_cFv */ -void daSwBall_c::execute() { - // NONMATCHING +int daSwBall_c::execute() { + static void (daSwBall_c::*l_func[])() = { + &daSwBall_c::actionRun, + &daSwBall_c::actionStop, + }; + + (this->*l_func[mAction])(); + return 1; } /* 80D4E524-80D4E6C4 0005C4 01A0+00 1/0 0/0 0/0 .text actionRun__10daSwBall_cFv */ void daSwBall_c::actionRun() { - // NONMATCHING + search_ball(); + BOOL in_area = checkArea(); + + switch (mMode) { + case 0: + if (in_area) { + mTimer = getArg1(); + if (mTimer == 0xFF) { + mTimer = 15; + } + + if (getArg0() == 1) { + if (mTimer == 0) { + fopAcM_onSwitch(this, getSwbit()); + mMode = 3; + } + } else if (mTimer == 0) { + fopAcM_onSwitch(this, getSwbit()); + mMode = 2; + } + + mMode = 1; + } + + fopAcM_offSwitch(this, getSwbit()); + break; + case 1: + if (!in_area) { + mMode = 0; + } else if (cLib_calcTimer<u8>(&mTimer) == 0) { + mMode = 2; + } + break; + case 2: + fopAcM_onSwitch(this, getSwbit()); + + if (getArg0() == 1) { + mMode = 3; + } else if (!in_area) { + mMode = 0; + } + break; + case 3: + break; + } + + PutCrrPos(); } /* 80D4E6C4-80D4E6C8 000764 0004+00 1/0 0/0 0/0 .text actionStop__10daSwBall_cFv */ -void daSwBall_c::actionStop() { - /* empty function */ -} - -/* ############################################################################################## */ -/* 80D4E9A8-80D4E9AC 000010 0004+00 0/1 0/0 0/0 .rodata @3994 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3994 = 300.0f; -COMPILER_STRIP_GATE(0x80D4E9A8, &lit_3994); -#pragma pop +void daSwBall_c::actionStop() {} /* 80D4E6C8-80D4E90C 000768 0244+00 1/1 0/0 0/0 .text PutCrrPos__10daSwBall_cFv */ void daSwBall_c::PutCrrPos() { - // NONMATCHING + if (checkPullLBall()) { + daPy_py_c* player = daPy_getPlayerActorClass(); + s16 spA = cLib_targetAngleY(&player->current.pos, ¤t.pos) - player->shape_angle.y; + + if (fopAcM_searchPlayerDistanceXZ(this) < 300.0f + KREG_F(0) && spA < 0x4000) { + fopAc_ac_c* grab_actor = fopAcM_SearchByID(player->getGrabActorID()); + if (grab_actor != NULL && fopAcM_IsActor(grab_actor) && fopAcM_GetName(grab_actor) == PROC_Obj_Carry) { + daObjCarry_c* carry_obj = (daObjCarry_c*)grab_actor; + if (carry_obj->getType() == daObjCarry_c::TYPE_LV8_BALL) { + player->setForcePutPos(current.pos); + } + } + } + + daObjCarry_c* carry_obj; + for (int i = 0; i < 8; i++) { + if (mBallIDs[i] != fpcM_ERROR_PROCESS_ID_e) { + carry_obj = (daObjCarry_c*)fopAcM_SearchByID(mBallIDs[i]); + } else { + carry_obj = NULL; + } + + bool sp8 = false; + if (carry_obj != NULL) { + if (field_0x59c == mBallIDs[i] || field_0x59c == fpcM_ERROR_PROCESS_ID_e) { + switch (field_0x593[i]) { + case 0: + if (!fopAcM_checkCarryNow(carry_obj) && checkArea_sub(carry_obj)) { + if (current.pos.x != carry_obj->current.pos.x || current.pos.z != carry_obj->current.pos.z) { + carry_obj->startCtrl(); + field_0x593[i] = 1; + } + field_0x59c = mBallIDs[i]; + } else { + field_0x59c = fpcM_ERROR_PROCESS_ID_e; + } + break; + case 1: + cLib_chaseF(&carry_obj->current.pos.x, current.pos.x, 10.0f); + cLib_chaseF(&carry_obj->current.pos.z, current.pos.z, 10.0f); + + if (0.0f == fopAcM_searchActorDistanceXZ(this, carry_obj)) { + carry_obj->endCtrl(); + field_0x593[i] = 0; + } + + field_0x59c = mBallIDs[i]; + break; + } + } + + mIsBallCarry[i] = fopAcM_checkCarryNow(carry_obj) != 0; + } + } + } } /* 80D4E90C-80D4E914 0009AC 0008+00 1/1 0/0 0/0 .text _delete__10daSwBall_cFv */ -bool daSwBall_c::_delete() { - return true; +int daSwBall_c::_delete() { + return 1; } /* 80D4E914-80D4E934 0009B4 0020+00 1/0 0/0 0/0 .text daSwBall_Execute__FP10daSwBall_c */ -static void daSwBall_Execute(daSwBall_c* param_0) { - // NONMATCHING +static int daSwBall_Execute(daSwBall_c* i_this) { + return i_this->execute(); } /* 80D4E934-80D4E954 0009D4 0020+00 1/0 0/0 0/0 .text daSwBall_Delete__FP10daSwBall_c */ -static void daSwBall_Delete(daSwBall_c* param_0) { - // NONMATCHING +static int daSwBall_Delete(daSwBall_c* i_this) { + return i_this->_delete(); } /* 80D4E954-80D4E974 0009F4 0020+00 1/0 0/0 0/0 .text daSwBall_Create__FP10fopAc_ac_c */ -static void daSwBall_Create(fopAc_ac_c* param_0) { - // NONMATCHING -} - -/* 80D4E974-80D4E990 000A14 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<Uc>__FPUc */ -extern "C" void func_80D4E974(void* _this, u8* param_0) { - // NONMATCHING +static int daSwBall_Create(fopAc_ac_c* i_this) { + return ((daSwBall_c*)i_this)->create(); } -/* ############################################################################################## */ /* 80D4E9FC-80D4EA1C -00001 0020+00 1/0 0/0 0/0 .data l_daSwBall_Method */ static actor_method_class l_daSwBall_Method = { - (process_method_func)daSwBall_Create__FP10fopAc_ac_c, - (process_method_func)daSwBall_Delete__FP10daSwBall_c, - (process_method_func)daSwBall_Execute__FP10daSwBall_c, + (process_method_func)daSwBall_Create, + (process_method_func)daSwBall_Delete, + (process_method_func)daSwBall_Execute, }; /* 80D4EA1C-80D4EA4C -00001 0030+00 0/0 0/0 1/0 .data g_profile_SwBall */ |
