diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2022-02-06 06:23:54 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-06 09:23:54 -0500 |
| commit | 3a79e96e8b033e26a3970da68d0633010fac0f03 (patch) | |
| tree | 4f96139d922bc2af03685bca121fb327723447f2 /src/d/cc/d_cc_uty.cpp | |
| parent | 612f26c132280da43ecfa5fa8c8cc32966f06eb6 (diff) | |
d_meter2 wip / d_s_play / d_file_sel_info (#179)
* d_meter2 wip
* d_s_play
* d_file_sel_info
* format
* tag_lv5soup / tag_setBall / fix dKyeff
* d_cc_uty
Diffstat (limited to 'src/d/cc/d_cc_uty.cpp')
| -rw-r--r-- | src/d/cc/d_cc_uty.cpp | 504 |
1 files changed, 410 insertions, 94 deletions
diff --git a/src/d/cc/d_cc_uty.cpp b/src/d/cc/d_cc_uty.cpp index 401c6c13cb..6df62d5e65 100644 --- a/src/d/cc/d_cc_uty.cpp +++ b/src/d/cc/d_cc_uty.cpp @@ -4,33 +4,13 @@ // #include "d/cc/d_cc_uty.h" +#include "SSystem/SComponent/c_math.h" +#include "d/d_procname.h" +#include "d/s/d_s_play.h" #include "dol2asm.h" #include "dolphin/types.h" // -// Types: -// - -struct fopAc_ac_c {}; - -struct daPy_py_c { - /* 80088134 */ bool checkCutJumpCancelTurn() const; - /* 8015F398 */ void checkMasterSwordEquip(); -}; - -struct dCcU_AtInfo {}; - -struct dCcD_GObjInf { - /* 800845B0 */ void getHitSeID(u8, int); -}; - -struct cCcD_Obj { - /* 80263A48 */ void GetAc(); -}; - -struct Z2Creature {}; - -// // Forward References: // @@ -54,108 +34,319 @@ extern "C" void checkMasterSwordEquip__9daPy_py_cFv(); extern "C" void GetAc__8cCcD_ObjFv(); extern "C" void cM_atan2s__Fff(); extern "C" void cM_rndFX__Ff(); -extern "C" void PSVECSquareMag(); extern "C" void _savegpr_25(); extern "C" void _restgpr_25(); -extern "C" extern u8 g_dComIfG_gameInfo[122384]; -extern "C" extern u32 __float_nan; extern "C" extern u8 struct_80451124[4]; // // Declarations: // +bool daPy_py_c::checkWoodSwordEquip() { + return dComIfGs_getSelectEquipSword() == WOOD_STICK; +} + +BOOL daPy_py_c::checkNowWolf() { + return dComIfGp_getLinkPlayer()->i_checkWolf(); +} + /* ############################################################################################## */ /* 803AC418-803AC500 009538 00E8+00 1/1 0/0 0/0 .data plCutLRC */ -SECTION_DATA static u8 plCutLRC[232] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +SECTION_DATA static int plCutLRC[58] = { + 0, 0, 1, 1, 2, 0, 2, 1, 0, 0, 0, 2, 1, 1, 1, 2, 2, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, }; /* 800873B0-800873D4 081CF0 0024+00 0/0 0/0 3/3 .text pl_cut_LRC__Fi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void pl_cut_LRC(int param_0) { - nofralloc -#include "asm/d/cc/d_cc_uty/pl_cut_LRC__Fi.s" +int pl_cut_LRC(int index) { + if (index >= 58) { + return 0; + } + + return plCutLRC[index]; } -#pragma pop /* 800873D4-800874C4 081D14 00F0+00 1/1 0/0 14/14 .text cc_pl_cut_bit_get__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cc_pl_cut_bit_get() { - nofralloc -#include "asm/d/cc/d_cc_uty/cc_pl_cut_bit_get__Fv.s" +u16 cc_pl_cut_bit_get() { + daPy_py_c* link = (daPy_py_c*)dComIfGp_getPlayer(0); + + u16 bit = 0; + if (link->getCutType() == daPy_py_c::TYPE_CUT_VERTICAL) { + bit = 0x1; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_STAB) { + bit = 0x2; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_STAB_COMBO) { + bit = 0x200; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_SWEEP) { + bit = 0x4; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_HORIZONTAL) { + bit = 0x8; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_LEFT_SWEEP_FINISH) { + bit = 0x20; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_DOWN_FINISH) { + bit = 0x40; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_TURN_RIGHT || link->getCutType() == 9 || + link->getCutType() == 43 || + link->getCutType() == daPy_py_c::TYPE_CUT_LARGE_TURN_RIGHT) { + bit = 0x80; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_TURN_LEFT || + link->getCutType() == daPy_py_c::TYPE_CUT_LARGE_TURN_LEFT) { + bit = 0x800; + } else if (link->getCutType() == daPy_py_c::TYPE_CUT_JUMP) { + bit = 0x100; + } else if (link->getCutType() == 40 || link->getCutType() == 41) { + bit = 0x400; + } + + return bit; } -#pragma pop /* 800874C4-800874F0 081E04 002C+00 1/1 0/0 0/0 .text getMapInfo__FSc */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void getMapInfo(s8 param_0) { - nofralloc -#include "asm/d/cc/d_cc_uty/getMapInfo__FSc.s" +static int getMapInfo(s8 param_0) { + int map_info = 30; + if (param_0 == 1) { + map_info = 31; + } else if (param_0 == 2) { + map_info = 32; + } + + return map_info; } -#pragma pop /* 800874F0-80087514 081E30 0024+00 2/2 0/0 0/0 .text getHitId__FP8cCcD_Obji */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void getHitId(cCcD_Obj* param_0, int param_1) { - nofralloc -#include "asm/d/cc/d_cc_uty/getHitId__FP8cCcD_Obji.s" +static u32 getHitId(cCcD_Obj* obj, int param_1) { + dCcD_GObjInf* dObj = static_cast<dCcD_GObjInf*>(obj); + return dObj->getHitSeID(dObj->GetAtSe(), param_1); } -#pragma pop /* 80087514-80087594 081E54 0080+00 0/0 0/0 47/47 .text * def_se_set__FP10Z2CreatureP8cCcD_ObjUlP10fopAc_ac_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void def_se_set(Z2Creature* param_0, cCcD_Obj* param_1, u32 param_2, fopAc_ac_c* param_3) { - nofralloc -#include "asm/d/cc/d_cc_uty/def_se_set__FP10Z2CreatureP8cCcD_ObjUlP10fopAc_ac_c.s" +void def_se_set(Z2Creature* sound, cCcD_Obj* collider, u32 map_info, fopAc_ac_c* actor) { + if (sound != NULL) { + int tmp; + if (actor != NULL && fopAcM_checkStatus(actor, 0x280000)) { + tmp = 0; + } else { + tmp = 1; + } + sound->startCollisionSE(getHitId(collider, tmp), map_info); + } } -#pragma pop /* 80087594-80087A58 081ED4 04C4+00 1/1 0/0 0/0 .text at_power_get__FP11dCcU_AtInfo */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void at_power_get(dCcU_AtInfo* param_0) { - nofralloc -#include "asm/d/cc/d_cc_uty/at_power_get__FP11dCcU_AtInfo.s" +static u8 at_power_get(dCcU_AtInfo* info) { + u8 power = info->mpCollider->GetAtAtp(); + + if (info->mPowerType == 0) { + if (info->mpCollider->ChkAtType(0x10000000)) { + power = 0; + } else if (power == 1) { + power = 1; + } else if (power == 2) { + power = 10; + } else if (power == 3) { + power *= 10; + } else if (power == 6) { + power = 80; + } else if (power >= 4) { + power = 200; + } + } else if (info->mPowerType == 6) { + if (info->mpCollider->ChkAtType(0x10000000)) { + power = 0; + } else if (power == 1) { + power = 1; + } else if (power == 2) { + power = 10; + } else if (power == 6) { + power = 80; + } else if (power >= 3) { + power *= 10; + } + } else if (info->mPowerType == 4) { + if (info->mpCollider->ChkAtType(0x400000)) { + power = 200; + } else if (info->mpCollider->ChkAtType(0x10000000)) { + power = 0; + } else if (power == 1) { + power = 1; + } else if (power == 2) { + power = 10; + } else if (power >= 3) { + power *= 10; + } else if (power == 6) { + power = 80; + } else if (power >= 4) { + power = 200; + } + } else if (info->mPowerType == 5) { + if (info->mpCollider->ChkAtType(0x2000)) { + power = 0; + } else if (power == 1) { + power = 1; + } else if (power == 2) { + power = 3; + } else if (power >= 3) { + power = 4; + } + } else if (info->mPowerType == 2) { + if (info->mpCollider->ChkAtType(0x400000)) { + power = 200; + } else if (power == 1) { + power = 1; + } else if (power == 2) { + power = 10; + } else if (power == 3) { + power = 20; + } else if (power == 6) { + power = 80; + } else if (power >= 4) { + power = 200; + } + } else if (info->mPowerType == 1) { + if (info->mpCollider->ChkAtType(0x400000) || power >= 4) { + power = 200; + } else { + power *= 10; + } + } else if (info->mPowerType == 3) { + if (info->mpCollider->ChkAtType(0x400000) || power >= 4) { + power = 200; + } else if (power == 1) { + power = 10; + } else if (power == 2) { + power = 20; + } else if (power >= 3) { + power = 40; + } + } else if (info->mPowerType == 7) { + if (info->mpCollider->ChkAtType(0x420008)) { + power = 50; + } else if (info->mpCollider->ChkAtType(0x2000)) { + power = 27; + } else if (power == 1) { + power = 1; + } else if (power == 2) { + power = 10; + } else if (power == 3) { + power *= 10; + } else if (power == 6) { + power = 80; + } else if (power >= 4) { + power = 200; + } + } else if (info->mPowerType == 8) { + if (power == 1) { + power = 3; + } else if (power == 2) { + power = 10; + } else if (power == 6) { + power = 80; + } else if (power >= 3) { + power *= 10; + } + } else if (info->mPowerType == 9 || info->mPowerType == 10) { + if (info->mpCollider->ChkAtType(0x4000)) { + power = 0; + } + if (info->mpCollider->ChkAtType(0x400000)) { + power = 19; + } + + if (power == 1) { + power = 4; + } else if (power == 2) { + power = 8; + } else if (power == 3) { + power *= 10; + } else if (power == 6) { + power = 80; + } else if (power >= 4) { + power = 200; + } + } else if (info->mPowerType == 11) { + if (info->mpCollider->ChkAtType(0x4000)) { + power = 0; + } + + if (power == 1) { + power = 10; + } else if (power == 2) { + power = 20; + } else if (power == 3) { + power = 30; + } else if (power >= 4) { + power = 100; + } + } else if (info->mPowerType == 12) { + if (power == 1) { + power = 10; + } else if (power == 2) { + power = 20; + } else if (power == 3) { + power = 30; + } else if (power >= 4) { + power = 100; + } + } + + return power; } -#pragma pop /* 80087A58-80087C04 082398 01AC+00 1/1 0/0 38/38 .text at_power_check__FP11dCcU_AtInfo */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void at_power_check(dCcU_AtInfo* param_0) { - nofralloc -#include "asm/d/cc/d_cc_uty/at_power_check__FP11dCcU_AtInfo.s" +fopAc_ac_c* at_power_check(dCcU_AtInfo* info) { + if (info->mpCollider == NULL) { + return NULL; + } + + info->mpActor = info->mpCollider->GetAc(); + info->mHitType = 12; + info->mAttackPower = 0; + info->mHitBit = 0; + + if (info->mpActor != NULL) { + info->mAttackPower = at_power_get(info); + + s16 ac_name = fopAcM_GetName(info->mpActor); + if (ac_name == PROC_ALINK || ac_name == PROC_ALINK) { + if (info->mpCollider->ChkAtType(0x8000) || info->mpCollider->ChkAtType(0x400000)) { + info->mHitType = 9; + } else { + info->mHitType = 1; + info->mHitBit = cc_pl_cut_bit_get(); + } + } else if (ac_name == PROC_NBOMB) { + info->mHitType = 2; + info->mHitBit = 0x10000000; + } else if (ac_name == PROC_BOOMERANG) { + info->mHitType = 10; + info->mHitBit = 0x40000000; + } else if (ac_name == PROC_ARROW) { + info->mHitType = 15; + info->mHitBit = 0x80000000; + } + } + + info->mHitStatus = 0; + if (info->mpCollider->ChkAtType(0x40) || info->mpCollider->ChkAtType(0x10000) || + info->mpCollider->ChkAtType(0x80) || info->mpCollider->ChkAtType(0x10)) { + info->mHitType = 0x10; + } else if (info->mpCollider->ChkAtType(0x4000)) { + info->mHitBit = 0x1000; + } else { + s16 ac_name = fopAcM_GetName(info->mpActor); + if (ac_name == PROC_ALINK || ac_name == PROC_ALINK) { + if (dCcD_GetGObjInf(info->mpCollider)->GetAtSpl() == 1) { + info->mHitStatus = 1; + } + } else if (info->mAttackPower >= 3) { + info->mHitStatus = 1; + } + } + + return info->mpActor; } -#pragma pop /* ############################################################################################## */ /* 80452798-804527A0 000D98 0004+04 1/1 0/0 0/0 .sdata2 @4212 */ @@ -191,16 +382,141 @@ SECTION_SDATA2 static f32 lit_4218[1 + 1 /* padding */] = { /* 80087C04-80088134 082544 0530+00 0/0 0/0 84/84 .text cc_at_check__FP10fopAc_ac_cP11dCcU_AtInfo */ +// reg issues +#ifdef NONMATCHING +fopAc_ac_c* cc_at_check(fopAc_ac_c* enemy, dCcU_AtInfo* info) { + daPy_py_c* link = (daPy_py_c*)dComIfGp_getPlayer(0); + info->mpActor = at_power_check(info); + + if (info->mpActor != NULL) { + cXyz tmp = info->mpActor->mSpeed; + tmp.y = 0.0f; + if (tmp.abs() > 100.0f) { + f32 x = info->mpActor->mSpeed.x; + f32 z = info->mpActor->mSpeed.z; + info->mHitDirection = cM_atan2s(-x, -z) + (s16)cM_rndFX(4000.0f); + } else { + if (fopAcM_GetName(info->mpActor) == PROC_BOOMERANG) { + f32 x_diff = enemy->mCurrent.mPosition.x - link->mCurrent.mPosition.x; + f32 z_diff = enemy->mCurrent.mPosition.z - link->mCurrent.mPosition.z; + info->mHitDirection = cM_atan2s(-x_diff, -z_diff) + (s16)cM_rndFX(10000.0f); + } else { + f32 x_diff = enemy->mCurrent.mPosition.x - info->mpActor->mCurrent.mPosition.x; + f32 z_diff = enemy->mCurrent.mPosition.z - info->mpActor->mCurrent.mPosition.z; + info->mHitDirection = cM_atan2s(-x_diff, -z_diff); + } + } + + if (info->mHitType == 1 && link->getCutType() == daPy_py_c::TYPE_CUT_HEAD) { + info->mHitDirection = link->mCollisionRot.y; + } + + if (info->mpCollider->ChkAtType(0x4000) && fopAcM_checkStatus(enemy, 0x380000)) { + info->mAttackPower = 0; + } + + if (static_cast<dCcD_GObjInf*>(info->mpCollider)->GetAtMtrl() == 4) { + if (fopAcM_GetName(enemy) == PROC_B_GND) { + info->mAttackPower = 0; + } else if (fopAcM_GetName(enemy) != PROC_B_ZANT) { + info->mAttackPower = 100; + } + } + + if (info->mHitType == 1) { + if (!daPy_py_c::checkNowWolf()) { + if (link->checkMasterSwordEquip()) { + info->mAttackPower *= 2; + } + + if (daPy_py_c::checkWoodSwordEquip()) { + // probably supposed to be some sort of division + info->mAttackPower = info->mAttackPower >> 1; + } + } + + if (link->getSwordAtUpTime()) { + info->mAttackPower *= 2; + info->mHitStatus = 1; + } + } + + if (info->mAttackPower != 0) { + enemy->field_0x562 -= info->mAttackPower; + } + + s8 pause_time = 0; + if (info->mAttackPower != 0 && enemy->field_0x562 <= 0) { + info->mHitStatus = 2; + enemy->field_0x562 = 0; + } + + int uvar8; + if (info->mpCollider->ChkAtType(0x4000) && !fopAcM_checkStatus(enemy, 0x280000)) { + uvar8 = 1; + } else { + uvar8 = 0; + } + + if (info->mpSound != NULL) { + if (info->field_0x18 != 0) { + info->mpSound->startCollisionSE(getHitId(info->mpCollider, uvar8), info->field_0x18); + } else { + info->mpSound->startCollisionSE(getHitId(info->mpCollider, uvar8), + getMapInfo(info->mHitStatus)); + } + } + + if (info->mHitStatus != 0) { + pause_time = 5; + } else { + if (info->mAttackPower > 1) { + pause_time = 2; + } + } + + if (info->mpCollider->ChkAtType(0x8000000) || + ((daPy_py_c*)dComIfGp_getPlayer(0))->checkHorseRide()) { + // actor is Bulblin or Horseback Ganon + // add bulblin class later + if ((fopAcM_GetName(enemy) == PROC_E_RD && *(char*)((char*)&enemy + 0x1292) != 0) || + fopAcM_GetName(enemy) == PROC_B_GND) { + pause_time = 3; + } else { + pause_time = 0; + } + } + + s16 ac_name = fopAcM_GetName(enemy); + // actor is Stalkin, Chu, Keese, Shadow Keese, Shadow Vermin, Baby Gohma, or Rat + if (ac_name == PROC_E_BS || ac_name == PROC_E_SM2 || ac_name == PROC_E_BA || + ac_name == PROC_E_YK || ac_name == PROC_E_YG || ac_name == PROC_E_GM || + ac_name == PROC_E_MS) { + pause_time = 0; + } + + if (info->mHitType == 1 || info->mpCollider->ChkAtType(0x8)) { + if (!link->checkCutJumpCancelTurn() && info->mpCollider->ChkAtType(0x8)) { + pause_time = 4; + } + dScnPly_c::setPauseTimer(pause_time); + } + } + + return info->mpActor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void cc_at_check(fopAc_ac_c* param_0, dCcU_AtInfo* param_1) { +asm fopAc_ac_c* cc_at_check(fopAc_ac_c* param_0, dCcU_AtInfo* param_1) { nofralloc #include "asm/d/cc/d_cc_uty/cc_at_check__FP10fopAc_ac_cP11dCcU_AtInfo.s" } #pragma pop +#endif /* 80088134-8008813C 082A74 0008+00 0/0 1/0 0/0 .text checkCutJumpCancelTurn__9daPy_py_cCFv */ -bool daPy_py_c::checkCutJumpCancelTurn() const { - return false; +int daPy_py_c::checkCutJumpCancelTurn() const { + return 0; } |
