diff options
| author | Max Roncace <me@caseif.net> | 2026-03-11 06:07:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-11 03:07:19 -0700 |
| commit | 8a333fc7c9e6d1228135a1296e7960f709a432ce (patch) | |
| tree | d64d2893964f0b1867403b6a3c595690822b2f5b /src/d | |
| parent | 0b0fdd1f60193d1e3e610326cc2cf2a7b558d366 (diff) | |
More debug fixes for 99% TUs (#3122)
* d_a_e_hp debug code 100%
* d_a_npc_chin debug improvements
* d_a_npc_du debug code 100%
* d_a_npc_cdn3 debug code 100%
* d_a_e_rdy GCN symbol fixes
* d_a_kago debug code 100%
* d_a_e_oc debug code 100%
* d_a_e_yr debug code almost matching
* d_a_e_bg debug code 100%
* d_a_ykgr debug code 100%
* d_a_tag_hjump debug data fixes
* d_a_tag_attack_item debug data fixes
* d_a_e_df debug code 100%
* d_a_e_sh debug code 100%
* d_a_L7op_demo_dr debug code 100%
* d_a_L7low_dr debug code 100%
* d_a_e_sm2 debug code 100%
* d_a_movie_player debug code 100%
* d_a_e_st debug code 100%
* d_a_npc_aru debug code 100%
* d_a_e_yg debug code 100%
* d_a_door_spiral debug code 100%
* d_a_bg debug code 100% (still has .data issues)
* d_a_e_dn debug code 100%
* d_a_tag_attention debug code 100%
* d_a_e_bd debug code 100%
* d_a_tag_camera debug .rodata fix
* d_a_obj_movebox debug code 100% (array dtors are mismapped)
* d_a_mg_rod debug improvements
* d_a_e_rd debug symbol fixes
Diffstat (limited to 'src/d')
28 files changed, 1300 insertions, 1056 deletions
diff --git a/src/d/actor/d_a_L7op_demo_dr.cpp b/src/d/actor/d_a_L7op_demo_dr.cpp index 3053a01d56..c05ebabb2c 100644 --- a/src/d/actor/d_a_L7op_demo_dr.cpp +++ b/src/d/actor/d_a_L7op_demo_dr.cpp @@ -247,9 +247,10 @@ void daL7ODR_c::setZoomOutCamPos(cXyz& param_0, cXyz& param_1, f32 param_2) { void daL7ODR_c::dr_wait() { if (field_0x88c == 0) { cXyz sp8(0.0f, 0.0f, 0.0f); + s16 angle = 0x400; field_0x8b4 = 1; - current.pos.set(5000.0f * cM_ssin(0x400), 7000.0f, 5000.0f * cM_scos(0x400)); + current.pos.set(5000.0f * cM_ssin(angle), 7000.0f, 5000.0f * cM_scos(angle)); current.angle.y = cLib_targetAngleY(¤t.pos, &sp8) + 0x4000; mpModelMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("B_dr", 0x2F), 2, 3.0f, 1.0f, 0.0f, -1.0f); @@ -260,6 +261,8 @@ void daL7ODR_c::dr_wait() { speedF = 0.0f; gravity = 0.0f; field_0x88c++; + } else if (field_0x88c == -1) { + // empty block } } @@ -272,7 +275,7 @@ void daL7ODR_c::dr_fly() { if (field_0x88c == 0) { field_0x8b4 = 0; mpModelMorf->setPlaySpeed(1.0f); - + field_0x898 = 600.0f; mDemoCamCenter = player->current.pos; mDemoCamCenter.y += 160.0f; @@ -340,10 +343,12 @@ void daL7ODR_c::dr_fly() { mSound.startCreatureSound(Z2SE_EN_DR_WING, 0, -1); } - if (field_0x898 == temp_f30) { - field_0x89c = 140.0f; - field_0x88c++; + if (field_0x898 != temp_f30) { + return; } + + field_0x89c = 140.0f; + field_0x88c++; } else if (field_0x88c == 3) { cXyz sp258; cLib_chaseAngleS(¤t.angle.x, 0x800, 0x10); @@ -626,7 +631,7 @@ void daL7ODR_c::dr_fly() { cLib_chaseF(&speedF, 0.0f, field_0x89c); speed.y = -speedF * cM_ssin(current.angle.x); mAcch.CrrPos(dComIfG_Bgsp()); - + s16 sp8 = current.angle.y; current.angle.y = -0x8000; fopAcM_posMoveF(this, NULL); @@ -735,7 +740,7 @@ static int daL7ODR_IsDelete(daL7ODR_c* i_this) { } int daL7ODR_c::_delete() { - fopAcM_GetID(this); + fopAcM_RegisterDeleteID(this, "L7ODR"); dComIfG_resDelete(&mPhase, "B_dr"); if (heap != NULL) { @@ -804,14 +809,13 @@ int daL7ODR_c::create() { mSound.init(¤t.pos, &eyePos, 3, 1); - health = 1; - field_0x560 = 1; - + field_0x560 = health = 1; + scale.setall(1.0f); attention_info.distances[fopAc_attn_BATTLE_e] = 0; attention_info.flags &= ~fopAc_AttnFlag_BATTLE_e; - + fopAcM_SetGroup(this, 0); fopAcM_OffStatus(this, 0); diff --git a/src/d/actor/d_a_bd.cpp b/src/d/actor/d_a_bd.cpp index d579c98c86..cde0bf553a 100644 --- a/src/d/actor/d_a_bd.cpp +++ b/src/d/actor/d_a_bd.cpp @@ -15,7 +15,46 @@ #include "Z2AudioLib/Z2Instances.h" #include <cstring> +class daBd_HIO_c : public JORReflexible { +public: + daBd_HIO_c(); + virtual ~daBd_HIO_c() {} + + void genMessage(JORMContext*); + + /* 0x04 */ s8 id; + /* 0x08 */ f32 mBasicSize; + /* 0x0C */ f32 mFlightSpeed; + /* 0x10 */ f32 mGroundSpeed; + /* 0x14 */ s16 mFlightTime; + /* 0x18 */ f32 mLinkDetectRange; + /* 0x1C */ s16 mChirpDist; + /* 0x1E */ s8 field_0x1E; +}; +daBd_HIO_c::daBd_HIO_c() { + id = -1; + mBasicSize = 1.2f; + mFlightSpeed = 20.0f; + mGroundSpeed = 3.0f; + mFlightTime = 400; + mLinkDetectRange = 300.0f; + mChirpDist = 60; + field_0x1E = 0; +} + +#if DEBUG +/* daBd_HIO_c::genMessage (JORMContext *) */ +void daBd_HIO_c::genMessage(JORMContext* mctx) { + mctx->genLabel(" 小鳥 ", 0x80000001); + mctx->genSlider("基本大きさ", &mBasicSize, 0.0f, 5.0f); + mctx->genSlider("飛行速度", &mFlightSpeed, 0.0f, 50.0f); + mctx->genSlider("地上速度", &mGroundSpeed, 0.0f, 20.0f); + mctx->genSlider("飛行時間(およそ)", &mFlightTime, 0, 30000); + mctx->genSlider("リンク認識距離", &mLinkDetectRange, 0.0f, 2000.0f); + mctx->genSlider("羽LevelSE鳴る距離", &mChirpDist, 0, 1000); +} +#endif struct land_pos { /* 0x00 */ s32 unk; @@ -44,7 +83,11 @@ static land_pos land_pos127[20] = { {0, -2302.0f, 1216.0f, -242.0f}, {-1, 0.0f, 0.0f, 0.0f}, }; -static int wait_bck[3] = {ANM_PITA_LEFTUP, ANM_PITA_RIGHT, ANM_PITA_DOWN}; +static void anm_init(bd_class* i_this, int i_anmID, f32 i_morf, u8 i_attr, f32 i_speed) { + i_this->mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("Bd", i_anmID), i_attr, i_morf, + i_speed, 0.0f, -1.0f, NULL); + i_this->mAnmID = i_anmID; +} static u8 hio_set; static daBd_HIO_c l_HIO; @@ -58,37 +101,6 @@ static cXyz land_sp_pos[4] = { static int rope_pt; -daBd_HIO_c::daBd_HIO_c() { - id = -1; - mBasicSize = 1.2f; - mFlightSpeed = 20.0f; - mGroundSpeed = 3.0f; - mFlightTime = 400; - mLinkDetectRange = 300.0f; - mChirpDist = 60; - field_0x1E = 0; -} - -#if DEBUG -/* daBd_HIO_c::genMessage (JORMContext *) */ -void daBd_HIO_c::genMessage(JORMContext* mctx) { - mctx->genLabel("小鳥", 0x80000001); - mctx->genSlider("基本大きさ", &mBasicSize, 0.0f, 5.0f); - mctx->genSlider("飛行速度", &mFlightSpeed, 0.0f, 50.0f); - mctx->genSlider("地上速度", &mGroundSpeed, 0.0f, 20.0f); - mctx->genSlider("飛行時間(およそ)", &mFlightTime, 0, 30000); - mctx->genSlider("リンク認識距離", &mLinkDetectRange, 0.0f, 2000.0f); - mctx->genSlider("羽LevelSE鳴る距離", &mChirpDist, 0, 1000); -} -#endif - - -static void anm_init(bd_class* i_this, int i_anmID, f32 i_morf, u8 i_attr, f32 i_speed) { - i_this->mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("Bd", i_anmID), i_attr, i_morf, - i_speed, 0.0f, -1.0f, NULL); - i_this->mAnmID = i_anmID; -} - static int daBd_Draw(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; @@ -100,7 +112,6 @@ static int daBd_Draw(bd_class* i_this) { return 1; } - static int way_bg_check(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; @@ -123,22 +134,23 @@ static int way_bg_check(bd_class* i_this) { return 0; } - static void* s_a_sub(void* i_target, void* i_bird) { - fopAc_ac_c* a_target = (fopAc_ac_c*)i_target; - bd_class* b_bird = (bd_class*)i_bird; - fopEn_enemy_c* a_bird = (fopEn_enemy_c*)i_bird; + UNUSED(i_bird); - if ((fopAcM_IsActor(i_target) && fopAcM_GetGroup(a_target) == fopAc_ENEMY_e) || - fopAcM_GetGroup(a_target) == fopAc_NPC_e || fopAcM_GetName(i_target) == fpcNm_OBJ_KANBAN2_e || + if ((fopAcM_IsActor(i_target) && fopAcM_GetGroup((fopAc_ac_c*)i_target) == fopAc_ENEMY_e) || + fopAcM_GetGroup((fopAc_ac_c*)i_target) == fopAc_NPC_e || fopAcM_GetName(i_target) == fpcNm_OBJ_KANBAN2_e || fopAcM_GetName(i_target) == fpcNm_OBJ_FOOD_e) { - cXyz distance = a_bird->current.pos - a_target->current.pos; + fopEn_enemy_c* birdEnemy = (fopEn_enemy_c*)i_bird; + fopAc_ac_c* a_target = (fopAc_ac_c*)i_target; + + cXyz distance = birdEnemy->current.pos - a_target->current.pos; if (distance.abs() < l_HIO.mLinkDetectRange + 10.0f * fabsf(a_target->speedF)) { return i_target; } - distance = b_bird->field_0x5C4 - a_target->current.pos; + bd_class* bird = (bd_class*)birdEnemy; + distance = bird->field_0x5C4 - a_target->current.pos; if (distance.abs() < l_HIO.mLinkDetectRange + 10.0f * fabsf(a_target->speedF)) { return i_target; } @@ -146,9 +158,7 @@ static void* s_a_sub(void* i_target, void* i_bird) { return NULL; } - static void pl_check(bd_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); f32 var_f30; @@ -161,7 +171,7 @@ static void pl_check(bd_class* i_this) { } if ((i_this->field_0x618 & 0xF) == 0) { - var_r28 = (u32)fpcM_Search(s_a_sub, a_this); + var_r28 = (u32)fpcM_Search(s_a_sub, i_this); } if (daPy_getPlayerActorClass()->checkHorseRide()) { @@ -201,23 +211,22 @@ static int pointBgCheck(cXyz* param_0, cXyz* param_1) { return 0; } - static int land_check(bd_class* i_this) { - int land_pos_len; - land_pos* land_pos; - s8 temp_r1[112]; + s8 sp3C[108]; int sp20 = g_Counter.mCounter0 + fopAcM_GetID(i_this); if ((sp20 & 7) != 0) { return -1; } - fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; - camera_process_class* camera = dComIfGp_getCamera(0); + fopEn_enemy_c* enemy = (fopEn_enemy_c*)&i_this->enemy; + camera_class* camera = (camera_class*)dComIfGp_getCamera(0); cXyz sp30; sp30 = camera->view.lookat.center - camera->view.lookat.eye; s16 spA = cM_atan2s(sp30.x, sp30.z); + int land_pos_len; + land_pos* land_pos; if (strcmp(dComIfGp_getStartStageName(), "F_SP103") == 0) { land_pos_len = 20; land_pos = land_pos103; @@ -227,7 +236,7 @@ static int land_check(bd_class* i_this) { } for (int i = 0; i < land_pos_len; i++) { - temp_r1[i] = 0; + sp3C[i] = 0; } f32 var_f31 = 1000.0f; for (int i = 0; i < 5; i++) { @@ -235,7 +244,7 @@ static int land_check(bd_class* i_this) { if (land_pos[j].unk < 0) { break; } - if (temp_r1[j] != 0) { + if (sp3C[j] != 0) { continue; } sp30.x = land_pos[j].x - camera->view.lookat.eye.x; @@ -256,8 +265,8 @@ static int land_check(bd_class* i_this) { sp30.x = land_pos[j].x; sp30.y = land_pos[j].y + 5.0f; sp30.z = land_pos[j].z; - if (pointBgCheck(&a_this->current.pos, &sp30)) { - temp_r1[j] = 1; + if (pointBgCheck(&enemy->current.pos, &sp30)) { + sp3C[j] = 1; } else { return j; } @@ -267,6 +276,7 @@ static int land_check(bd_class* i_this) { return -1; } +static int wait_bck[3] = {ANM_PITA_LEFTUP, ANM_PITA_RIGHT, ANM_PITA_DOWN}; static void drop_check(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; @@ -278,14 +288,12 @@ static void drop_check(bd_class* i_this) { } } - static void turn_set(bd_class* i_this) { + fopEn_enemy_c* enemy = &i_this->enemy; s16 angle_table[3] = {-0x8000, 0x4000, -0x4000}; - s16 angle = angle_table[(int)cM_rndF(2.99f)]; - i_this->mTargetAngleY = i_this->enemy.current.angle.y + angle; + i_this->mTargetAngleY = enemy->current.angle.y + angle_table[(int)cM_rndF(2.99f)]; } - static void bd_ground(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); @@ -394,7 +402,6 @@ static void bd_ground(bd_class* i_this) { } } - static void bd_fly(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); @@ -514,7 +521,6 @@ static void bd_fly(bd_class* i_this) { } } - static void bd_landing(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); @@ -604,7 +610,6 @@ static void bd_landing2(bd_class* i_this) { TREG_S(7) + 1000); } - static void bd_landing3(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); @@ -647,7 +652,6 @@ static void bd_landing3(bd_class* i_this) { } } - static void bd_rope(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; @@ -735,7 +739,6 @@ static void bd_drop(bd_class* i_this) { } } - static void action(bd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; @@ -851,11 +854,12 @@ static void action(bd_class* i_this) { } } - static int daBd_Execute(bd_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)i_this; + //TODO: almost definitely a fakematch, forces debug to use .rodata pool + (void)1.2f; + + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->enemy; daNpc_Kkri_c* kkri; - daCow_c* cow; if (i_this->field_0x5B6 >= 1) { if (i_this->field_0x642 != 0) { @@ -889,8 +893,8 @@ static int daBd_Execute(bd_class* i_this) { action(i_this); mDoMtx_stack_c::transS(a_this->current.pos.x, a_this->current.pos.y + i_this->field_0x620, a_this->current.pos.z); - mDoMtx_stack_c::YrotM(a_this->shape_angle.y); - mDoMtx_stack_c::XrotM(a_this->shape_angle.x); + mDoMtx_stack_c::YrotM((s16)a_this->shape_angle.y); + mDoMtx_stack_c::XrotM((s16)a_this->shape_angle.x); mDoMtx_stack_c::ZrotM(a_this->shape_angle.z); mDoMtx_stack_c::scaleM(l_HIO.mBasicSize, l_HIO.mBasicSize, l_HIO.mBasicSize); J3DModel* model_p = i_this->mpMorf->getModel(); @@ -908,7 +912,7 @@ static int daBd_Execute(bd_class* i_this) { i_this->mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(a_this))); if (i_this->field_0x656 == 0 && dComIfGp_event_runCheck()) { - cow = (daCow_c*)fopAcM_SearchByName(fpcNm_COW_e); + fopAc_ac_c* cow = (fopAc_ac_c*)fopAcM_SearchByName(fpcNm_COW_e); if (cow != NULL && cow->speedF > 1.0f) { i_this->field_0x656 = 1; i_this->mActionID = ACT_GROUND; @@ -965,10 +969,9 @@ static int useHeapInit(fopAc_ac_c* i_this) { return 1; } - static int daBd_Create(fopAc_ac_c* i_act_this) { bd_class* i_this = (bd_class*)i_act_this; - fopAcM_ct(i_act_this, bd_class); + fopAcM_ct(&i_this->enemy, bd_class); int phase_state = dComIfG_resLoad(&i_this->mPhase, "Bd"); if (phase_state == cPhs_COMPLEATE_e) { @@ -998,8 +1001,7 @@ static int daBd_Create(fopAc_ac_c* i_act_this) { i_act_this, 1, &i_this->mAcchCir, fopAcM_GetSpeed_p(i_act_this), NULL, NULL); i_this->mAcchCir.SetWall(10.0f, 10.0f); - i_act_this->health = 1; - i_act_this->field_0x560 = 1; + i_act_this->field_0x560 = i_act_this->health = 1; i_this->mStts.Init(100, 0, i_act_this); static dCcD_SrcSph cc_sph_src = { diff --git a/src/d/actor/d_a_bg.cpp b/src/d/actor/d_a_bg.cpp index 6f7c8ed2d6..3bac37dbf9 100644 --- a/src/d/actor/d_a_bg.cpp +++ b/src/d/actor/d_a_bg.cpp @@ -42,9 +42,11 @@ static int createMatAnm(J3DModelData* i_modelData, u16 i_materialID) { return 1; } +#if PLATFORM_GCN static u8 const lit_3756[12] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +#endif int daBg_btkAnm_c::create(J3DModelData* i_modelData, J3DAnmTextureSRTKey* i_btk, int i_anmPlay) { mpBtk = new mDoExt_btkAnm(); @@ -243,6 +245,12 @@ int daBg_c::createHeap() { return 1; } +#if DEBUG +static void dummy() { + GXColor color = {0xC0, 0x00, 0x00, 0x00}; +} +#endif + daBg_c::~daBg_c() { int roomNo = fopAcM_GetParam(this); @@ -252,7 +260,7 @@ daBg_c::~daBg_c() { } if (heap != NULL && mpBgW != NULL) { - dComIfG_Bgsp().Release((dBgW_Base*)mpBgW); + dComIfG_Bgsp().Release(mpBgW); dStage_roomControl_c::setBgW(roomNo, NULL); } diff --git a/src/d/actor/d_a_door_spiral.cpp b/src/d/actor/d_a_door_spiral.cpp index f49ffca58c..c398127f46 100644 --- a/src/d/actor/d_a_door_spiral.cpp +++ b/src/d/actor/d_a_door_spiral.cpp @@ -209,7 +209,6 @@ int daSpiral_c::create() { return cPhs_COMPLEATE_e; } -// DEBUG NONMATCHING - regalloc int daSpiral_c::CreateHeap() { J3DModelData* modelData = getModelData(); JUT_ASSERT(338, modelData != NULL); @@ -223,35 +222,38 @@ int daSpiral_c::CreateHeap() { return 0; } - cBgD_t* bgd = (cBgD_t*)dComIfG_getObjectRes(getAlwaysArcName(), getSpiralDzbName(mType)); - JUT_ASSERT(356, bgd != NULL); - bool spiral_rt = mpSpiralDzb->Set(bgd, 1, &mSpiralBgMtx); - if (spiral_rt == true) { - return 0; - } + { + cBgD_t* bgd = (cBgD_t*)dComIfG_getObjectRes(getAlwaysArcName(), getSpiralDzbName(mType)); + JUT_ASSERT(356, bgd != NULL); + bool spiral_rt = mpSpiralDzb->Set(bgd, 1, &mSpiralBgMtx); + if (spiral_rt == true) { + return 0; + } - mDoorDarkDzb = new dBgW(); - if (mDoorDarkDzb == NULL) { - return 0; + mDoorDarkDzb = new dBgW(); + if (mDoorDarkDzb == NULL) { + return 0; + } } - bgd = (cBgD_t*)dComIfG_getObjectRes(getAlwaysArcName(), getDzb()); - JUT_ASSERT(375, bgd != NULL); + { + cBgD_t* bgd = (cBgD_t*)dComIfG_getObjectRes(getAlwaysArcName(), getDzb()); + JUT_ASSERT(375, bgd != NULL); - cXyz dzb_pos(l_dzb_offset); - mDoMtx_stack_c::YrotS(home.angle.y); - mDoMtx_stack_c::multVec(&dzb_pos, &dzb_pos); - mDoMtx_stack_c::transS(current.pos.x + dzb_pos.x, current.pos.y + dzb_pos.y, current.pos.z + dzb_pos.z); - mDoMtx_stack_c::YrotM(home.angle.y); - cMtx_copy(mDoMtx_stack_c::get(), mDoorDarkBgMtx); + cXyz dzb_pos(l_dzb_offset); + mDoMtx_stack_c::YrotS(home.angle.y); + mDoMtx_stack_c::multVec(&dzb_pos, &dzb_pos); + mDoMtx_stack_c::transS(current.pos.x + dzb_pos.x, current.pos.y + dzb_pos.y, current.pos.z + dzb_pos.z); + mDoMtx_stack_c::YrotM(home.angle.y); + cMtx_copy(mDoMtx_stack_c::get(), mDoorDarkBgMtx); - bool dark_rt = mDoorDarkDzb->Set(bgd, 1, &mDoorDarkBgMtx); - if (dark_rt == true) { - return 0; + bool dark_rt = mDoorDarkDzb->Set(bgd, 1, &mDoorDarkBgMtx); + if (dark_rt == true) { + return 0; + } } if (checkMakeStop() && !mStop.create(this)) { - int _; return 0; } @@ -805,11 +807,8 @@ BOOL daSpiral_c::drawCheck(int) { } #if DEBUG -// DEBUG NONMATCHING - stack void daSpiral_c::debugDraw() { - GXColor spC = {0xFF, 0xFF, 0xFF, 0xFF}; - GXColor sp8 = spC; - GXColor color = sp8; + GXColor color = (GXColor){0xFF, 0xFF, 0xFF, 0xFF}; cXyz sp68[4]; cXyz sp38[4]; @@ -843,7 +842,7 @@ void daSpiral_c::debugDraw() { } if (KREG_S(9) == 1000) { - dDbVw_drawQuadOpa(sp68, spC, TRUE); + dDbVw_drawQuadOpa(sp68, color, TRUE); dDbVw_drawSphereXlu(current.pos, 30.0f, color, TRUE); } diff --git a/src/d/actor/d_a_e_bg.cpp b/src/d/actor/d_a_e_bg.cpp index be38c9c527..a0d9f86860 100644 --- a/src/d/actor/d_a_e_bg.cpp +++ b/src/d/actor/d_a_e_bg.cpp @@ -16,6 +16,23 @@ #include "d/d_s_play.h" #include "f_op/f_op_camera_mng.h" +class daE_BG_HIO_c : public JORReflexible { +public: + daE_BG_HIO_c(); + virtual ~daE_BG_HIO_c() {} + + void genMessage(JORMContext*); + + /* 0x04 */ s8 field_0x4; + /* 0x08 */ f32 mTrackingSpeed; + /* 0x0C */ f32 mRushSpeed; + /* 0x10 */ f32 mWaitDistanceBeforeCharging; + /* 0x14 */ f32 mPlayerSearchDistance; + /* 0x18 */ f32 mAttackRange; + /* 0x1C */ f32 mSwimRange; + /* 0x20 */ f32 mJumpTime; +}; + daE_BG_HIO_c::daE_BG_HIO_c() { field_0x4 = -1; mTrackingSpeed = 8.0f; @@ -335,7 +352,8 @@ void daE_BG_c::executeSwim() { } } - if (search_esa() != NULL) { + fopAc_ac_c* search_actor = search_esa(); + if (search_actor != NULL) { setActionMode(7, 0); return; } @@ -380,8 +398,8 @@ void daE_BG_c::executeSwim() { field_0x6ac = field_0x69a - shape_angle.y; cLib_addCalcAngleS(&shape_angle.y, field_0x69a, 0x10, 0x400, 0x100); - s32 targetAngleX = cLib_targetAngleX(¤t.pos, &field_0x660); - cLib_addCalcAngleS(&shape_angle.x, targetAngleX, 0x10, 0x400, 0x100); + cLib_addCalcAngleS(&shape_angle.x, (s16)cLib_targetAngleX(¤t.pos, &field_0x660), + 0x10, 0x400, 0x100); cLib_chaseF(&speedF, cM_scos(shape_angle.x) * 4.0f, 0.2f); cLib_chaseF(&speed.y, cM_ssin(shape_angle.x) * 4.0f, 0.2f); @@ -743,8 +761,8 @@ bool daE_BG_c::setBombCarry(int param_0) { fopAcM_GetRoomNo(this)); } + fopAc_ac_c* unkActor1; if (bomb != NULL) { - fopAc_ac_c* unkActor1; fopAcM_SearchByID(fopAcM_GetLinkId(this), &unkActor1); if (unkActor1 != NULL) { ((daE_BG_c*)unkActor1)->setBgId(fopAcM_GetID(bomb)); @@ -935,6 +953,8 @@ void daE_BG_c::executeEat() { field_0x6a2 = nREG_S(0) + 0xc00; field_0x69c += field_0x6a0; + f32 targetSpeedX; + f32 targetSpeedY; switch (this->mMoveMode) { case 0: field_0x660.y = rodPos.y + cM_rndFX(100.0f); @@ -1038,10 +1058,8 @@ void daE_BG_c::executeEat() { cLib_addCalcAngleS(&shape_angle.x, 0, 0x10, 0x400, 0x100); if (rodPos.abs(current.pos) > 70.0f) { - cM_scos(shape_angle.x); - cLib_chaseF(&speedF, 0.0f, 0.1f); - cM_ssin(shape_angle.x); - cLib_chaseF(&speed.y, 0.0f, 0.1f); + cLib_chaseF(&speedF, cM_scos(shape_angle.x) * 0.0f, 0.1f); + cLib_chaseF(&speed.y, cM_ssin(shape_angle.x) * 0.0f, 0.1f); } else { cLib_chaseF(&speedF, cM_scos(shape_angle.x) * -1.0f, 0.3f); cLib_chaseF(&speed.y, cM_ssin(shape_angle.x) * -1.0f, 0.3f); @@ -1286,7 +1304,7 @@ static int daE_BG_Delete(daE_BG_c* i_this) { int daE_BG_c::CreateHeap() { J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("E_BG", 10); - JUT_ASSERT(0, modelData != NULL); + JUT_ASSERT(1890, modelData != NULL); mpMorfSO = new mDoExt_McaMorfSO(modelData, NULL, NULL, (J3DAnmTransform*)dComIfG_getObjectRes("E_BG", 7), 0, 1.0f, 0, diff --git a/src/d/actor/d_a_e_df.cpp b/src/d/actor/d_a_e_df.cpp index 0f0a14a7e2..bc7d9dea28 100644 --- a/src/d/actor/d_a_e_df.cpp +++ b/src/d/actor/d_a_e_df.cpp @@ -13,7 +13,7 @@ class daE_DF_HIO_c : public JORReflexible { public: daE_DF_HIO_c(); - virtual ~daE_DF_HIO_c() {}; + virtual ~daE_DF_HIO_c() {} void genMessage(JORMContext*); @@ -23,18 +23,18 @@ public: STATIC_ASSERT(sizeof(daE_DF_HIO_c) == 0xC); +daE_DF_HIO_c::daE_DF_HIO_c() { + mNo = -1; + field_0x8 = 0.0f; +} + #if DEBUG -inline void daE_DF_HIO_c::genMessage(JORMContext* i_ctx) { +void daE_DF_HIO_c::genMessage(JORMContext* i_ctx) { i_ctx->genLabel("デクレシア", 0x80000001); i_ctx->genSlider("速度", &field_0x8, 0.0f, 100.0f); } #endif -daE_DF_HIO_c::daE_DF_HIO_c() { - mNo = -1; - field_0x8 = 0.0f; -} - int daE_DF_c::CreateHeap() { J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("E_DF", 0xD); JUT_ASSERT(161, modelData != NULL); @@ -101,13 +101,13 @@ void daE_DF_c::CameraSet(f32 i_posz) { cXyz vec(0.0f, 0.0f, i_posz); dBgS_LinChk line_chk; - u16 angle = 0; + s16 angle = 0; for (s16 i = 0; i < 4; i++) { - cLib_offsetPos(&end, &start, angle, &vec); + cLib_offsetPos(&end, &start, (s16)angle, &vec); line_chk.Set(&start, &end, NULL); if (dComIfG_Bgsp().LineCross(&line_chk) == 0) { - cLib_offsetPos(&end, ¢er, angle, &vec); + cLib_offsetPos(&end, ¢er, (s16)angle, &vec); end.y += 400.0f; camera->mCamera.Set(center, end, mFovY, 0); @@ -116,7 +116,7 @@ void daE_DF_c::CameraSet(f32 i_posz) { break; } - angle += 0x10000 - 0x8000; + ANGLE_ADD_2(angle, 0x8000); } } @@ -409,10 +409,10 @@ void daE_DF_c::LinkEatAction() { cLib_chaseAngleS(&mChaseAngle.z, 0, 0x100); } -bool daE_DF_c::Mogu_Mogu() { +u8 daE_DF_c::Mogu_Mogu() { if (mMoguCount > 4) { mMoguCount = 0; - return true; + return 1; } if (mpMorfSO->isLoop()) { @@ -428,10 +428,10 @@ bool daE_DF_c::Mogu_Mogu() { } else { mCreatureSound.startCreatureSound(Z2SE_EN_DF_EAT_WAIT, 0, -1); } - return false; + return 0; } - return false; + return 0; } void daE_DF_c::ObjEatAction() { @@ -494,7 +494,8 @@ void daE_DF_c::SearchAction() { if (obj_carry != NULL) { if (fopAcM_GetName(obj_carry) == fpcNm_Obj_Carry_e) { mEatObjType = EAT_TYPE_OBJ; - mCarryType = obj_carry->getType(); + daObjCarry_c* obj_carry_copy = obj_carry; + mCarryType = obj_carry_copy->getType(); fopAcM_delete(obj_carry); cXyz* obj_pos = &fopAcM_GetPosition(obj_carry); Set_Angle(obj_pos); diff --git a/src/d/actor/d_a_e_dn.cpp b/src/d/actor/d_a_e_dn.cpp index 40fb56c905..0e910a22d1 100644 --- a/src/d/actor/d_a_e_dn.cpp +++ b/src/d/actor/d_a_e_dn.cpp @@ -186,51 +186,53 @@ static void anm_init(e_dn_class* i_this, int i_anm_id, f32 i_morf, u8 i_attr, f3 static int nodeCallBack(J3DJoint* i_joint, int param_2) { if (param_2 == 0) { - int jointNo = i_joint->getJntNo(); + J3DJoint* joint = i_joint; + int jointNo = joint->getJntNo(); J3DModel* model = j3dSys.getModel(); - e_dn_class* i_this = (e_dn_class*)model->getUserArea(); - if (i_this != NULL) { + e_dn_class* dn = (e_dn_class*)model->getUserArea(); + void* dn_v = (void*)dn; + if (dn != NULL) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); if (jointNo != JNT_WORLD_ROOT) { if (jointNo == JNT_WAIST) { - cMtx_YrotM(*calc_mtx, (s16)i_this->field_0x830.y); - cMtx_ZrotM(*calc_mtx, i_this->jnt_waist_z_rot + (-i_this->field_0x762[2].x + i_this->field_0x830.x)); + cMtx_YrotM(*calc_mtx, (s16)dn->field_0x830.y); + cMtx_ZrotM(*calc_mtx, dn->jnt_waist_z_rot + (-dn->field_0x762[2].x + dn->field_0x830.x)); } else if (jointNo == JNT_LEGL1) { - cMtx_YrotM(*calc_mtx, i_this->jnt_legl1_y_rot); + cMtx_YrotM(*calc_mtx, dn->jnt_legl1_y_rot); } else if (jointNo == JNT_LEGL2) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x7fc[0]); + cMtx_ZrotM(*calc_mtx, dn->field_0x7fc[0]); } else if (jointNo == JNT_LEGR1) { - cMtx_YrotM(*calc_mtx, i_this->field_0x7fc[1]); + cMtx_YrotM(*calc_mtx, dn->field_0x7fc[1]); } else if (jointNo == JNT_LEGR2) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x7fc[2]); + cMtx_ZrotM(*calc_mtx, dn->field_0x7fc[2]); } else if (jointNo == JNT_BACKBONE02) { - cMtx_YrotM(*calc_mtx, (i_this->field_0x6fa / 2) + (-i_this->field_0x6f6 + i_this->field_0x762[1].y)); - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[1].x + i_this->field_0x7ec[1]); + cMtx_YrotM(*calc_mtx, (dn->field_0x6fa / 2) + (-dn->field_0x6f6 + dn->field_0x762[1].y)); + cMtx_ZrotM(*calc_mtx, dn->field_0x762[1].x + dn->field_0x7ec[1]); } else if (jointNo == JNT_NECK01 || jointNo == JNT_NECK02) { - cMtx_YrotM(*calc_mtx, i_this->field_0x762[0].y + (-i_this->field_0x6f6 + i_this->field_0x6fa)); - cMtx_ZrotM(*calc_mtx, i_this->field_0x7ec[0] + (-i_this->field_0x6f8 + i_this->field_0x762[0].x)); + cMtx_YrotM(*calc_mtx, dn->field_0x762[0].y + (-dn->field_0x6f6 + dn->field_0x6fa)); + cMtx_ZrotM(*calc_mtx, dn->field_0x7ec[0] + (-dn->field_0x6f8 + dn->field_0x762[0].x)); } else if (jointNo == JNT_ARML1) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[3].y + i_this->jnt_arml1_z_rot_offset); + cMtx_ZrotM(*calc_mtx, dn->field_0x762[3].y + dn->jnt_arml1_z_rot_offset); } else if (jointNo == JNT_ARML2) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[4].y + i_this->jnt_arml2_z_rot_offset); + cMtx_ZrotM(*calc_mtx, dn->field_0x762[4].y + dn->jnt_arml2_z_rot_offset); } else if (jointNo == JNT_ARMR1) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[5].y + i_this->jnt_armr1_z_rot_offset); + cMtx_ZrotM(*calc_mtx, dn->field_0x762[5].y + dn->jnt_armr1_z_rot_offset); } else if (jointNo == JNT_ARMR2) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[6].y + i_this->jnt_armr2_z_rot_offset); + cMtx_ZrotM(*calc_mtx, dn->field_0x762[6].y + dn->jnt_armr2_z_rot_offset); } else if (jointNo >= JNT_TAIL01 && jointNo <= JNT_TAIL04) { - cMtx_YrotM(*calc_mtx, i_this->field_0x80e[jointNo - 31].y + i_this->jnt_tail_y_rot_offset); - cMtx_ZrotM(*calc_mtx, (s16)i_this->field_0x80e[jointNo - 31].x); + cMtx_YrotM(*calc_mtx, dn->field_0x80e[jointNo - 31].y + dn->jnt_tail_y_rot_offset); + cMtx_ZrotM(*calc_mtx, (s16)dn->field_0x80e[jointNo - 31].x); } } - if (i_this->death_jnt_rot != 0) { + if (dn->death_jnt_rot != 0) { if ((jointNo & 1) != 0) { - cMtx_YrotM(*calc_mtx, i_this->death_jnt_rot); + cMtx_YrotM(*calc_mtx, dn->death_jnt_rot); } else if ((jointNo & 2) != 0) { - cMtx_XrotM(*calc_mtx, i_this->death_jnt_rot); + cMtx_XrotM(*calc_mtx, dn->death_jnt_rot); } else if ((jointNo & 4) != 0) { - cMtx_ZrotM(*calc_mtx, i_this->death_jnt_rot); + cMtx_ZrotM(*calc_mtx, dn->death_jnt_rot); } } @@ -270,6 +272,7 @@ static int daE_DN_Draw(e_dn_class* i_this) { g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); g_env_light.setLightTevColorType_MAJI(model, &actor->tevStr); + J3DMaterial* matNode_p; if (i_this->death_flag != 0) { J3DModelData* modelData = model->getModelData(); for (u16 i = 0; i < modelData->getMaterialNum(); i++) { @@ -285,7 +288,7 @@ static int daE_DN_Draw(e_dn_class* i_this) { if (i_this->death_flag != 0) { J3DModelData* modelData = model->getModelData(); for (u16 i = 0; i < modelData->getMaterialNum(); i++) { - J3DMaterial* matNode_p = modelData->getMaterialNodePointer(i); + matNode_p = modelData->getMaterialNodePointer(i); matNode_p->getTevColor(0)->r = 0; matNode_p->getTevColor(0)->g = 0; matNode_p->getTevColor(0)->b = 0; @@ -364,6 +367,7 @@ fopAc_ac_c* target_info[10]; int target_info_count; static void* s_b_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && dBomb_c::checkBombActor((fopAc_ac_c*)i_actor) && !((dBomb_c*)i_actor)->checkStateExplode() && target_info_count < 10) { target_info[target_info_count] = (fopAc_ac_c*)i_actor; target_info_count++; @@ -458,7 +462,7 @@ static BOOL player_way_check(e_dn_class* i_this) { way = way * -1; } - if ((u32)((s16)way & 0xFFFF) < 0x6000) { + if ((u16)way < 0x6000) { return FALSE; } @@ -521,15 +525,14 @@ static BOOL jump_pos_check(e_dn_class* i_this, cXyz* i_pos) { work.x = 0.0f; work.y = 200.0f; - int i = 0; - while (i < KREG_S(7) + 10) { + for (int i = 0; i < KREG_S(7) + 10; i++) { work.z = z_offset; MtxPosition(&work, &new_pos); new_pos += actor->current.pos; gnd_chk.SetPos(&new_pos); new_pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - if ((actor->current.pos.y - new_pos.y) < 200.0f) { + if (actor->current.pos.y - new_pos.y < 200.0f) { *i_pos = new_pos; work.z += KREG_F(18) + 200.0f; MtxPosition(&work, &new_pos); @@ -537,15 +540,13 @@ static BOOL jump_pos_check(e_dn_class* i_this, cXyz* i_pos) { gnd_chk.SetPos(&new_pos); new_pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - if ((actor->current.pos.y - new_pos.y) < 200.0f) { + if (actor->current.pos.y - new_pos.y < 200.0f) { *i_pos = new_pos; } return TRUE; } - z_offset += 50.0f; - i++; } return FALSE; @@ -709,7 +710,6 @@ static void e_dn_otoreac(e_dn_class* i_this) { static void e_dn_bomb_action(e_dn_class* i_this) { fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - s16 angle; cXyz work, bomb_pos_target; dBomb_c* bomb = bomb_check(i_this); if (bomb == NULL) { @@ -748,16 +748,16 @@ static void e_dn_bomb_action(e_dn_class* i_this) { } break; - case 4: + case 4: { if (i_this->arg1 == 1 && bomb->speedF < 0.1f && !bomb->checkStateCarry() && JMAFastSqrt(work.x * work.x + work.z * work.z) < 250.0f) { - angle = i_this->search_angle_y - actor->shape_angle.y; + s16 angle = i_this->search_angle_y - actor->shape_angle.y; if (angle < 0x4000 && angle > -0x4000) { // ±90° i_this->mode = 10; break; } } - target_angle_y += 0x8000; // 180° + ANGLE_ADD_2(target_angle_y, 0x8000); // 180° dash_speed = l_HIO.dash_speed; if (JMAFastSqrt(work.x * work.x + work.z * work.z) > 600.0f) { i_this->mode = 5; @@ -765,6 +765,7 @@ static void e_dn_bomb_action(e_dn_class* i_this) { } break; + } case 5: i_this->sound.startCreatureSoundLevel(Z2SE_EN_DN_V_LOOK_BOMB, 0, -1); @@ -863,7 +864,7 @@ static void e_dn_normal(e_dn_class* i_this) { case 3: movement_speed = l_HIO.movement_speed; - angle = actor->current.angle.y; + s16 angle = actor->current.angle.y; cLib_addCalcAngleS2(&actor->current.angle.y, i_this->cur_angle_y_target, 2, 0x400); /* If the actor is facing roughly 22.5° from the target y, stop moving */ @@ -947,8 +948,9 @@ static void e_dn_drawback(e_dn_class* i_this) { } static void e_dn_wolfbite(e_dn_class* i_this) { - fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->actor; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); + fopEn_enemy_c* enemy = (fopEn_enemy_c*)actor; i_this->invulnerability_timer = 10; cLib_addCalc0(&actor->speedF, 1.0f, 2.0f); @@ -975,8 +977,8 @@ static void e_dn_wolfbite(e_dn_class* i_this) { } } - if (actor->health <= 0 || actor->checkWolfBiteDamage()) { - actor->offWolfBiteDamage(); + if (actor->health <= 0 || enemy->checkWolfBiteDamage()) { + enemy->offWolfBiteDamage(); anm_init(i_this, ANM_HANGED_DAMAGE, 2.0f, J3DFrameCtrl::EMode_NONE, 1.0f); S16_SUB(actor->health, 10); if (actor->health <= 0) { @@ -1032,13 +1034,17 @@ static int way_check(e_dn_class* i_this) { int learn_check; static void* shot_s_sub(void* i_actor, void* i_data) { - e_dn_class* i_this = (e_dn_class*)i_data; - fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - if ((fopAcM_IsActor(i_actor) && (learn_check & 0x80000000) != 0 && fopAcM_GetName(i_actor) == fpcNm_ARROW_e && (fopAcM_GetParam(i_actor) == 1 || - fopAcM_GetParam(i_actor) == 2))) { - cXyz sp28(actor->current.pos - ((fopAc_ac_c*)i_actor)->current.pos); - if (sp28.abs() < 1000.0f) { - return i_actor; + UNUSED(i_data); + if (fopAcM_IsActor(i_actor)) { + if ((learn_check & 0x80000000) != 0 && + fopAcM_GetName(i_actor) == fpcNm_ARROW_e && + (fopAcM_GetParam(i_actor) == 1 || fopAcM_GetParam(i_actor) == 2)) { + fopAc_ac_c* arrowActor = (fopAc_ac_c*)i_actor; + e_dn_class* dn = (e_dn_class*)i_data; + cXyz sp28(dn->actor.current.pos - arrowActor->current.pos); + if (sp28.abs() < 1000.0f) { + return i_actor; + } } } @@ -1050,7 +1056,6 @@ static void e_dn_fight_run(e_dn_class* i_this) { cXyz sp4c, sp58; f32 fVar1 = 0.0f; int frame = i_this->anm_p->getFrame(); - BOOL wayCheck; s8 sVar4 = 1; if (pl_check(i_this, i_this->pl_range + 50.0f, 0x7FFF) == 0 && i_this->timer[0] == 0) { @@ -1223,8 +1228,9 @@ static void e_dn_fight_run(e_dn_class* i_this) { i_this->timer[2] = JREG_F(1) + (cM_rndF(30.0f) + 30.0f); f32 fVar1 = 1.0f; if (cM_rndF(1.0f) < fVar1) { - wayCheck = way_check(i_this); - if (!wayCheck && cM_rndF(1.0f) < 0.75f) { + //TOOD: probably fakematch (debug) + BOOL wayCheck; + if (!(wayCheck = way_check(i_this)) && cM_rndF(1.0f) < 0.75f) { if (i_this->pl_dir < (l_HIO.attack_init_range - 100.0f) + TREG_F(7)) { i_this->action = ACTION_ATTACK_0; } else { @@ -1447,8 +1453,11 @@ static fopAc_ac_c* at_hit_check(e_dn_class* i_this) { return NULL; } + fopAc_ac_c* rv; if (i_this->at_sph.ChkAtHit() != 0) { - return dCc_GetAc(i_this->at_sph.GetAtHitObj()->GetAc()); + cCcD_Obj* atHitObj = i_this->at_sph.GetAtHitObj(); + rv = dCc_GetAc(atHitObj->GetAc()); + return rv; } return NULL; @@ -1541,6 +1550,7 @@ static void e_dn_attack(e_dn_class* i_this) { cLib_addCalc0(&actor->speedF, 1.0f, 5.0f); if (i_this->at_chk_flag != 0) { fopAc_ac_c* actor_p = at_hit_check(i_this); + UNUSED(actor_p); // maybe debug fakematch? if (actor_p != NULL && fopAcM_GetName(actor_p) == fpcNm_ALINK_e && daPy_getPlayerActorClass()->checkPlayerGuard()) { i_this->anm_p->setPlaySpeed(0.0f); i_this->action = ACTION_FIGHT_RUN; @@ -1759,7 +1769,8 @@ static BOOL body_gake(e_dn_class* i_this) { } static void e_dn_damage(e_dn_class* i_this) { - fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->actor; + fopEn_enemy_c* enemy = (fopEn_enemy_c*)actor; cXyz sp34, sp40; if (actor->health <= 0) { @@ -1768,7 +1779,7 @@ static void e_dn_damage(e_dn_class* i_this) { } if (daPy_py_c::checkNowWolf() != 0) { - if (i_this->field_0x6f3 == 0 && actor->checkWolfDownStartFlg()) { + if (i_this->field_0x6f3 == 0 && enemy->checkWolfDownStartFlg()) { if (i_this->timer[0] > 40) { i_this->timer[0] = 90; OS_REPORT(" DN WOLFHIT LONG \n"); @@ -1790,13 +1801,13 @@ static void e_dn_damage(e_dn_class* i_this) { } } - } else if (actor != NULL && actor->checkCutDownHitFlg()) { - actor->offCutDownHitFlg(); + } else if (enemy != NULL && enemy->checkCutDownHitFlg()) { + enemy->offCutDownHitFlg(); i_this->mode = 3; actor->health = 0; i_this->timer[0] = 100; i_this->timer[1] = 46; - actor->offDownFlg(); + enemy->offDownFlg(); actor->health = 0; i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); i_this->death_flag = 1; @@ -1824,15 +1835,16 @@ static void e_dn_damage(e_dn_class* i_this) { case 1: if (i_this->objacch.ChkWallHit() != 0 && i_this->timer[0] == 0) { - int kado_kabe = kado_check(i_this); - if (kado_kabe != 0) { + //TODO: probably fakematch (debug) + int kado_kabe; + if ((kado_kabe = kado_check(i_this)) != 0) { OS_REPORT(" ..KADO KABE ..%x\n", kado_kabe); if (kado_kabe == 2) { i_this->field_0x70e = 0xC00; - i_this->field_0x724.y += TREG_S(8) + -7000; + ANGLE_ADD_2(i_this->field_0x724.y, TREG_S(8) + -7000); } else { i_this->field_0x70e = -0xC00; - i_this->field_0x724.y += -(TREG_S(8) - 7000); + ANGLE_ADD_2(i_this->field_0x724.y, -(TREG_S(8) - 7000)); } i_this->field_0x7e8 = BREG_F(10) + 8000.0f; @@ -1844,7 +1856,7 @@ static void e_dn_damage(e_dn_class* i_this) { i_this->mode = 10; actor->speed.y = 0.0f; i_this->field_0x704 *= 0.2f; - i_this->field_0x724.y += 0x8000; + ANGLE_ADD_2(i_this->field_0x724.y, 0x8000); i_this->field_0x7e8 = BREG_F(10) + 8000.0f; i_this->unk_timer_5 = BREG_S(7) + 5; i_this->field_0x754 = BREG_F(4) + 100.0f; @@ -1908,7 +1920,7 @@ static void e_dn_damage(e_dn_class* i_this) { if (i_this->objacch.ChkGroundHit()) { if (actor->health > 0 && !daPy_py_c::checkNowWolf()) { - actor->onDownFlg(); + enemy->onDownFlg(); } dKy_Sound_set(actor->current.pos, 100, fopAcM_GetID(&i_this->actor), 5); @@ -1976,8 +1988,8 @@ static void e_dn_damage(e_dn_class* i_this) { i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_UP, -1); - if (actor != NULL) { - actor->offDownFlg(); + if (enemy != NULL) { + enemy->offDownFlg(); } } break; @@ -2018,8 +2030,8 @@ static void e_dn_damage(e_dn_class* i_this) { i_this->timer[0] = 5; i_this->mode = 21; - if (actor != NULL) { - actor->offDownFlg(); + if (enemy != NULL) { + enemy->offDownFlg(); } } break; @@ -2036,7 +2048,7 @@ static void e_dn_damage(e_dn_class* i_this) { break; case 30: - if (!actor->checkWolfDownPullFlg()) { + if (!enemy->checkWolfDownPullFlg()) { i_this->timer[1] = 0; } @@ -2051,8 +2063,8 @@ static void e_dn_damage(e_dn_class* i_this) { i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_UP, -1); i_this->timer[0] = 10; } else if (i_this->timer[1] == 1) { - actor->onWolfDownPullEndFlg(); - actor->offCutDownHitFlg(); + enemy->onWolfDownPullEndFlg(); + enemy->offCutDownHitFlg(); actor->health = 0; i_this->timer[0] = 1000; i_this->timer[1] = 35; @@ -2062,13 +2074,13 @@ static void e_dn_damage(e_dn_class* i_this) { case 31: if (i_this->timer[0] == 0) { - actor->offDownFlg(); + enemy->offDownFlg(); i_this->mode = 20; i_this->field_0x6f3 = 0; } } - if (actor != NULL && actor->checkDownFlg()) { + if (enemy != NULL && enemy->checkDownFlg()) { i_this->field_0x6f2 = 0; } @@ -2237,9 +2249,11 @@ static void e_dn_reg(e_dn_class* i_this) { break; } + s16 sp0A = actor->current.angle.y; cLib_addCalcAngleS2(&actor->current.angle.y, i_this->cur_angle_y_target, 2, 0x800); - s16 sVar1 = actor->current.angle.y - i_this->cur_angle_y_target; - if (sVar1 > 0x800 || sVar1 < -0x800) { + sp0A -= actor->current.angle.y; + s16 sp08 = actor->current.angle.y - i_this->cur_angle_y_target; + if (sp08 > 0x800 || sp08 < -0x800) { dash_speed = 0.0f; } @@ -2343,7 +2357,8 @@ static void damage_check(e_dn_class* i_this) { i_this->invulnerability_timer = 1000; } else { at_power_check(&i_this->at_info); - s16 sVar1 = actor->health; + s16 oldHealth1 = actor->health; + s16 oldHealth2 = actor->health; cc_at_check(actor, &i_this->at_info); if (daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_HEAD_JUMP) { @@ -2362,7 +2377,7 @@ static void damage_check(e_dn_class* i_this) { i_this->learn |= i_this->at_info.mHitBit; if (i_this->at_info.mHitType == 16 || i_this->at_info.mpCollider->ChkAtType(AT_TYPE_HOOKSHOT)) { - actor->health = sVar1; + actor->health = oldHealth2; i_this->action = ACTION_DRAWBACK; i_this->mode = 0; @@ -2425,7 +2440,7 @@ static void action(e_dn_class* i_this) { s8 pl_search = 0; s8 bVar2 = 1; - actor->offHeadLockFlg(); + i_this->actor.offHeadLockFlg(); if (fopAcM_otherBgCheck(player, actor)) { fopAcM_OffStatus(actor, 0); actor->attention_info.flags = 0; @@ -2561,15 +2576,15 @@ static void action(e_dn_class* i_this) { MtxPosition(&work, &sp24c); actor->current.pos += sp24c; work = i_this->field_0x5bc - i_this->field_0x5c8; - f32 fVar1 = work.abs(); + f32 var_f28 = work.abs(); work = i_this->field_0x5bc - actor->current.pos; - f32 fVar2 = work.abs(); - f32 fVar3 = fVar1 * (NREG_F(19) + 0.3f); - if (fVar3 > NREG_F(18) + 250.0f) { - fVar3 = NREG_F(18) + 250.0f; + f32 var_f25 = work.abs(); + f32 var_f30 = var_f28 * (NREG_F(19) + 0.3f); + if (var_f30 > NREG_F(18) + 250.0f) { + var_f30 = NREG_F(18) + 250.0f; } - i_this->cur_pos_y_offset = fVar3 * cM_ssin((fVar2 / fVar1) * 32768.0f); + i_this->cur_pos_y_offset = var_f30 * cM_ssin((var_f25 / var_f28) * 32768.0f); i_this->field_0x5d8 = 0; } else { cLib_addCalc0(&i_this->cur_pos_y_offset, 1.0f, 30.0f); @@ -2621,9 +2636,9 @@ static void action(e_dn_class* i_this) { } } - s16 max_step, sVar2, sVar3; - sVar2 = 0; - sVar3 = 0; + s16 sp14, sp12, max_step; + sp14 = 0; + sp12 = 0; max_step = 0x800; if (i_this->field_0x700 != 0) { i_this->field_0x700--; @@ -2657,22 +2672,22 @@ static void action(e_dn_class* i_this) { } work.y += -(TREG_F(2) + 150.0f) * l_HIO.model_size; - sVar2 = cM_atan2s(work.x, work.z) - actor->shape_angle.y; - sVar3 = actor->shape_angle.x + cM_atan2s(work.y, JMAFastSqrt(work.x * work.x + work.z * work.z)); - if (sVar2 > 0x2710) { - sVar2 = 10000; - } else if (sVar2 < -10000) { - sVar2 = -10000; + sp14 = cM_atan2s(work.x, work.z) - actor->shape_angle.y; + sp12 = actor->shape_angle.x + cM_atan2s(work.y, JMAFastSqrt(work.x * work.x + work.z * work.z)); + if (sp14 > 0x2710) { + sp14 = 10000; + } else if (sp14 < -10000) { + sp14 = -10000; } - if (sVar3 > 0x2710) { - sVar3 = 10000; - } else if (sVar3 < -20000) { - sVar3 = -20000; + if (sp12 > 0x2710) { + sp12 = 10000; + } else if (sp12 < -20000) { + sp12 = -20000; } - cLib_addCalcAngleS2(&i_this->field_0x6f6, sVar2 / 2, 2, max_step); - cLib_addCalcAngleS2(&i_this->field_0x6f8, sVar3 / 2, 2, max_step); + cLib_addCalcAngleS2(&i_this->field_0x6f6, sp14 / 2, 2, max_step); + cLib_addCalcAngleS2(&i_this->field_0x6f8, sp12 / 2, 2, max_step); } i_this->field_0x6fc = 0; @@ -2710,13 +2725,13 @@ static void action(e_dn_class* i_this) { i_this->field_0x7a4[1].x = i_this->field_0x75c * cM_scos(i_this->field_0x760) * (BREG_F(0) + 70.0f); i_this->field_0x7a4[2].x += i_this->field_0x7a4[1].x; cLib_addCalc0(&i_this->field_0x75c, 1.0f, BREG_F(1) + 3.0f); - i_this->field_0x760 += BREG_S(0) + 4000; + ANGLE_ADD_2(i_this->field_0x760, BREG_S(0) + 4000); } if (fabsf(i_this->field_0x754) > 1.0f) { i_this->field_0x7a4[0].x = i_this->field_0x754 * cM_scos(i_this->field_0x758) * (BREG_F(2) + 70.0f); cLib_addCalc0(&i_this->field_0x754, 1.0f, BREG_F(3) + 3.0f); - i_this->field_0x758 += BREG_S(1) + 4000; + ANGLE_ADD_2(i_this->field_0x758, BREG_S(1) + 4000); } if (actor->speed.y < 0.0f && i_this->objacch.ChkGroundHit()) { @@ -2725,36 +2740,36 @@ static void action(e_dn_class* i_this) { } if (i_this->field_0x704) { - s16 sVar4 = i_this->field_0x724.y - actor->shape_angle.y; - i_this->field_0x7a4[3].y = 0x4000 + -sVar4; + sp14 = i_this->field_0x724.y - actor->shape_angle.y; + i_this->field_0x7a4[3].y = 0x4000 + -sp14; if (i_this->field_0x7a4[3].y > 6000) { // ~33° i_this->field_0x7a4[3].y = 6000; } else if (i_this->field_0x7a4[3].y < -9000) { // ~49.4° i_this->field_0x7a4[3].y = -9000; } - i_this->field_0x7a4[4].y = 0x4000 + -sVar4; + i_this->field_0x7a4[4].y = 0x4000 + -sp14; if (i_this->field_0x7a4[4].y > 17000) { // ~93.4° i_this->field_0x7a4[4].y = 17000; } else if (i_this->field_0x7a4[4].y < 0) { i_this->field_0x7a4[4].y = 0; } - i_this->field_0x7a4[5].y = sVar4 + 0x4000; + i_this->field_0x7a4[5].y = sp14 + 0x4000; if (i_this->field_0x7a4[5].y > 6000) { i_this->field_0x7a4[5].y = 6000; } else if (i_this->field_0x7a4[5].y < -9000) { i_this->field_0x7a4[5].y = -9000; } - i_this->field_0x7a4[6].y = sVar4 + 0x4000; + i_this->field_0x7a4[6].y = sp14 + 0x4000; if (i_this->field_0x7a4[6].y > 17000) { i_this->field_0x7a4[6].y = 17000; } else if (i_this->field_0x7a4[6].y < 0) { i_this->field_0x7a4[6].y = 0; } - cMtx_YrotS(*calc_mtx, sVar4); + cMtx_YrotS(*calc_mtx, sp14); work.x = 0.0f; work.y = 0.0f; work.z = BREG_F(8) + 12000.0f; @@ -2766,7 +2781,7 @@ static void action(e_dn_class* i_this) { i_this->field_0x836.x = BREG_S(6) + 10000; } - i_this->field_0x836.x += BREG_S(7) + 6000; + ANGLE_ADD_2(i_this->field_0x836.x, BREG_S(7) + 6000); } static s16 j_spd[11] = { @@ -2812,15 +2827,15 @@ static void action(e_dn_class* i_this) { i_this->unk_timer_4--; } - f32 fVar1 = i_this->unk_timer_4 * (DREG_F(13) + 1.0f); - if (fVar1 > 30.0f) { - fVar1 = 30.0f; + f32 var_f31 = i_this->unk_timer_4 * (DREG_F(13) + 1.0f); + if (var_f31 > 30.0f) { + var_f31 = 30.0f; } - fVar1 *= fVar1; + var_f31 *= var_f31; for (int i = 0; i < 4; i++) { - i_this->field_0x80e[i].x = fVar1 * (cM_ssin(i_this->frame_counter * (DREG_S(5) + 5000) + i * (DREG_S(7) + -15000)) * (DREG_F(18) + 5.0f)); - i_this->field_0x80e[i].y = fVar1 * (cM_ssin(i_this->frame_counter * (DREG_S(5) + 0x12C0) + i * (DREG_S(7) + -13000)) * (DREG_F(18) + 5.0f)); + i_this->field_0x80e[i].x = var_f31 * (cM_ssin(i_this->frame_counter * (DREG_S(5) + 5000) + i * (DREG_S(7) + -15000)) * (DREG_F(18) + 5.0f)); + i_this->field_0x80e[i].y = var_f31 * (cM_ssin(i_this->frame_counter * (DREG_S(5) + 0x12C0) + i * (DREG_S(7) + -13000)) * (DREG_F(18) + 5.0f)); } cLib_addCalcAngleS2(&i_this->jnt_tail_y_rot_offset, 0, 4, 0x100); @@ -2830,10 +2845,10 @@ static void action(e_dn_class* i_this) { Vec sp258; cXyz sp264, sp270; dBgS_GndChk gnd_chk; - s16 sVar6, sVar7; - sVar6 = 0; - sVar7 = 0; - fVar1 = 100.0f; + s16 sp0C, sp0A; + sp0C = 0; + sp0A = 0; + f32 var_f27 = 100.0f; MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_BACKBONE02), *calc_mtx); work.set(0.0f, 0.0f, 0.0f); @@ -2846,32 +2861,31 @@ static void action(e_dn_class* i_this) { if (sp264.y != -G_CM3D_F_INF) { sp258.x = sp264.x; sp258.y = sp264.y + 100.0f; - sp258.z = sp264.z + fVar1; + sp258.z = sp264.z + var_f27; gnd_chk.SetPos(&sp258); sp258.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + f32 x, y, z; if (sp258.y != -G_CM3D_F_INF) { - f32 z, y; y = sp258.y - sp264.y; z = sp258.z - sp264.z; - sVar7 = -cM_atan2s(y, z); - if (sVar7 > 0x3000 || sVar7 < -0x3000) { - sVar7 = 0; + sp0A = -cM_atan2s(y, z); + if (sp0A > 0x3000 || sp0A < -0x3000) { + sp0A = 0; } } - sp258.x = sp264.x + fVar1; + sp258.x = sp264.x + var_f27; sp258.y = sp264.y + 100.0f; sp258.z = sp264.z; gnd_chk.SetPos(&sp258); sp258.y = dComIfG_Bgsp().GroundCross(&gnd_chk); if (sp258.y != -G_CM3D_F_INF) { - f32 x, y; y = sp258.y - sp264.y; x = sp258.x - sp264.x; - sVar6 = (s16)cM_atan2s(y, x); - if (sVar6 > 0x3000 || sVar6 < -0x3000) { - sVar6 = 0; + sp0C = (s16)cM_atan2s(y, x); + if (sp0C > 0x3000 || sp0C < -0x3000) { + sp0C = 0; } } } @@ -2898,8 +2912,8 @@ static void action(e_dn_class* i_this) { actor->current.pos += sp24c; } - i_this->field_0x730.x = sVar7; - i_this->field_0x730.z = sVar6; + i_this->field_0x730.x = sp0A; + i_this->field_0x730.z = sp0C; } } @@ -3362,7 +3376,7 @@ static int useHeapInit(fopAc_ac_c* actor) { static cPhs_Step daE_DN_Create(fopAc_ac_c* actor) { e_dn_class* i_this = (e_dn_class*)actor; - fopAcM_ct(actor, e_dn_class); + fopAcM_ct(&i_this->actor, e_dn_class); cPhs_Step phase = dComIfG_resLoad(&i_this->phase, "E_dn"); if (phase == cPhs_COMPLEATE_e) { diff --git a/src/d/actor/d_a_e_hp.cpp b/src/d/actor/d_a_e_hp.cpp index 12782f91d4..4a5f388e57 100644 --- a/src/d/actor/d_a_e_hp.cpp +++ b/src/d/actor/d_a_e_hp.cpp @@ -28,6 +28,27 @@ public: u8 rangeDisplay; }; +daE_HP_HIO_c::daE_HP_HIO_c() { + mChild = -1; + modelSize = 1.2f; + waitTimeAfterAttack = 40; + resurrectionTime = 100; + attackDelayOnApproach = 50; + rangeDisplay = 0; +} + +#if DEBUG +void daE_HP_HIO_c::genMessage(JORMContext* ctx) { + // General-purpose Poe + ctx->genLabel("汎用ポゥ", 0x80000001); + ctx->genSlider("モデルサイズ", &modelSize, 0.0, 10.0); + ctx->genSlider("攻撃終了後待ち時間", &waitTimeAfterAttack, 0, 1000); + ctx->genSlider("復活時間", &resurrectionTime, 0, 1000); + ctx->genSlider("接近後攻撃しない時間", &attackDelayOnApproach, 0, 0xfe); + ctx->genCheckBox("範囲表示(FINALでは不可)", &rangeDisplay, 0x1); +} +#endif + namespace { static dCcD_SrcCyl cc_hp_src = { { @@ -37,11 +58,11 @@ static dCcD_SrcCyl cc_hp_src = { {0}, }, { - { - {0.0f, 0.0f, 0.0f}, - 50.0f, - 300.0f, - } + { + {0.0f, 0.0f, 0.0f}, + 50.0f, + 300.0f, + } } }; @@ -53,7 +74,7 @@ static dCcD_SrcSph cc_lamp_src = { {0x0}, // mGObjCo }, // mObjInf { - {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph + {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph } // mSphAttr }; @@ -65,36 +86,15 @@ static dCcD_SrcCyl cc_hp_at_src = { {0}, }, { - { - {0.0f, 0.0f, 0.0f}, - 50.0f, - 300.0f, - } + { + {0.0f, 0.0f, 0.0f}, + 50.0f, + 300.0f, + } } }; } // namespace -daE_HP_HIO_c::daE_HP_HIO_c() { - mChild = -1; - modelSize = 1.2f; - waitTimeAfterAttack = 40; - resurrectionTime = 100; - attackDelayOnApproach = 50; - rangeDisplay = 0; -} - -#if DEBUG -void daE_HP_HIO_c::genMessage(JORMContext* ctx) { - // General-purpose Poe - ctx->genLabel("汎用ポゥ", 0x80000001); - ctx->genSlider("モデルサイズ", &modelSize, 0.0, 10.0); - ctx->genSlider("攻撃終了後待ち時間", &waitTimeAfterAttack, 0, 1000); - ctx->genSlider("復活時間", &resurrectionTime, 0, 1000); - ctx->genSlider("接近後攻撃しない時間", &attackDelayOnApproach, 0, 0xfe); - ctx->genCheckBox("範囲表示(FINALでは不可)", &rangeDisplay, 0x1); -} -#endif - int daE_HP_c::ctrlJoint(J3DJoint* i_joint, J3DModel* i_model) { J3DJoint* joint = i_joint; s32 jointNo = joint->getJntNo(); @@ -230,7 +230,8 @@ int daE_HP_c::draw() { mDoMtx_stack_c::multVec(&unkXyz1, &field_0x75c); mDoMtx_stack_c::transS(field_0x75c); - unkXyz1 = dComIfGp_getCamera(0)->view.lookat.eye - field_0x75c; + camera_class* camera = (camera_class*)dComIfGp_getCamera(0); + unkXyz1 = camera->view.lookat.eye - field_0x75c; mDoMtx_stack_c::YrotM(unkXyz1.atan2sX_Z()); mDoMtx_stack_c::XrotM((s16)unkXyz1.atan2sY_XZ()); mDoMtx_stack_c::scaleM(l_HIO.modelSize, l_HIO.modelSize, l_HIO.modelSize); @@ -250,7 +251,7 @@ int daE_HP_c::draw() { } } - mpMorf->getModel(); + model = mpMorf->getModel(); mpMorf->entryDL(); if (checkDownFlg()) { @@ -302,7 +303,8 @@ void daE_HP_c::setActionMode(int param_0, int i_mode) { } bool daE_HP_c::mChkDistance(f32 param_0) { - cXyz vecToPlayer = dComIfGp_getPlayer(0)->current.pos - current.pos; + fopAc_ac_c* player = (fopAc_ac_c*)dComIfGp_getPlayer(0); + cXyz vecToPlayer = player->current.pos - current.pos; if (vecToPlayer.abs() < param_0) { return true; } else { @@ -677,8 +679,7 @@ void daE_HP_c::executeDown() { field_0x772.z = 0; unkXyz1 = home.pos - current.pos; - latDist = unkXyz1.atan2sX_Z(); - cMtx_YrotS(*calc_mtx, latDist); + cMtx_YrotS(*calc_mtx, unkXyz1.atan2sX_Z()); unkXyz1.x = 0.0f; unkXyz1.y = 100.0f; @@ -812,7 +813,8 @@ void daE_HP_c::action() { break; } - if (checkBallModelDraw()) { + fopEn_enemy_c* enemy = this; + if (enemy->checkBallModelDraw()) { mSound2.startCreatureSoundLevel(Z2SE_EN_PO_SOUL, 0, -1); } @@ -841,7 +843,7 @@ void daE_HP_c::action() { } field_0x772.x = -cM_atan2s(planeNormal->z, planeNormal->y); - field_0x772.z = cM_atan2s(planeNormal->x, planeNormal->y); + field_0x772.z = (s16)cM_atan2s(planeNormal->x, planeNormal->y); } } else if (mAction != 1 && mAction != 3) { gravity = 0.0f; diff --git a/src/d/actor/d_a_e_oc.cpp b/src/d/actor/d_a_e_oc.cpp index 54abe314ce..4bd6dd3353 100644 --- a/src/d/actor/d_a_e_oc.cpp +++ b/src/d/actor/d_a_e_oc.cpp @@ -2370,18 +2370,19 @@ void daE_OC_c::executeMoveOut() { bool daE_OC_c::checkWaterSurface() { dBgS_ObjGndChk_Spl gnd_chk_spl; - cXyz my_vec_0 = current.pos; + Vec my_vec_0; + my_vec_0 = current.pos; my_vec_0.y += 500.0f; - gnd_chk_spl.SetPos((Vec*)&my_vec_0); + gnd_chk_spl.SetPos(&my_vec_0); mWaterLvl = dComIfG_Bgsp().GroundCross(&gnd_chk_spl); if (mAcch.ChkGroundHit()) { mWaterLvl = -G_CM3D_F_INF; } if (mWaterLvl > (current.pos.y - 140.0f)) { - return 1; + return true; } else { - return 0; + return false; } } diff --git a/src/d/actor/d_a_e_rdy.cpp b/src/d/actor/d_a_e_rdy.cpp index 5f9b8b5fd4..17708bdf30 100644 --- a/src/d/actor/d_a_e_rdy.cpp +++ b/src/d/actor/d_a_e_rdy.cpp @@ -3790,6 +3790,7 @@ static void* s_adel_sub(void* i_proc, void* i_this) { return NULL; } +// DEBUG NONMATCHING: regalloc hell static void demo_camera(e_rdy_class* i_this) { fopAc_ac_c* a_this = &i_this->actor; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); @@ -4238,7 +4239,7 @@ static void demo_camera(e_rdy_class* i_this) { } if (cVar12 != 0) { - fopAc_ac_c* a_arr = (fopAc_ac_c*) fopAcM_SearchByName(fpcNm_E_ARROW_e); + fopAc_ac_c* a_arr = (fopAc_ac_c*)fopAcM_SearchByName(fpcNm_E_ARROW_e); if (a_arr != NULL) { e_arrow_class* arrow = (e_arrow_class*) a_arr; if (cVar12 == 3) { @@ -4285,7 +4286,7 @@ static void demo_camera(e_rdy_class* i_this) { vec2.set(-93666.0f, -5951.0f, 39000.0f); player->setPlayerPosAndAngle(&vec2, 0, 0); fpcM_Search(s_adel_sub, i_this); -#if VERSION != VERSION_SHIELD_DEBUG +#if PLATFORM_GCN i_this->mMode = 2; anm_init(i_this, ANM_WAIT01, 10.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); #endif diff --git a/src/d/actor/d_a_e_sh.cpp b/src/d/actor/d_a_e_sh.cpp index d9cad9bbe7..39aab64663 100644 --- a/src/d/actor/d_a_e_sh.cpp +++ b/src/d/actor/d_a_e_sh.cpp @@ -748,21 +748,26 @@ static void action(e_sh_class* i_this) { if (unkFlag1) { fopAcM_OnStatus(enemy, 0); - i_this->enemy.attention_info.flags = fopAc_attn_CARRY_e; + //TODO: was this maybe hardcoded as just "4"? +#if PLATFORM_GCN + enemy->attention_info.flags = fopAc_attn_CARRY_e; +#else + enemy->attention_info.flags = fopAc_attn_UNK_4; +#endif } else { fopAcM_OffStatus(enemy, 0); - i_this->enemy.attention_info.flags = fopAc_attn_LOCK_e; + enemy->attention_info.flags = fopAc_attn_LOCK_e; } - cMtx_YrotS(*calc_mtx, i_this->enemy.current.angle.y); + cMtx_YrotS(*calc_mtx, enemy->current.angle.y); baseVec.x = 0.0f; baseVec.y = 0.0f; - baseVec.z = i_this->enemy.speedF; + baseVec.z = enemy->speedF; MtxPosition(&baseVec, &finalVec); - i_this->enemy.speed.x = finalVec.x; - i_this->enemy.speed.z = finalVec.z; - i_this->enemy.current.pos += enemy->speed; - i_this->enemy.speed.y = i_this->enemy.speed.y - (JREG_F(5) + 5.0f); + enemy->speed.x = finalVec.x; + enemy->speed.z = finalVec.z; + enemy->current.pos += enemy->speed; + enemy->speed.y = enemy->speed.y - (JREG_F(5) + 5.0f); cXyz* ccMoveP = i_this->mStts.GetCCMoveP(); if (ccMoveP != NULL) { @@ -777,10 +782,10 @@ static void action(e_sh_class* i_this) { baseVec.z = -i_this->field_0x6a4; cMtx_YrotS(*calc_mtx, i_this->field_0x6a8); MtxPosition(&baseVec, &finalVec); - i_this->enemy.current.pos += finalVec; + enemy->current.pos += finalVec; cLib_addCalc0(&i_this->field_0x6a4, 1.0f, 6.0f); - i_this->enemy.speedF = 0.0f; + enemy->speedF = 0.0f; } i_this->mObjAcch.CrrPos(dComIfG_Bgsp()); @@ -1187,7 +1192,7 @@ static int daE_SH_Create(fopAc_ac_c* i_this) { int resLoadResult = dComIfG_resLoad(&sh->mPhase, "E_sh"); if (resLoadResult == cPhs_COMPLEATE_e) { - OS_REPORT("", fopAcM_GetParam(i_this)); + OS_REPORT("E_sh PARAM %x\n", fopAcM_GetParam(i_this)); sh->field_0x5b4 = (u8)fopAcM_GetParam(i_this); u8 bVar1 = (fopAcM_GetParam(i_this) & 0xff00) >> 8; @@ -1205,21 +1210,26 @@ static int daE_SH_Create(fopAc_ac_c* i_this) { sh->field_0x6b8 = (f32)bVar2 * 100.0f; } - OS_REPORT(""); + OS_REPORT("E_sh//////////////E_SH SET 1 !!\n"); if (!fopAcM_entrySolidHeap(i_this, useHeapInit, 0x2960)) { - OS_REPORT(""); + OS_REPORT("//////////////E_SH SET NON !!\n"); return cPhs_ERROR_e; } - OS_REPORT(""); + OS_REPORT("//////////////E_SH SET 2 !!\n"); if (!hio_set) { sh->mInitState = 1; hio_set = true; - l_HIO.mChild = mDoHIO_CREATE_CHILD("E_sh", &l_HIO); + l_HIO.mChild = mDoHIO_CREATE_CHILD("スタルハウンド", &l_HIO); } + //TODO: was this maybe hardcoded as just "4"? +#if PLATFORM_GCN i_this->attention_info.flags = fopAc_attn_CARRY_e; +#else + i_this->attention_info.flags = fopAc_attn_UNK_4; +#endif fopAcM_SetMtx(i_this, sh->mAnm_p->getModel()->getBaseTRMtx()); fopAcM_SetMin(i_this, -200.0f, -200.0f, -200.0f); diff --git a/src/d/actor/d_a_e_sm2.cpp b/src/d/actor/d_a_e_sm2.cpp index 1563e7cde2..6610ed0af2 100644 --- a/src/d/actor/d_a_e_sm2.cpp +++ b/src/d/actor/d_a_e_sm2.cpp @@ -53,7 +53,8 @@ void daE_SM2_HIO_c::genMessage(JORMContext* ctx) { static int nodeCallBack(J3DJoint* i_joint, int param_1) { if (param_1 == 0) { - int jnt_no = i_joint->getJntNo(); + J3DJoint* joint = i_joint; + int jnt_no = joint->getJntNo(); J3DModel* model = j3dSys.getModel(); e_sm2_class* a_this = (e_sm2_class*)model->getUserArea(); @@ -79,8 +80,9 @@ static int daE_SM2_Draw(e_sm2_class* i_this) { fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->enemy; g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); + J3DModel* model; if (!i_this->isPiece) { - J3DModel* model = i_this->modelMorf->getModel(); + model = i_this->modelMorf->getModel(); g_env_light.setLightTevColorType_MAJI(model, &actor->tevStr); J3DMaterial* material = model->getModelData()->getMaterialNodePointer(0); @@ -96,15 +98,19 @@ static int daE_SM2_Draw(e_sm2_class* i_this) { cXyz pos; pos.set(actor->current.pos.x, 50.0f + actor->current.pos.y + BREG_F(18), actor->current.pos.z); - f32 var_f31 = i_this->size * (2500.0f + BREG_F(19)) * i_this->field_0x830; + f32 var_f31 = (2500.0f + BREG_F(19)) * i_this->size * i_this->field_0x830; if (var_f31 < 700.0f) { var_f31 = 700.0f; } - i_this->shadowId = dComIfGd_setShadow(i_this->shadowId, 1, model, &pos, var_f31, 0.0f, actor->current.pos.y, i_this->acch.GetGroundH(), i_this->acch.m_gnd, &actor->tevStr, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); + i_this->shadowId = + dComIfGd_setShadow(i_this->shadowId, 1, model, &pos, var_f31, 0.0f, + actor->current.pos.y, i_this->acch.GetGroundH(), + i_this->acch.m_gnd, &i_this->enemy.tevStr, 0, 1.0f, + dDlst_shadowControl_c::getSimpleTex()); } } else { - J3DModel* model = i_this->pieceModelMorf->getModel(); + model = i_this->pieceModelMorf->getModel(); J3DMaterial* material = model->getModelData()->getMaterialNodePointer(0); material->getTevKColor(1)->r = i_this->color_R; @@ -1187,8 +1193,9 @@ static void action(e_sm2_class* i_this) { } } + J3DModel* model; if (!i_this->isPiece) { - J3DModel* model = i_this->modelMorf->getModel(); + model = i_this->modelMorf->getModel(); mDoMtx_stack_c::transS(i_this->field_0x840.x, i_this->field_0x840.y, i_this->field_0x840.z); mDoMtx_stack_c::YrotM(i_this->field_0x84c.y); @@ -1214,13 +1221,14 @@ static void action(e_sm2_class* i_this) { i_this->modelMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(actor))); i_this->modelMorf->modelCalc(); } else { - J3DModel* model = i_this->pieceModelMorf->getModel(); + model = i_this->pieceModelMorf->getModel(); mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y, actor->current.pos.z); mDoMtx_stack_c::YrotM(actor->shape_angle.y + (i_this->counter * -400)); - f32 temp_f27 = (0.5f / i_this->field_0x6b0) * (1.0f + ((0.007f + NREG_F(16)) * (i_this->timers[1] * cM_ssin(i_this->counter * (ZREG_S(1) + 8000))))); - mDoMtx_stack_c::scaleM((1.08f + KREG_F(7)) * temp_f27, i_this->field_0x6b0, temp_f27); + f32 var_f25 = 1.0f + ((0.007f + NREG_F(16)) * (i_this->timers[1] * cM_ssin(i_this->counter * (ZREG_S(1) + 8000)))); + f32 var_f27 = (0.5f / i_this->field_0x6b0) * var_f25; + mDoMtx_stack_c::scaleM((1.08f + KREG_F(7)) * var_f27, i_this->field_0x6b0, var_f27); mDoMtx_stack_c::YrotM(i_this->counter * 400); model->setBaseTRMtx(mDoMtx_stack_c::get()); @@ -1293,7 +1301,8 @@ static void action(e_sm2_class* i_this) { cLib_addCalc0(&i_this->field_0x82c, 0.1f, 0.2f); if (i_this->field_0xfd4 != 0) { - eff_set(i_this, &i_this->field_0x708[3], (2.0f + TREG_F(12)) * i_this->size); + f32 size = (2.0f + TREG_F(12)) * i_this->size; + eff_set(i_this, &i_this->field_0x708[3], size); i_this->field_0xfd4 = 0; } } diff --git a/src/d/actor/d_a_e_st.cpp b/src/d/actor/d_a_e_st.cpp index 557f9e2632..5c99e89e50 100644 --- a/src/d/actor/d_a_e_st.cpp +++ b/src/d/actor/d_a_e_st.cpp @@ -334,20 +334,20 @@ static int daE_ST_Draw(e_st_class* i_this) { pos.set(a_this->current.pos.x, a_this->current.pos.y + 400.0f + BREG_F(18), a_this->current.pos.z); if (fopAcM_gc_c::gndCheck(&pos)) { pos.y = TREG_F(7) + fopAcM_gc_c::getGroundY(); - i_this->mShadowKey = dComIfGd_setShadow(i_this->mShadowKey, 1, model, &pos, l_HIO.basic_size * 700.0f, 0.0f, - a_this->current.pos.y, fopAcM_gc_c::getGroundY(), *fopAcM_gc_c::getGroundCheck(), - &a_this->tevStr, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); + i_this->mShadowKey = + dComIfGd_setShadow(i_this->mShadowKey, 1, model, &pos, l_HIO.basic_size * 700.0f, 0.0f, + a_this->current.pos.y, fopAcM_gc_c::getGroundY(), + *fopAcM_gc_c::getGroundCheck(), &i_this->actor.tevStr, 0, 1.0f, + dDlst_shadowControl_c::getSimpleTex()); } if (i_this->field_0x720 != 0) { - u8 uVar1 = JREG_S(5) + 180; - GXColor color = {uVar1, uVar1, uVar1, 0xFF}; - i_this->mLineMat1.update(20, color, &a_this->tevStr); + u8 brightness = JREG_S(5) + 180; + i_this->mLineMat1.update(20, (GXColor){brightness, brightness, brightness, 0xFF}, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->mLineMat1); if (i_this->field_0x760 != 0) { - GXColor color2 = {uVar1, uVar1, uVar1, 0xFF}; - i_this->mLineMat2.update(20, color2, &a_this->tevStr); + i_this->mLineMat2.update(20, (GXColor){brightness, brightness, brightness, 0xFF}, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->mLineMat2); } } diff --git a/src/d/actor/d_a_e_yg.cpp b/src/d/actor/d_a_e_yg.cpp index af5c540e6b..92133d2ce9 100644 --- a/src/d/actor/d_a_e_yg.cpp +++ b/src/d/actor/d_a_e_yg.cpp @@ -244,10 +244,12 @@ static fopAc_ac_c* target_info[20]; static int target_info_count; static void* s_d_sub(void* i_actor, void* i_data) { - daObjCarry_c* actor = (daObjCarry_c*)i_actor; - - if (fopAcM_IsActor(actor) && fopAcM_GetName(actor) == fpcNm_Obj_Carry_e && actor->getType() == 5 && target_info_count < 20) { - target_info[target_info_count] = actor; + UNUSED(i_data); + + if (fopAcM_IsActor(i_actor) && + fopAcM_GetName(i_actor) == fpcNm_Obj_Carry_e && + ((daObjCarry_c*)i_actor)->getType() == 5 && target_info_count < 20) { + target_info[target_info_count] = (fopAc_ac_c*)i_actor; target_info_count++; } @@ -637,51 +639,52 @@ static void e_yg_dokuro(e_yg_class* i_this) { if (skull_p == NULL || i_this->mBgc.ChkWallHit() || fopAcM_checkCarryNow(skull_p)) { i_this->mAction = ACTION_NORMAL; i_this->mActionMode = MODE_INIT; - } else { - cXyz pos_delta(skull_p->current.pos - actor->current.pos); - f32 abs_val = pos_delta.abs(); - i_this->mCurrentAngleYTarget = (s16)cM_atan2s(pos_delta.x, pos_delta.z); - f32 target = 0.0f; - - switch (i_this->mActionMode) { - case MODE_INIT: - anm_init(i_this, BCK_YG_FIND, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mActionMode = DOKURO_MODE_RUN; - break; - - case DOKURO_MODE_RUN: - if (i_this->mpMorf->isStop()) { - anm_init(i_this, BCK_YG_RUN, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->mActionMode = DOKURO_MODE_2; - } - break; - - case DOKURO_MODE_2: - if (abs_val < TREG_F(14) + 75.0f) { - anm_init(i_this, BCK_YG_GNAW, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->mTimers[0] = cM_rndF(60.0f) + 90.0f; - i_this->mActionMode = DOKURO_MODE_3; - } else { - target = l_HIO.movement_spd; - } - break; + return; + } - case DOKURO_MODE_3: - if (abs_val < TREG_F(15) + 65.0f) { - target = -2.0f; - } else if (abs_val > TREG_F(16) + 70.0f) { - target = 2.0f; - } - break; + cXyz pos_delta(skull_p->current.pos - actor->current.pos); + f32 abs_val = pos_delta.abs(); + i_this->mCurrentAngleYTarget = (s16)cM_atan2s(pos_delta.x, pos_delta.z); + f32 target = 0.0f; + + switch (i_this->mActionMode) { + case MODE_INIT: + anm_init(i_this, BCK_YG_FIND, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + i_this->mActionMode = DOKURO_MODE_RUN; + break; + + case DOKURO_MODE_RUN: + if (i_this->mpMorf->isStop()) { + anm_init(i_this, BCK_YG_RUN, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); + i_this->mActionMode = DOKURO_MODE_2; } + break; - cLib_addCalcAngleS2(&actor->current.angle.y, i_this->mCurrentAngleYTarget, 2, 0x2000); - cLib_addCalc2(&actor->speedF, target, 1.0f, 10.0f); + case DOKURO_MODE_2: + if (abs_val < TREG_F(14) + 75.0f) { + anm_init(i_this, BCK_YG_GNAW, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); + i_this->mTimers[0] = cM_rndF(60.0f) + 90.0f; + i_this->mActionMode = DOKURO_MODE_3; + } else { + target = l_HIO.movement_spd; + } + break; - if (pl_check(i_this, i_this->mDistance)) { - i_this->mAction = ACTION_ATTACK; - i_this->mActionMode = MODE_INIT; + case DOKURO_MODE_3: + if (abs_val < TREG_F(15) + 65.0f) { + target = -2.0f; + } else if (abs_val > TREG_F(16) + 70.0f) { + target = 2.0f; } + break; + } + + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->mCurrentAngleYTarget, 2, 0x2000); + cLib_addCalc2(&actor->speedF, target, 1.0f, 10.0f); + + if (pl_check(i_this, i_this->mDistance)) { + i_this->mAction = ACTION_ATTACK; + i_this->mActionMode = MODE_INIT; } } @@ -831,6 +834,8 @@ static void damage_check(e_yg_class* i_this) { } static void ke_control(e_yg_class* i_this, yg_ke_s* yg_p, int param_3, f32 i_posZ) { + UNUSED(param_3); + cXyz work, pos_offset; int i; cXyz* pcVar1 = &yg_p->field_0x0[1]; @@ -841,46 +846,52 @@ static void ke_control(e_yg_class* i_this, yg_ke_s* yg_p, int param_3, f32 i_pos work.z = i_posZ; cXyz spc4; - f32 fVar2, fVar3, fVar4; - f32 fVar1; + f32 var_f30; + f32 sp24; + f32 var_f25; if (i_this->mWaterFlag) { - fVar1 = ZREG_F(9) + -5.0f; + var_f25 = ZREG_F(9) + -5.0f; } else { - fVar1 = ZREG_F(8) + -12.0f; + var_f25 = ZREG_F(8) + -12.0f; } - s16 sVar1 = cM_rndF2(65536.0f); - - fVar2 = JREG_F(8) + 3.0f; - f32 fVar5 = JREG_F(5) + (i_this->mBgc.GetGroundH() + 3.0f); - if (fVar5 < i_this->mGroundCross) { - fVar5 = i_this->mGroundCross; + s16 x_rot; + s16 y_rot; + s16 sp10 = cM_rndF2(65536.0f); + + f32 var_f24 = JREG_F(8) + 3.0f; + f32 var_f31 = JREG_F(5) + (i_this->mBgc.GetGroundH() + 3.0f); + if (var_f31 < i_this->mGroundCross) { + var_f31 = i_this->mGroundCross; } - - f32 fVar6 = JREG_F(17) + 0.8f; + f32 sp20; + f32 sp1C; + f32 var_f29; + f32 var_f28; + f32 var_f27; + f32 var_f26 = JREG_F(17) + 0.8f; for (i = 1; i < 10; i++, pcVar1++, pcVar2++) { - f32 fVar7 = fVar2 * cM_ssin(sVar1 + i * 7000); - f32 fVar8 = fVar2 * cM_ssin(sVar1 + 10000 + i * 6000); - f32 fVar9 = (10 - i) * 0.1f; + sp20 = var_f24 * cM_ssin(sp10 + i * 7000); + sp1C = var_f24 * cM_ssin(sp10 + 10000 + i * 6000); + var_f27 = (10 - i) * 0.1f; - spc4.x = pcVar2->x + (fVar7 + yg_p->field_0xf0.x * fVar9); - spc4.y = pcVar2->y + yg_p->field_0xf0.y * fVar9; - spc4.z = pcVar2->z + (fVar8 + yg_p->field_0xf0.z * fVar9); - - fVar3 = spc4.x + (pcVar1->x - pcVar1[-1].x); - - f32 fVar10; - f32 fVar11 = spc4.z + (pcVar1->z - pcVar1[-1].z); + spc4.x = pcVar2->x + (sp20 + yg_p->field_0xf0.x * var_f27); + spc4.y = pcVar2->y + yg_p->field_0xf0.y * var_f27; + spc4.z = pcVar2->z + (sp1C + yg_p->field_0xf0.z * var_f27); - fVar4 = fVar1 + (pcVar1->y + spc4.y); - if (fVar4 < fVar5) { - fVar4 = fVar5; + sp24 = spc4.x + (pcVar1->x - pcVar1[-1].x); + + var_f29 = spc4.z + (pcVar1->z - pcVar1[-1].z); + + var_f28 = var_f25 + (pcVar1->y + spc4.y); + if (var_f28 < var_f31) { + var_f28 = var_f31; } - fVar10 = fVar4 - pcVar1[-1].y; - s16 x_rot = -cM_atan2s(fVar10, fVar11); - s16 y_rot = (s16)cM_atan2s(fVar3, JMAFastSqrt(fVar10 * fVar10 + fVar11 * fVar11)); + var_f30 = var_f28 - pcVar1[-1].y; + x_rot = -cM_atan2s(var_f30, var_f29); + y_rot = (s16)cM_atan2s(sp24, JMAFastSqrt(var_f30 * var_f30 + var_f29 * var_f29)); cMtx_XrotS(*calc_mtx, x_rot); cMtx_YrotM(*calc_mtx, y_rot); MtxPosition(&work, &pos_offset); @@ -891,9 +902,9 @@ static void ke_control(e_yg_class* i_this, yg_ke_s* yg_p, int param_3, f32 i_pos pcVar1->y = pcVar1[-1].y + pos_offset.y; pcVar1->z = pcVar1[-1].z + pos_offset.z; - pcVar2->x = fVar6 * (pcVar1->x - pcVar2->x); - pcVar2->y = fVar6 * (pcVar1->y - pcVar2->y); - pcVar2->z = fVar6 * (pcVar1->z - pcVar2->z); + pcVar2->x = var_f26 * (pcVar1->x - pcVar2->x); + pcVar2->y = var_f26 * (pcVar1->y - pcVar2->y); + pcVar2->z = var_f26 * (pcVar1->z - pcVar2->z); } } @@ -971,7 +982,7 @@ static void ke_set(e_yg_class* i_this) { work.set(0.0f, ZREG_F(4) + 15.0f, 0.0f); } MtxPosition(&work, &i_this->mYgKes[i].field_0xf0); - + i_this->mYgKes[i].field_0xf0 -= i_this->mYgKes[i].field_0x0[0]; ke_move(i_this, &i_this->mLineMat, &i_this->mYgKes[i], i, pos_z); MtxPull(); @@ -1224,7 +1235,7 @@ static int daE_YG_Execute(e_yg_class* i_this) { MTXCopy(daPy_getLinkPlayerActorClass()->getWolfMouthMatrix(), mDoMtx_stack_c::get()); mDoMtx_stack_c::multVecZero(&actor->current.pos); mDoMtx_stack_c::YrotM(KREG_S(0)); - mDoMtx_stack_c::XrotM(KREG_S(1) + (s16)0x8000); + mDoMtx_stack_c::XrotM(KREG_S(1) + 0x8000); mDoMtx_stack_c::ZrotM(KREG_S(2) + 2500); mDoMtx_stack_c::transM(KREG_F(0) + 10.0f, KREG_F(1) + -60.0f, KREG_F(2) + -20.0f); model->setBaseTRMtx(mDoMtx_stack_c::get()); diff --git a/src/d/actor/d_a_e_yr.cpp b/src/d/actor/d_a_e_yr.cpp index d1851d303a..180c3762b8 100644 --- a/src/d/actor/d_a_e_yr.cpp +++ b/src/d/actor/d_a_e_yr.cpp @@ -16,8 +16,8 @@ public: e_yrHIO_c() { mInvulnerable = 0; mStationary = 0; - field_0x8 = 20.0f; - field_0xc = 2500.0f; + field_0x0c = 20.0f; + mTurningRadius = 2500.0f; mModelScale = 1.0f; mAttackAMinTime = 2000; mAttackAMaxTime = 2500; @@ -51,68 +51,68 @@ public: virtual ~e_yrHIO_c() {} #if DEBUG - void genMessage(JORMContext*); + virtual void genMessage(JORMContext*); #endif - /* 0x04 */ u8 mInvulnerable; - /* 0x05 */ u8 mStationary; - /* 0x06 */ u8 mSuddenAttack; - /* 0x08 */ f32 field_0x8; - /* 0x0C */ f32 field_0xc; + /* 0x06 */ u8 mInvulnerable; + /* 0x07 */ u8 mStationary; + /* 0x08 */ u8 mSuddenAttack; + /* 0x0C */ f32 field_0x0c; /* 0x10 */ f32 mTurningRadius; - /* 0x14 */ f32 mModelScale; - /* 0x18 */ s16 mAttackAMinTime; - /* 0x1A */ s16 mAttackAMaxTime; - /* 0x1C */ s16 mAttackBMinTime; - /* 0x1E */ s16 mAttackBMaxTime; - /* 0x20 */ f32 mAttackMoveSpeed; - /* 0x24 */ f32 mAttackFrequency; - /* 0x28 */ f32 mFlyPlaybackSpeed; - /* 0x2C */ f32 mHoveringPlaybackSpeed; - /* 0x30 */ f32 mAttackPlaybackSpeed; - /* 0x34 */ s16 mChanceTime; - /* 0x38 */ f32 field_0x38; - /* 0x3C */ f32 mChancePlaybackSpeed; - /* 0x40 */ s16 field_0x40; - /* 0x44 */ f32 field_0x44; - /* 0x48 */ f32 field_0x48; - /* 0x4C */ f32 field_0x4c; - /* 0x50 */ s16 mBrakeStartDist; - /* 0x54 */ f32 field_0x54; - /* 0x58 */ f32 mLargeDamage; - /* 0x5C */ f32 mSmallDamage; - /* 0x60 */ s16 mHitOccurrenceFrame; - /* 0x64 */ f32 mDetectDistSky; - /* 0x68 */ f32 mDetectDistGround; - /* 0x6C */ s16 mDetectAngleSky; - /* 0x6E */ s16 mDetectAngleGround; - /* 0x70 */ f32 mDetectHeightSky; - /* 0x74 */ f32 mDetectHeightGround; + /* 0x14 */ f32 field_0x14; + /* 0x18 */ f32 mModelScale; + /* 0x1C */ s16 mAttackAMinTime; + /* 0x1E */ s16 mAttackAMaxTime; + /* 0x20 */ s16 mAttackBMinTime; + /* 0x22 */ s16 mAttackBMaxTime; + /* 0x24 */ f32 mAttackMoveSpeed; + /* 0x28 */ f32 mAttackFrequency; + /* 0x2C */ f32 mFlyPlaybackSpeed; + /* 0x30 */ f32 mHoveringPlaybackSpeed; + /* 0x34 */ f32 mAttackPlaybackSpeed; + /* 0x38 */ s16 mChanceTime; + /* 0x3C */ f32 field_0x38; + /* 0x40 */ f32 mChancePlaybackSpeed; + /* 0x44 */ s16 field_0x40; + /* 0x48 */ f32 field_0x44; + /* 0x4C */ f32 field_0x48; + /* 0x50 */ f32 field_0x4c; + /* 0x54 */ s16 mBrakeStartDist; + /* 0x58 */ f32 field_0x54; + /* 0x5C */ f32 mLargeDamage; + /* 0x60 */ f32 mSmallDamage; + /* 0x64 */ s16 mHitOccurrenceFrame; + /* 0x68 */ f32 mDetectDistSky; + /* 0x6C */ f32 mDetectDistGround; + /* 0x70 */ s16 mDetectAngleSky; + /* 0x72 */ s16 mDetectAngleGround; + /* 0x74 */ f32 mDetectHeightSky; + /* 0x78 */ f32 mDetectHeightGround; }; #if DEBUG void e_yrHIO_c::genMessage(JORMContext* ctx) { // "Kagarok" - ctx->genLabel("\u3000闇カーゴロック", 0x80000001); + ctx->genLabel(" 闇カーゴロック", 0x80000001); ctx->genCheckBox("不死身", &mInvulnerable, 0x1); ctx->genCheckBox("静止", &mStationary, 0x1); ctx->genCheckBox("いきなり攻撃", &mSuddenAttack, 0x1); - ctx->genSlider("旋回半径", &mTurningRadius, 0.0, 10000.0f); - ctx->genSlider("モデルスケール", &mModelScale, 0.0, 10.0f); + ctx->genSlider("旋回半径", &mTurningRadius, 0.0f, 10000.0f); + ctx->genSlider("モデルスケール", &mModelScale, 0.0f, 10.0f); ctx->genSlider("A攻時間(最短)", &mAttackAMinTime, 0, 15000); ctx->genSlider("A攻時間(最長)", &mAttackAMaxTime, 0, 15000); ctx->genSlider("B攻時間(最短)", &mAttackBMinTime, 0, 15000); ctx->genSlider("B攻時間(最長)", &mAttackBMaxTime, 0, 15000); - ctx->genSlider("攻撃移動速度", &mAttackMoveSpeed, 0.0, 2.0f); - ctx->genSlider("攻撃頻度", &mAttackFrequency, 0.0, 10.0f); - ctx->genSlider("fly再生速度", &mFlyPlaybackSpeed, 0.0, 3.0f); - ctx->genSlider("hovering再生速度", &mHoveringPlaybackSpeed, 0.0, 3.0f); - ctx->genSlider("atack再生速度", &mAttackPlaybackSpeed, 0.0, 3.0f); - ctx->genSlider("chance再生速度", &mChancePlaybackSpeed, 0.0, 3.0f); + ctx->genSlider("攻撃移動速度", &mAttackMoveSpeed, 0.0f, 2.0f); + ctx->genSlider("攻撃頻度", &mAttackFrequency, 0.0f, 10.0f); + ctx->genSlider("fly再生速度", &mFlyPlaybackSpeed, 0.0f, 3.0f); + ctx->genSlider("hovering再生速度", &mHoveringPlaybackSpeed, 0.0f, 3.0f); + ctx->genSlider("atack再生速度", &mAttackPlaybackSpeed, 0.0f, 3.0f); + ctx->genSlider("chance再生速度", &mChancePlaybackSpeed, 0.0f, 3.0f); ctx->genSlider("chance時間", &mChanceTime, 0, 200); ctx->genSlider("brake開始距離", &mBrakeStartDist, 0, 3000); - ctx->genSlider("大ダメージ力", &mLargeDamage, 0.0, 150.0f); - ctx->genSlider("小ダメージ力", &mSmallDamage, 0.0, 150.0f); + ctx->genSlider("大ダメージ力", &mLargeDamage, 0.0f, 150.0f); + ctx->genSlider("小ダメージ力", &mSmallDamage, 0.0f, 150.0f); ctx->genSlider("HIT発生フレーム", &mHitOccurrenceFrame, 0, 5); ctx->genSlider("プ認距離(空)", &mDetectDistSky, 0.0f, 10000.0f); ctx->genSlider("プ認高さ(空)", &mDetectHeightSky, 0.0f, 5000.0f); @@ -299,7 +299,7 @@ static int e_yr_player_view_check(e_yr_class* i_this) { if (vDistToPlayer < detectHeight) { s16 r28 = actor->current.angle.y - i_this->field_0xe84 - i_this->mYawToPlayer; if (r28 < 0) { - r28 = -r28; + r28 = r28 * -1; } if ((u16)r28 < detectAngle) { return 1; @@ -311,7 +311,7 @@ static int e_yr_player_view_check(e_yr_class* i_this) { static void path_check(e_yr_class* i_this) { static u8 check_index[255]; - if (i_this->field_0x6ec != 0) { + if (i_this->ppd != 0) { dPnt* point; fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->mEnemy; @@ -322,8 +322,8 @@ static void path_check(e_yr_class* i_this) { unkXyz1 = actor->current.pos; unkXyz1.y += 100.0f; - point = i_this->field_0x6ec->m_points; - for (s32 i = 0; i < i_this->field_0x6ec->m_num; i++, point++) { + point = i_this->ppd->m_points; + for (s32 i = 0; i < i_this->ppd->m_num; i++, point++) { unkXyz2.x = point->m_position.x; unkXyz2.y = point->m_position.y + 100.0f; unkXyz2.z = point->m_position.z; @@ -343,8 +343,8 @@ static void path_check(e_yr_class* i_this) { f32 unkFloat1 = 0.0f; bool unkFlag1 = false; for (s32 i = 0; i < 100; i++, unkFloat1 += 50.0f) { - point = i_this->field_0x6ec->m_points; - for (s32 j = 0; j < i_this->field_0x6ec->m_num; j++, point++) { + point = i_this->ppd->m_points; + for (s32 j = 0; j < i_this->ppd->m_num; j++, point++) { if (check_index[j] != 0) { xDist = actor->current.pos.x - point->m_position.x; yDist = actor->current.pos.y - point->m_position.y; @@ -352,8 +352,8 @@ static void path_check(e_yr_class* i_this) { if (JMAFastSqrt(xDist * xDist + yDist * yDist + zDist * zDist) < unkFloat1) { i_this->field_0x6ea = j - (s32)i_this->field_0x6eb; - if (i_this->field_0x6ea >= (s8)i_this->field_0x6ec->m_num) { - i_this->field_0x6ea = i_this->field_0x6ec->m_num; + if (i_this->field_0x6ea >= (s8)i_this->ppd->m_num) { + i_this->field_0x6ea = i_this->ppd->m_num; } else { if (i_this->field_0x6ea < 0) { i_this->field_0x6ea = 0; @@ -396,10 +396,11 @@ static void daE_Yr_shadowDraw(e_yr_class* i_this) { cXyz unkXyz1; unkXyz1.set(actor->current.pos.x, actor->current.pos.y + 150.0f + BREG_F(18), actor->current.pos.z); - i_this->mShadowKey = dComIfGd_setShadow(i_this->mShadowKey, 1, model, &unkXyz1, - 800.0f + BREG_F(19), 40.0f + BREG_F(17), actor->current.pos.y, - i_this->mAcch.GetGroundH(), i_this->mAcch.m_gnd, &actor->tevStr, - 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); + i_this->mShadowKey = + dComIfGd_setShadow(i_this->mShadowKey, 1, model, &unkXyz1, + 800.0f + BREG_F(19), 40.0f + BREG_F(17), actor->current.pos.y, + i_this->mAcch.GetGroundH(), i_this->mAcch.m_gnd, &i_this->mEnemy.tevStr, + 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); } static int daE_Yr_Draw(e_yr_class* i_this) { @@ -435,18 +436,18 @@ static void e_yr_pos_move(e_yr_class* i_this) { f32 zDiff = i_this->field_0x680.z - actor->current.pos.z; s16 yaw = cM_atan2s(xDiff, zDiff); s16 pitch = -cM_atan2s(yDiff, JMAFastSqrt(xDiff * xDiff + zDiff * zDiff)); - s16 angleY = actor->current.angle.y; + s16 curAngleY = actor->current.angle.y; cLib_addCalcAngleS2(&actor->current.angle.y, yaw, 10 + TREG_S(3), i_this->field_0x69c * i_this->field_0x694); - angleY = (angleY - actor->current.angle.y) * 0x20; + s16 targetAngleY = (curAngleY - actor->current.angle.y) * 0x20; s16 limit = 5500 + TREG_S(1); - if (angleY > limit) { - angleY = limit; - } else if (angleY < -limit) { - angleY = -limit; + if (targetAngleY > limit) { + targetAngleY = limit; + } else if (targetAngleY < -limit) { + targetAngleY = -limit; } - cLib_addCalcAngleS2(&actor->current.angle.z, angleY, 10 + TREG_S(3), + cLib_addCalcAngleS2(&actor->current.angle.z, targetAngleY, 10 + TREG_S(3), i_this->field_0x69c * i_this->field_0x694 * 0.5f); cLib_addCalcAngleS2(&actor->current.angle.x, pitch, 10 + TREG_S(3), @@ -512,8 +513,10 @@ static void e_yr_path_move(e_yr_class* i_this) { s32 frame; switch (i_this->field_0x67c) { - case 0: - frame = i_this->mpMorfSO->getFrame(); + case 0: { + // this case uses a different stack address than others in debug - + // it seems plausible that the frame variable was inadvertently shadowed here + s32 frame = i_this->mpMorfSO->getFrame(); if (actor->current.pos.y > i_this->field_0x680.y && frame == 9 + TREG_S(0)) { @@ -522,6 +525,7 @@ static void e_yr_path_move(e_yr_class* i_this) { } break; + } case 1: if (actor->current.pos.y <= (i_this->field_0x680).y) { i_this->field_0x67c = 0; @@ -531,6 +535,7 @@ static void e_yr_path_move(e_yr_class* i_this) { break; case 10: default: + (void)0; break; } @@ -542,18 +547,18 @@ static void e_yr_path_move(e_yr_class* i_this) { switch (i_this->field_0x67d) { case 0: { i_this->field_0x6ea += i_this->field_0x6eb; - if (i_this->field_0x6ea >= (s8)i_this->field_0x6ec->m_num) { - if (dPath_ChkClose(i_this->field_0x6ec)) { + if (i_this->field_0x6ea >= (s8)i_this->ppd->m_num) { + if (dPath_ChkClose(i_this->ppd)) { i_this->field_0x6ea = 0; } else { i_this->field_0x6eb = -1; - i_this->field_0x6ea = i_this->field_0x6ec->m_num - 2; + i_this->field_0x6ea = i_this->ppd->m_num - 2; } - s32 nextId = i_this->field_0x6ec->m_nextID; + s32 nextId = i_this->ppd->m_nextID; if (nextId != 0xffff) { - i_this->field_0x6ec = dPath_GetRoomPath(nextId, fopAcM_GetRoomNo(actor)); - JUT_ASSERT(0x451, i_this->field_0x6ec != NULL); + i_this->ppd = dPath_GetRoomPath(nextId, fopAcM_GetRoomNo(actor)); + JUT_ASSERT(0x451, i_this->ppd != NULL); } } else { if (i_this->field_0x6ea < 0) { @@ -565,7 +570,7 @@ static void e_yr_path_move(e_yr_class* i_this) { case -1: { i_this->field_0x67d = 1; - point = i_this->field_0x6ec->m_points; + point = i_this->ppd->m_points; point = &point[i_this->field_0x6ea]; if (i_this->field_0x6f0 != 0) { @@ -623,7 +628,7 @@ static void e_yr_path_move(e_yr_class* i_this) { } if (dist < 10.0f * TREG_F(10) + 300.0f) { i_this->field_0x67d = 0; - point = i_this->field_0x6ec->m_points; + point = i_this->ppd->m_points; point = &point[i_this->field_0x6ea]; if (point->mArg0 == 5) { i_this->field_0x66c = 1; @@ -682,11 +687,11 @@ static void e_yr_path_move(e_yr_class* i_this) { unkChar1 = 1; if (i_this->field_0x6a4[2] == 0) { i_this->field_0x6ea++; - if (i_this->field_0x6ea >= i_this->field_0x6ec->m_num) { + if (i_this->field_0x6ea >= i_this->ppd->m_num) { i_this->field_0x6ea = 0; } - point = i_this->field_0x6ec->m_points; + point = i_this->ppd->m_points; point = &point[i_this->field_0x6ea]; i_this->field_0x680.x = point->m_position.x; i_this->field_0x680.y = point->m_position.y; @@ -719,7 +724,7 @@ static void e_yr_path_move(e_yr_class* i_this) { zDiff = i_this->field_0x680.z - actor->current.pos.z; if (JMAFastSqrt(xDiff * xDiff + zDiff * zDiff) < 50.0f) { i_this->field_0x67d = 22; - point = i_this->field_0x6ec->m_points; + point = i_this->ppd->m_points; point = &point[i_this->field_0x6ea]; if (point->mArg0 == 3) { i_this->field_0x6a4[2] = cM_rndF(50.0f) + 50.0f; @@ -806,9 +811,9 @@ static void e_yr_auto_move(e_yr_class* i_this) { case 0: if (i_this->field_0x6a4[1] == 0) { xDiff = - actor->home.pos.x + cM_rndFX(l_e_yrHIO.field_0xc) - actor->current.pos.x; + actor->home.pos.x + cM_rndFX(l_e_yrHIO.mTurningRadius) - actor->current.pos.x; zDiff = - actor->home.pos.z + cM_rndFX(l_e_yrHIO.field_0xc) - actor->current.pos.z; + actor->home.pos.z + cM_rndFX(l_e_yrHIO.mTurningRadius) - actor->current.pos.z; if (JMAFastSqrt(xDiff * xDiff + zDiff * zDiff) > 200.0f) { i_this->field_0x6a4[1] = cM_rndF(150.0f) + 50.0f; @@ -1102,6 +1107,9 @@ static void e_yr_atack_move(e_yr_class* i_this) { cLib_addCalc2(&actor->current.pos.y, i_this->mAcch.GetGroundH() + 100.0f + TREG_F(17), 0.05f, 5.0f); break; + default: + (void)0; + break; } } @@ -1164,6 +1172,7 @@ static void e_yr_horse_move(e_yr_class* i_this) { f32 horseSpeed = dComIfGp_getHorseActor()->speedF; if (horseSpeed > 60.0f) { + int dummy; // force stack pointer into r31 for debug horseSpeed = 60.0f; } else { if (horseSpeed < 30.0f) { @@ -1303,6 +1312,9 @@ static void e_yr_horse_move(e_yr_class* i_this) { } break; + default: + (void)0; + break; } if (unkFlag1) { @@ -1526,12 +1538,12 @@ static void e_yr_wait_move(e_yr_class* i_this) { } static void e_yr_su_wait_move(e_yr_class* i_this) { - s32 old_0x6e0; - fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->mEnemy; fopAc_ac_c* playerActor = dComIfGp_getPlayer(0); daPy_py_c* player = (daPy_py_c*)playerActor; + s32 old_0x6e0; + cXyz unkXyz1; cXyz unkXyz2; @@ -1934,8 +1946,7 @@ static void ground_angle_set(e_yr_class* i_this) { dBgS_GndChk gndChk; f32 unkFloat1 = 75.0f; - model = i_this->mpMorfSO->getModel(); - MTXCopy(model->getAnmMtx(0), *calc_mtx); + MTXCopy(i_this->mpMorfSO->getModel()->getAnmMtx(0), *calc_mtx); unkXyz1.set(0.0f, 0.0f, 0.0f); MtxPosition(&unkXyz1, &unkXyz3); @@ -2009,9 +2020,12 @@ static void ground_angle_set(e_yr_class* i_this) { cLib_addCalcAngleS2(&i_this->field_0x6f8.z, unkShort1, 1, 0x400); } -static int daE_Yr_Execute(e_yr_class* i_this) { +// stripped function, inferred from its local static variable (which is not stripped) +static inline void wing_smoke_set(e_yr_class* i_this) { static s32 wing_j[4] = {12, 13, 17, 18}; +} +static int daE_Yr_Execute(e_yr_class* i_this) { fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->mEnemy; fopAc_ac_c* playerActor = dComIfGp_getPlayer(0); @@ -2456,6 +2470,8 @@ static int daE_Yr_Create(fopAc_ac_c* i_this) { fopAcM_ct(i_this, e_yr_class); if (loadResult == cPhs_COMPLEATE_e) { + int dummy; // force stack pointer into r31 for debug + // "It won't reset because it's already been defeated" OS_REPORT("PARAM %x\n", fopAcM_GetParam(i_this)); @@ -2485,8 +2501,8 @@ static int daE_Yr_Create(fopAc_ac_c* i_this) { i_this->home.pos = i_this->current.pos; if (yr->field_0x666 != 0xff) { - yr->field_0x6ec = dPath_GetRoomPath(yr->field_0x666, fopAcM_GetRoomNo(i_this)); - if (yr->field_0x6ec == 0) { + yr->ppd = dPath_GetRoomPath(yr->field_0x666, fopAcM_GetRoomNo(i_this)); + if (yr->ppd == 0) { return cPhs_ERROR_e; } diff --git a/src/d/actor/d_a_kago.cpp b/src/d/actor/d_a_kago.cpp index 29d063e09c..9f85b227ef 100644 --- a/src/d/actor/d_a_kago.cpp +++ b/src/d/actor/d_a_kago.cpp @@ -234,10 +234,10 @@ int daKago_c::executeBalloonMenu() { fopAcM_orderPotentialEvent(this, 1, 0xffff, 0); eventInfo.onCondition(dEvtCnd_CANDEMO_e); - #if VERSION == VERSION_SHIELD_DEBUG - return 0; - #else + #if PLATFORM_GCN break; + #else + return 0; #endif } @@ -368,7 +368,7 @@ f32 daKago_c::checkGroundHeight(cXyz i_pos, f32* o_step) { gnd_height = gndCrossMag; field_0x6e0 = 1; - if (current.pos.y < gndCrossMag) { + if (current.pos.y < gnd_height) { mGroundHeight = current.pos.y; } else { mGroundHeight = mGroundFlyHeight; @@ -636,24 +636,26 @@ s8 daKago_c::searchNearPassPoint() { cXyz pointPos; cXyz playerPos(daPy_getPlayerActorClass()->current.pos); - f32 prev_nearest_distXZ, nearest_distXZ; - nearest_distXZ = prev_nearest_distXZ = 100000.0f; - int nearest_point_no; + f32 nearest_DistXZ[2]; + nearest_DistXZ[0] = nearest_DistXZ[1] = 100000.0f; + int nearest_point_no[2]; for (int i = 0; i < mpPath1->m_num; i++) { pointPos = dPath_GetPnt(mpPath1, i)->m_position; f32 player_pnt_distXZ = playerPos.absXZ(pointPos); - if (player_pnt_distXZ < nearest_distXZ) { - prev_nearest_distXZ = nearest_distXZ; - nearest_distXZ = player_pnt_distXZ; - nearest_point_no = i; - } else if (player_pnt_distXZ < prev_nearest_distXZ) { - prev_nearest_distXZ = player_pnt_distXZ; + if (player_pnt_distXZ < nearest_DistXZ[0]) { + nearest_DistXZ[1] = nearest_DistXZ[0]; + nearest_point_no[1] = nearest_point_no[0]; + nearest_DistXZ[0] = player_pnt_distXZ; + nearest_point_no[0] = i; + } else if (player_pnt_distXZ < nearest_DistXZ[1]) { + nearest_DistXZ[1] = player_pnt_distXZ; + nearest_point_no[1] = i; } } - int next_point_no = nearest_point_no + mPathStep; + int next_point_no = nearest_point_no[0] + mPathStep; if (next_point_no < 0) { next_point_no = 1; } else if (next_point_no >= mpPath1->m_num) { @@ -1479,13 +1481,16 @@ void daKago_c::executeWait() { setActionMode(ACTION_LANDING_e, 0); executeLanding(); } + + return; } - return; - } #if DEBUG - mPathDir = 1; + mPathDir = 1; +#endif + } +#if DEBUG if (mDoCPd_c::getHoldL(PAD_1) && mDoCPd_c::getHoldR(PAD_1) && mDoCPd_c::getTrigB(PAD_1)) { @@ -1498,9 +1503,10 @@ void daKago_c::executeWait() { if (mSceneType == SCENE_TYPE_RIVER) { createBalloonScore(); - return; } } + + return; } #endif } @@ -2334,6 +2340,7 @@ void daKago_c::initFirstDemo() { cXyz cStack_34; daPy_py_c* player = daPy_getPlayerActorClass(); + s16 targetYaw; s16 playerYaw = player->shape_angle.y; cXyz playerPos = player->current.pos; @@ -2343,7 +2350,6 @@ void daKago_c::initFirstDemo() { midnaPos = midna->current.pos; } - s16 targetYaw; switch (mDemoMode) { case 0: { Z2GetAudioMgr()->setDemoName(mDemoName); @@ -2356,9 +2362,9 @@ void daKago_c::initFirstDemo() { shape_angle.y = current.angle.y = cLib_targetAngleY(&playerPos, &field_0x6a4); cStack_34.set(-300.0f, 400.0f, -1000.0f); cLib_offsetPos(¤t.pos, &playerPos, shape_angle.y, &cStack_34); - targetYaw = cLib_targetAngleY(&playerPos, ¤t.pos); + playerYaw = cLib_targetAngleY(&playerPos, ¤t.pos); - player->setPlayerPosAndAngle(&playerPos, targetYaw, 0); + player->setPlayerPosAndAngle(&playerPos, playerYaw, 0); if (midna != NULL) { midna->current.pos = playerPos; midnaPos = midna->current.pos; @@ -2497,8 +2503,7 @@ bool daKago_c::executeFirstDemo() { cXyz playerPos = player->current.pos; int unkFlag1; - int mode = mDemoMode; // fakematch - switch (mode) { + switch (mDemoMode) { case 0: dComIfGp_getEvent()->setSkipProc(this, DemoSkipCallBack, 2); @@ -2599,7 +2604,7 @@ bool daKago_c::executeFirstDemo() { } break; - case 3: { + case 3: dComIfGp_getEvent()->setSkipProc(this, DemoSkipCallBack, 3); setMidnaTagPos(); @@ -2619,7 +2624,6 @@ bool daKago_c::executeFirstDemo() { } break; - } case 4: dComIfGp_getEvent()->setSkipProc(this, DemoSkipCallBack, 2); @@ -2739,11 +2743,11 @@ bool daKago_c::executeFirstDemo() { case 8: unkFlag1 = 0; - if (mode == 7 || field_0x6e8 == 0) { + if (mDemoMode == 7 || field_0x6e8 == 0) { if (field_0x728 == 110) { unkFlag1 = 1; } - } else if (mode == 8 && field_0x728 == 140) { + } else if (mDemoMode == 8 && field_0x728 == 140) { unkFlag1 = 1; } @@ -3445,6 +3449,8 @@ void daKago_c::setWaterFallEffect() { } static void* s_waterfall(void* i_actor, void* i_data) { + UNUSED(i_data); + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == fpcNm_Tag_WaterFall_e) { if (!fpcM_IsCreating(fopAcM_GetID(i_actor))) { if (((daTagWaterFall_c*)i_actor)->checkHitWaterFall(((fopAc_ac_c*)i_data)->current.pos)) diff --git a/src/d/actor/d_a_mg_rod.cpp b/src/d/actor/d_a_mg_rod.cpp index e44cdfeeff..816deb528e 100644 --- a/src/d/actor/d_a_mg_rod.cpp +++ b/src/d/actor/d_a_mg_rod.cpp @@ -291,9 +291,9 @@ static void rod_control(dmg_rod_class* i_this) { s16 segPitch, segYaw, rodPitchAdj, rodRollAdj; f32 var_f31; - f32 var_f29; f32 var_f26; f32 var_f30; + f32 var_f29; f32 var_f25; rodJointPos = i_this->mg_rod.field_0x0; @@ -4228,7 +4228,9 @@ static void uki_main(dmg_rod_class* i_this) { break; } - if (i_this->rod_substick_y <= -0.5f && (i_this->rod_substick_y - i_this->prev_rod_substick_y) <= -0.5f && i_this->action == ACTION_UKI_STANDBY) { + if (i_this->rod_substick_y <= -0.5f && + i_this->rod_substick_y - i_this->prev_rod_substick_y <= -0.5f && + i_this->action == ACTION_UKI_STANDBY) { if (i_this->is_hook_in_water != 0) { daAlink_getAlinkActorClass()->seStartOnlyReverb(Z2SE_AL_ROD_SWING_LURE); } @@ -4376,7 +4378,7 @@ static void uki_main(dmg_rod_class* i_this) { mDoMtx_stack_c::XrotM(spC); mDoMtx_stack_c::scaleM(l_HIO.field_0xc, l_HIO.field_0xc, l_HIO.field_0xc); mDoMtx_stack_c::transM(0.0f, 0.0f, l_HIO.field_0x10); - mDoMtx_stack_c::XrotM(XREG_S(8)); + mDoMtx_stack_c::XrotM((s16)XREG_S(8)); i_this->uki_model->setBaseTRMtx(mDoMtx_stack_c::get()); mDoMtx_stack_c::transM(0.0f, 0.0f, l_HIO.field_0x14); @@ -4491,6 +4493,8 @@ static void play_camera(dmg_rod_class* i_this) { f32 sp60; f32 sp5C; camera_class* sp58; + // debug indicates these case bodies are likely unscoped despite containing declarations + // (due to extra an b instruction at the end) switch (i_this->play_cam_mode) { case 0: if (dComIfGp_checkPlayerStatus0(0, 0x2000) || dComIfGp_event_runCheck()) { @@ -4522,7 +4526,7 @@ static void play_camera(dmg_rod_class* i_this) { } } break; - case 1: { + case 1: i_this->play_cam_mode = 2; camera->mCamera.Stop(); i_this->play_cam_timer = 0; @@ -4540,8 +4544,7 @@ static void play_camera(dmg_rod_class* i_this) { camera->mCamera.SetTrimSize(1); i_this->play_cam_fovy = 55.0f; /* fallthrough */ - } - case 2: { + case 2: sp70 = 1; sp6C = 0.3f + NREG_F(3); sp68 = i_this->field_0x1420; @@ -4605,8 +4608,7 @@ static void play_camera(dmg_rod_class* i_this) { i_this->field_0x141a = i_this->field_0x1418 - daAlink_getAlinkActorClass()->getFishingRodAngleY(); i_this->field_0x140c = i_this->play_cam_fovy; break; - } - case 5: { + case 5: sp70 = 1; cLib_addCalc2(&i_this->field_0x141c, 400.0f + BREG_F(7), 0.1f, (20.0f + YREG_F(8)) * i_this->camera_morf_rate); @@ -4735,8 +4737,7 @@ static void play_camera(dmg_rod_class* i_this) { } } break; - } - case 10: { + case 10: cMtx_YrotS(*calc_mtx, player->shape_angle.y); sp174.x = (25.0f + (100.0f + DREG_F(0))) - 50.0f; sp174.y = (10.0f + DREG_F(1)) - 10.0f; @@ -4783,7 +4784,6 @@ static void play_camera(dmg_rod_class* i_this) { } i_this->field_0xf78 = 0.05f; break; - } case 11: cLib_addCalc2(&i_this->play_cam_fovy, 55.0f + DREG_F(6), 0.05f, 1.0f); @@ -5314,10 +5314,12 @@ static void play_camera_u(dmg_rod_class* i_this) { int sp14 = 0; f32 var_f31; + // debug indicates these case bodies are likely unscoped despite containing declarations + // (due to extra an b instruction at the end) switch (i_this->play_cam_mode) { case 0: break; - case 1: { + case 1: i_this->play_cam_mode = 2; camera->mCamera.Stop(); i_this->play_cam_timer = 0; @@ -5330,7 +5332,6 @@ static void play_camera_u(dmg_rod_class* i_this) { i_this->play_cam_eye = sp10->view.lookat.eye; i_this->play_cam_center = sp10->view.lookat.center; i_this->camera_morf_rate = 1000.0f; - } /* fallthrough */ case 2: sp14 = 1; @@ -5493,8 +5494,9 @@ static void play_camera_u(dmg_rod_class* i_this) { cLib_addCalc2(&i_this->play_cam_fovy, 55.0f, 0.1f, 10.0f); break; } + // debug indicates this case body is unscoped despite containing declarations case 20: - case 21: { + case 21: if (!actor->eventInfo.checkCommandDemoAccrpt()) { fopAcM_orderPotentialEvent(actor, 2, 0xFFFF, 0); actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); @@ -5647,8 +5649,8 @@ static void play_camera_u(dmg_rod_class* i_this) { i_this->field_0xf64 = -30.0f; daAlink_getAlinkActorClass()->changeFishGetFace(0); } + (void)0; break; - } case 90: sp18 = 1; break; diff --git a/src/d/actor/d_a_movie_player.cpp b/src/d/actor/d_a_movie_player.cpp index 55cb7525b7..ab32fd4564 100644 --- a/src/d/actor/d_a_movie_player.cpp +++ b/src/d/actor/d_a_movie_player.cpp @@ -524,7 +524,11 @@ static u8 __THPReadHuffmanTableSpecification() { __THPHuffmanCodeTab = (u16*)((u32)__THPWorkArea + 256 + 1); length = (u16)((__THPInfo->c)[0] << 8 | (__THPInfo->c)[1]); __THPInfo->c += 2; +#if PLATFORM_SHIELD + length -= (u16)2; +#else length -= 2; +#endif for (;;) { i = (*(__THPInfo->c)++); @@ -543,8 +547,12 @@ static u8 __THPReadHuffmanTableSpecification() { __THPHuffGenerateSizeTable(); __THPHuffGenerateCodeTable(); __THPHuffGenerateDecoderTables(tab_index); - __THPInfo->validHuffmanTabs |= 1 << tab_index; - length -= 17 + num_Vij; +#if PLATFORM_SHIELD + __THPInfo->validHuffmanTabs |= (u8)(1 << tab_index); +#else + __THPInfo->validHuffmanTabs |= (1 << tab_index); +#endif + U16_SUB_2(length, (17 + num_Vij)); if (length == 0) { break; @@ -1627,7 +1635,7 @@ static void __THPHuffDecodeDCTCompY(__REGISTER THPFileInfo* info, THPCoeff* bloc } if (__cntlzw((u32)diff) > 32 - t) { - diff += ((0xFFFFFFFF << t) + 1); + S16_ADD_2(diff, (0xFFFFFFFF << t) + 1); } }; @@ -2331,7 +2339,7 @@ static void __THPHuffDecodeDCTCompU(__REGISTER THPFileInfo* info, THPCoeff* bloc ASSERTLINE(5070, info->cnt <=33); if (__cntlzw((u32)diff) > 32 - t) { - diff += ((0xFFFFFFFF << t) + 1); + S16_ADD_2(diff, (0xFFFFFFFF << t) + 1); } } @@ -2475,7 +2483,7 @@ static void __THPHuffDecodeDCTCompV(__REGISTER THPFileInfo* info, THPCoeff* bloc ASSERTLINE(5255, info->cnt <=33); if (__cntlzw((u32)diff) > 32 - t) { - diff += ((0xFFFFFFFF << t) + 1); + S16_ADD_2(diff, (0xFFFFFFFF << t) + 1); } } diff --git a/src/d/actor/d_a_npc_aru.cpp b/src/d/actor/d_a_npc_aru.cpp index 2c8705ab0d..51c3cf14b8 100644 --- a/src/d/actor/d_a_npc_aru.cpp +++ b/src/d/actor/d_a_npc_aru.cpp @@ -1258,6 +1258,7 @@ void daNpc_Aru_c::adjustMoveDir() { } } + s16 sVar4; if (bVar1[1] != 0 && bVar1[2] != 0) { mTimer = mpHIO->m.no_turn_time; @@ -1294,7 +1295,7 @@ void daNpc_Aru_c::adjustMoveDir() { field_0xfca = 2; } } else { - s16 sVar4 = sVar3[0] - mCurAngle.y; + sVar4 = sVar3[0] - mCurAngle.y; if (abs(sVar4) > 0x7800) { if (mActorDirection == 1 || mActorDirection == 2 || mActorDirection == 3) { diff --git a/src/d/actor/d_a_npc_cdn3.cpp b/src/d/actor/d_a_npc_cdn3.cpp index a309d97c7c..8d63fa1347 100644 --- a/src/d/actor/d_a_npc_cdn3.cpp +++ b/src/d/actor/d_a_npc_cdn3.cpp @@ -368,231 +368,80 @@ void daNpcCdn3_c::initEscape() { dComIfGs_onSaveDunSwitch(0x3c); } -daNpcCdn3_c::seqFunc* daNpcCdn3_c::m_funcTbl[44] = { - m_seq00_funcTbl, m_seq01_funcTbl, - m_seq02_funcTbl, m_seq03_funcTbl, - m_seq04_funcTbl, m_seq05_funcTbl, - m_seq06_funcTbl, m_seq07_funcTbl, - m_seq08_funcTbl, m_seq09_funcTbl, - m_seq10_funcTbl, m_seq11_funcTbl, - m_seq12_funcTbl, m_seq13_funcTbl, - m_seq14_funcTbl, m_seq15_funcTbl, - m_seq16_funcTbl, m_seq17_funcTbl, - m_seq18_funcTbl, m_seq19_funcTbl, - m_seq20_funcTbl, m_seq21_funcTbl, - m_seq22_funcTbl, m_seq23_funcTbl, - m_seq24_funcTbl, m_seq25_funcTbl, - m_seq26_funcTbl, m_seq27_funcTbl, - m_seq28_funcTbl, m_seq29_funcTbl, - m_seq30_funcTbl, m_seq31_funcTbl, - m_seq32_funcTbl, m_seq33_funcTbl, - m_seq34_funcTbl, m_seq35_funcTbl, - m_seq36_funcTbl, m_seq37_funcTbl, - m_seq38_funcTbl, m_seq39_funcTbl, - m_seq40_funcTbl, m_seq41_funcTbl, - m_seq42_funcTbl, m_seq43_funcTbl, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq00_funcTbl[2] = {&daNpcCdn3_c::walka, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq01_funcTbl[2] = {&daNpcCdn3_c::runa, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq02_funcTbl[2] = {&daNpcCdn3_c::waita, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq03_funcTbl[2] = {&daNpcCdn3_c::talka, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq04_funcTbl[2] = {&daNpcCdn3_c::runb, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq05_funcTbl[4] = {&daNpcCdn3_c::turnr, &daNpcCdn3_c::waita, - &daNpcCdn3_c::talka, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq06_funcTbl[4] = {&daNpcCdn3_c::turnl, &daNpcCdn3_c::waita, - &daNpcCdn3_c::talka, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq07_funcTbl[2] = {&daNpcCdn3_c::waitwall, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq08_funcTbl[7] = { - &daNpcCdn3_c::talkwall, - &daNpcCdn3_c::waitwall, - &daNpcCdn3_c::talkbwall, - &daNpcCdn3_c::waitwall, - &daNpcCdn3_c::talkwall, - &daNpcCdn3_c::talkbwall, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq09_funcTbl[2] = {&daNpcCdn3_c::talkb, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq10_funcTbl[2] = {&daNpcCdn3_c::talkc, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq11_funcTbl[6] = {&daNpcCdn3_c::talka, &daNpcCdn3_c::waita, - &daNpcCdn3_c::talkb, &daNpcCdn3_c::waitb, - &daNpcCdn3_c::talkc, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq12_funcTbl[2] = {&daNpcCdn3_c::waitb, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq13_funcTbl[6] = { - &daNpcCdn3_c::browsea, &daNpcCdn3_c::browseb, &daNpcCdn3_c::talka, - &daNpcCdn3_c::talkb, &daNpcCdn3_c::waita, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq14_funcTbl[2] = {&daNpcCdn3_c::walkb, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq15_funcTbl[2] = {&daNpcCdn3_c::sitwaita, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq16_funcTbl[7] = { - &daNpcCdn3_c::sittalka, - &daNpcCdn3_c::sitwaita, - &daNpcCdn3_c::sittalkab, - &daNpcCdn3_c::sitwaita, - &daNpcCdn3_c::sittalka, - &daNpcCdn3_c::sittalkab, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq17_funcTbl[2] = { - &daNpcCdn3_c::playm, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq18_funcTbl[2] = {&daNpcCdn3_c::sitwaitb, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq19_funcTbl[7] = { - &daNpcCdn3_c::sittalkb, - &daNpcCdn3_c::sitwaitb, - &daNpcCdn3_c::sittalkbb, - &daNpcCdn3_c::sitwaitb, - &daNpcCdn3_c::sittalkb, - &daNpcCdn3_c::sittalkbb, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq20_funcTbl[2] = {&daNpcCdn3_c::looka, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq21_funcTbl[2] = {&daNpcCdn3_c::lookb, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq22_funcTbl[4] = {&daNpcCdn3_c::looka, &daNpcCdn3_c::lookb, - &daNpcCdn3_c::waita, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq23_funcTbl[7] = { - &daNpcCdn3_c::talka, - &daNpcCdn3_c::waita, - &daNpcCdn3_c::talkb, - &daNpcCdn3_c::waita, - &daNpcCdn3_c::talka, - &daNpcCdn3_c::talkb, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq24_funcTbl[5] = { - &daNpcCdn3_c::talkb, &daNpcCdn3_c::talka, &daNpcCdn3_c::talkc, &daNpcCdn3_c::waita, NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq25_funcTbl[7] = { - &daNpcCdn3_c::browsea, - &daNpcCdn3_c::browseb, - &daNpcCdn3_c::talka, - &daNpcCdn3_c::talkb, - &daNpcCdn3_c::talkc, - &daNpcCdn3_c::waita, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq26_funcTbl[3] = { - &daNpcCdn3_c::browsea, - &daNpcCdn3_c::browseb, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq27_funcTbl[2] = {&daNpcCdn3_c::dance, NULL}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq28_funcTbl[3] = { - &daNpcCdn3_c::ladytalka, - &daNpcCdn3_c::normtalka, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq29_funcTbl[3] = { - &daNpcCdn3_c::ladytalkb, - &daNpcCdn3_c::normtalkb, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq30_funcTbl[6] = { - &daNpcCdn3_c::talka, &daNpcCdn3_c::ladytalka, &daNpcCdn3_c::waita, - &daNpcCdn3_c::talkb, &daNpcCdn3_c::waita, NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq31_funcTbl[6] = { - &daNpcCdn3_c::waita, &daNpcCdn3_c::ladytalkb, &daNpcCdn3_c::talka, - &daNpcCdn3_c::waita, &daNpcCdn3_c::talkb, NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq32_funcTbl[7] = { - &daNpcCdn3_c::talka, - &daNpcCdn3_c::ladytalka, - &daNpcCdn3_c::waita, - &daNpcCdn3_c::talkb, - &daNpcCdn3_c::waita, - &daNpcCdn3_c::normtalka, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq33_funcTbl[7] = { - &daNpcCdn3_c::waita, - &daNpcCdn3_c::ladytalkb, - &daNpcCdn3_c::talka, - &daNpcCdn3_c::waita, - &daNpcCdn3_c::talkb, - &daNpcCdn3_c::normtalkb, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq34_funcTbl[9] = { - &daNpcCdn3_c::talka, &daNpcCdn3_c::ladytalka, &daNpcCdn3_c::ladytalkb, - &daNpcCdn3_c::waita, &daNpcCdn3_c::talkb, &daNpcCdn3_c::waita, - &daNpcCdn3_c::normtalka, &daNpcCdn3_c::normtalkb, NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq35_funcTbl[2] = { - &daNpcCdn3_c::sellme, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq36_funcTbl[4] = { - &daNpcCdn3_c::ladytalkb, - &daNpcCdn3_c::talka, - &daNpcCdn3_c::waita, - NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq37_funcTbl[2] = { - &daNpcCdn3_c::sing, NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq38_funcTbl[2] = { - &daNpcCdn3_c::sittalka, NULL, -}; - -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq39_funcTbl[2] = { - &daNpcCdn3_c::sittalkab, NULL, -}; +inline int daNpcCdn3_c::create() { + fopAcM_ct(this, daNpcCdn3_c); + mIsDarkWorld = dKy_darkworld_check(); + m_type = getType(); + mObjNum = getObjNum(); + m_seqNum = getSeqNum(); + mFlowNodeNum = getFlowNodeNum(); + if (m_seqNum < 0 || 44 <= m_seqNum) { + // "Castle town townspeople map tool setting error + // Argument 1 motion sequence = %d is abnormal" + OSReport_Error("城下町の町人 マップツール設定値異常 引数1モーションシーケンス=%dが異常です。\n", m_seqNum); + JUT_ASSERT(175, FALSE); + } + int rv = loadResrc(m_type, mObjNum); + if (rv == cPhs_COMPLEATE_e) { + int heapSize = 0x2890; +#if DEBUG + heapSize |= fopAcM::HeapSkipMargin; +#else + heapSize |= 0x80000000; +#endif + if (fopAcM_entrySolidHeap(this, createHeapCallBack, heapSize) == 0) { + // "Actor creation failed!" + OS_REPORT("アクター生成失敗しました!\n"); + return cPhs_ERROR_e; + } + create_init(); + } + return rv; +} -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq40_funcTbl[3] = { - &daNpcCdn3_c::sittalka, &daNpcCdn3_c::sittalkab, NULL, -}; +inline void daNpcCdn3_c::create_init() { +#if DEBUG + // "NPC(C class,D class)HighPoly" + l_Cd2_HIO.entryHIO("NPC(C級,D級)HighPoly"); +#endif -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq41_funcTbl[2] = { - &daNpcCdn3_c::sittalkb, NULL, -}; + gravity = -3.0f; + initTimeSchedule(); + fopAcM_SetMtx(this, mpMorf->getModel()->getBaseTRMtx()); + fopAcM_setCullSizeBox(this, -40.0f, -10.0f, -40.0f, 40.0f, 190.0f, 40.0f); + mAcchCir.SetWall(Cd2_HIO_chkWallH(m_type), Cd2_HIO_chkWallR(m_type)); + mAcch.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, + fopAcM_GetSpeed_p(this), fopAcM_GetAngle_p(this), fopAcM_GetShapeAngle_p(this)); + mAcch.SetRoofNone(); + mAcch.SetWaterNone(); + mAcch.CrrPos(dComIfG_Bgsp()); + setEnvTevCol(); + setRoomNo(); + initCollision(); + if (strcmp(dComIfGp_getStartStageName(), "F_SP116") == 0 && + dComIfGp_getStartStageRoomNo() == 3 && getType() == 7) + { + attention_info.distances[fopAc_attn_SPEAK_e] = 0xda; + attention_info.distances[fopAc_attn_TALK_e] = 0xda; + } else { + attention_info.distances[fopAc_attn_SPEAK_e] = 0xd9; + attention_info.distances[fopAc_attn_TALK_e] = 0xd9; + } -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq42_funcTbl[2] = { - &daNpcCdn3_c::sittalkbb, NULL, + if (isInShop()) { + fopAcM_OnStatus(this, fopAcStts_UNK_0x4000_e); + } -}; + if (m_path.setPath(getPathID(), fopAcM_GetRoomNo(this), 1, ¤t.pos, false)) { + setAction(MODE_PATH); + } else { + setAction(MODE_WAIT); + } -daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq43_funcTbl[3] = { - &daNpcCdn3_c::sittalkb, &daNpcCdn3_c::sittalkbb, NULL, -}; + mpMorf->setMorf(0.0f); + field_0xb64 = current.pos.y = mAcch.GetGroundH(); + setMtx(); +} void daNpcCdn3_c::executeEscape() { if (field_0xb68 == 0) { @@ -1005,11 +854,19 @@ void daNpcCdn3_c::setSchedule(daTagSchedule_c* param_1) { } inline bool daNpcCdn3_c::isInShop() { - u8 rv = FALSE; - if (strcmp(dComIfGp_getStartStageName(), "R_SP160") == 0 && dComIfG_play_c::getLayerNo(0) <= 1) { - rv = TRUE; + return (bool)(strcmp(dComIfGp_getStartStageName(), "R_SP160") == 0 && dComIfG_play_c::getLayerNo(0) <= 1); +} + +inline bool daNpcCdn3_c::isOrchestra() { + if (strcmp(dComIfGp_getStartStageName(), "F_SP116") != 0) { + return false; + } else if (m_seqNum == 17 && (getType() == 4 || getType() == 5 || getType() == 6 || getType() == 16)) { + return true; + } else if (m_seqNum == 37 && getType() == 7) { + return true; + } else { + return false; } - return rv; } bool daNpcCdn3_c::isChairStyle() { @@ -1456,74 +1313,6 @@ int daNpcCdn3_c::sing(void* param_0) { return field_0xaa0 == 0; } -int daNpcCdn3_c::create() { - fopAcM_ct(this, daNpcCdn3_c); - mIsDarkWorld = dKy_darkworld_check(); - m_type = getType(); - mObjNum = getObjNum(); - m_seqNum = getSeqNum(); - mFlowNodeNum = getFlowNodeNum(); - if (m_seqNum < 0 || 44 <= m_seqNum) { - OSReport_Error("城下町の町人 マップツール設定値異常 引数1モーションシーケンス=%dが異常です。\n", m_seqNum); - JUT_ASSERT(175, FALSE); - } - int rv = loadResrc(m_type, mObjNum); - if (rv == cPhs_COMPLEATE_e) { - int msb = 0x80000000; - int heapSize = 0x2890; - heapSize |= msb; - if (fopAcM_entrySolidHeap(this, createHeapCallBack, heapSize) == 0) { - OS_REPORT("アクター生成失敗しました!\n"); - return cPhs_ERROR_e; - } - create_init(); - } - return rv; -} - -void daNpcCdn3_c::create_init() { -#if DEBUG - l_Cd2_HIO.entryHIO("NPC(C級,D級)HighPoly"); -#endif - - gravity = -3.0f; - initTimeSchedule(); - fopAcM_SetMtx(this, mpMorf->getModel()->getBaseTRMtx()); - fopAcM_setCullSizeBox(this, -40.0f, -10.0f, -40.0f, 40.0f, 190.0f, 40.0f); - mAcchCir.SetWall(Cd2_HIO_chkWallH(m_type), Cd2_HIO_chkWallR(m_type)); - mAcch.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, - fopAcM_GetSpeed_p(this), fopAcM_GetAngle_p(this), fopAcM_GetShapeAngle_p(this)); - mAcch.SetRoofNone(); - mAcch.SetWaterNone(); - mAcch.CrrPos(dComIfG_Bgsp()); - setEnvTevCol(); - setRoomNo(); - initCollision(); - if (strcmp(dComIfGp_getStartStageName(), "F_SP116") == 0 && - dComIfGp_getStartStageRoomNo() == 3 && getType() == 7) - { - attention_info.distances[fopAc_attn_SPEAK_e] = 0xda; - attention_info.distances[fopAc_attn_TALK_e] = 0xda; - } else { - attention_info.distances[fopAc_attn_SPEAK_e] = 0xd9; - attention_info.distances[fopAc_attn_TALK_e] = 0xd9; - } - - if (isInShop()) { - fopAcM_OnStatus(this, fopAcStts_UNK_0x4000_e); - } - - if (m_path.setPath(getPathID(), fopAcM_GetRoomNo(this), 1, ¤t.pos, false)) { - setAction(MODE_PATH); - } else { - setAction(MODE_WAIT); - } - - mpMorf->setMorf(0.0f); - field_0xb64 = current.pos.y = mAcch.GetGroundH(); - setMtx(); -} - void daNpcCdn3_c::setMtx() { mDoMtx_stack_c::transS(current.pos.x, field_0xb64, current.pos.z); mDoMtx_stack_c::YrotM(shape_angle.y); @@ -1711,6 +1500,232 @@ inline int daNpcCdn3_c::draw() { return 1; } +daNpcCdn3_c::seqFunc* daNpcCdn3_c::m_funcTbl[44] = { + m_seq00_funcTbl, m_seq01_funcTbl, + m_seq02_funcTbl, m_seq03_funcTbl, + m_seq04_funcTbl, m_seq05_funcTbl, + m_seq06_funcTbl, m_seq07_funcTbl, + m_seq08_funcTbl, m_seq09_funcTbl, + m_seq10_funcTbl, m_seq11_funcTbl, + m_seq12_funcTbl, m_seq13_funcTbl, + m_seq14_funcTbl, m_seq15_funcTbl, + m_seq16_funcTbl, m_seq17_funcTbl, + m_seq18_funcTbl, m_seq19_funcTbl, + m_seq20_funcTbl, m_seq21_funcTbl, + m_seq22_funcTbl, m_seq23_funcTbl, + m_seq24_funcTbl, m_seq25_funcTbl, + m_seq26_funcTbl, m_seq27_funcTbl, + m_seq28_funcTbl, m_seq29_funcTbl, + m_seq30_funcTbl, m_seq31_funcTbl, + m_seq32_funcTbl, m_seq33_funcTbl, + m_seq34_funcTbl, m_seq35_funcTbl, + m_seq36_funcTbl, m_seq37_funcTbl, + m_seq38_funcTbl, m_seq39_funcTbl, + m_seq40_funcTbl, m_seq41_funcTbl, + m_seq42_funcTbl, m_seq43_funcTbl, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq00_funcTbl[2] = {&daNpcCdn3_c::walka, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq01_funcTbl[2] = {&daNpcCdn3_c::runa, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq02_funcTbl[2] = {&daNpcCdn3_c::waita, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq03_funcTbl[2] = {&daNpcCdn3_c::talka, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq04_funcTbl[2] = {&daNpcCdn3_c::runb, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq05_funcTbl[4] = {&daNpcCdn3_c::turnr, &daNpcCdn3_c::waita, + &daNpcCdn3_c::talka, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq06_funcTbl[4] = {&daNpcCdn3_c::turnl, &daNpcCdn3_c::waita, + &daNpcCdn3_c::talka, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq07_funcTbl[2] = {&daNpcCdn3_c::waitwall, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq08_funcTbl[7] = { + &daNpcCdn3_c::talkwall, + &daNpcCdn3_c::waitwall, + &daNpcCdn3_c::talkbwall, + &daNpcCdn3_c::waitwall, + &daNpcCdn3_c::talkwall, + &daNpcCdn3_c::talkbwall, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq09_funcTbl[2] = {&daNpcCdn3_c::talkb, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq10_funcTbl[2] = {&daNpcCdn3_c::talkc, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq11_funcTbl[6] = {&daNpcCdn3_c::talka, &daNpcCdn3_c::waita, + &daNpcCdn3_c::talkb, &daNpcCdn3_c::waitb, + &daNpcCdn3_c::talkc, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq12_funcTbl[2] = {&daNpcCdn3_c::waitb, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq13_funcTbl[6] = { + &daNpcCdn3_c::browsea, &daNpcCdn3_c::browseb, &daNpcCdn3_c::talka, + &daNpcCdn3_c::talkb, &daNpcCdn3_c::waita, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq14_funcTbl[2] = {&daNpcCdn3_c::walkb, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq15_funcTbl[2] = {&daNpcCdn3_c::sitwaita, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq16_funcTbl[7] = { + &daNpcCdn3_c::sittalka, + &daNpcCdn3_c::sitwaita, + &daNpcCdn3_c::sittalkab, + &daNpcCdn3_c::sitwaita, + &daNpcCdn3_c::sittalka, + &daNpcCdn3_c::sittalkab, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq17_funcTbl[2] = { + &daNpcCdn3_c::playm, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq18_funcTbl[2] = {&daNpcCdn3_c::sitwaitb, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq19_funcTbl[7] = { + &daNpcCdn3_c::sittalkb, + &daNpcCdn3_c::sitwaitb, + &daNpcCdn3_c::sittalkbb, + &daNpcCdn3_c::sitwaitb, + &daNpcCdn3_c::sittalkb, + &daNpcCdn3_c::sittalkbb, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq20_funcTbl[2] = {&daNpcCdn3_c::looka, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq21_funcTbl[2] = {&daNpcCdn3_c::lookb, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq22_funcTbl[4] = {&daNpcCdn3_c::looka, &daNpcCdn3_c::lookb, + &daNpcCdn3_c::waita, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq23_funcTbl[7] = { + &daNpcCdn3_c::talka, + &daNpcCdn3_c::waita, + &daNpcCdn3_c::talkb, + &daNpcCdn3_c::waita, + &daNpcCdn3_c::talka, + &daNpcCdn3_c::talkb, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq24_funcTbl[5] = { + &daNpcCdn3_c::talkb, &daNpcCdn3_c::talka, &daNpcCdn3_c::talkc, &daNpcCdn3_c::waita, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq25_funcTbl[7] = { + &daNpcCdn3_c::browsea, + &daNpcCdn3_c::browseb, + &daNpcCdn3_c::talka, + &daNpcCdn3_c::talkb, + &daNpcCdn3_c::talkc, + &daNpcCdn3_c::waita, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq26_funcTbl[3] = { + &daNpcCdn3_c::browsea, + &daNpcCdn3_c::browseb, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq27_funcTbl[2] = {&daNpcCdn3_c::dance, NULL}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq28_funcTbl[3] = { + &daNpcCdn3_c::ladytalka, + &daNpcCdn3_c::normtalka, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq29_funcTbl[3] = { + &daNpcCdn3_c::ladytalkb, + &daNpcCdn3_c::normtalkb, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq30_funcTbl[6] = { + &daNpcCdn3_c::talka, &daNpcCdn3_c::ladytalka, &daNpcCdn3_c::waita, + &daNpcCdn3_c::talkb, &daNpcCdn3_c::waita, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq31_funcTbl[6] = { + &daNpcCdn3_c::waita, &daNpcCdn3_c::ladytalkb, &daNpcCdn3_c::talka, + &daNpcCdn3_c::waita, &daNpcCdn3_c::talkb, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq32_funcTbl[7] = { + &daNpcCdn3_c::talka, + &daNpcCdn3_c::ladytalka, + &daNpcCdn3_c::waita, + &daNpcCdn3_c::talkb, + &daNpcCdn3_c::waita, + &daNpcCdn3_c::normtalka, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq33_funcTbl[7] = { + &daNpcCdn3_c::waita, + &daNpcCdn3_c::ladytalkb, + &daNpcCdn3_c::talka, + &daNpcCdn3_c::waita, + &daNpcCdn3_c::talkb, + &daNpcCdn3_c::normtalkb, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq34_funcTbl[9] = { + &daNpcCdn3_c::talka, &daNpcCdn3_c::ladytalka, &daNpcCdn3_c::ladytalkb, + &daNpcCdn3_c::waita, &daNpcCdn3_c::talkb, &daNpcCdn3_c::waita, + &daNpcCdn3_c::normtalka, &daNpcCdn3_c::normtalkb, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq35_funcTbl[2] = { + &daNpcCdn3_c::sellme, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq36_funcTbl[4] = { + &daNpcCdn3_c::ladytalkb, + &daNpcCdn3_c::talka, + &daNpcCdn3_c::waita, + NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq37_funcTbl[2] = { + &daNpcCdn3_c::sing, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq38_funcTbl[2] = { + &daNpcCdn3_c::sittalka, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq39_funcTbl[2] = { + &daNpcCdn3_c::sittalkab, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq40_funcTbl[3] = { + &daNpcCdn3_c::sittalka, &daNpcCdn3_c::sittalkab, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq41_funcTbl[2] = { + &daNpcCdn3_c::sittalkb, NULL, +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq42_funcTbl[2] = { + &daNpcCdn3_c::sittalkbb, NULL, + +}; + +daNpcCdn3_c::seqFunc daNpcCdn3_c::m_seq43_funcTbl[3] = { + &daNpcCdn3_c::sittalkb, &daNpcCdn3_c::sittalkbb, NULL, +}; + static int daNpcCdn3_Create(void* i_this) { return static_cast<daNpcCdn3_c*>(i_this)->create(); } diff --git a/src/d/actor/d_a_npc_chin.cpp b/src/d/actor/d_a_npc_chin.cpp index c362c718ea..f6f28ec2e8 100644 --- a/src/d/actor/d_a_npc_chin.cpp +++ b/src/d/actor/d_a_npc_chin.cpp @@ -150,6 +150,9 @@ daNpcChin_HIO_c::daNpcChin_HIO_c() { m = daNpcChin_Param_c::m; } +daNpcChin_HIO_c::~daNpcChin_HIO_c() { +} + void daNpcChin_HIO_c::genMessage(JORMContext* ctx) { daNpcF_commonGenMessage(ctx, &m.common); } @@ -1216,9 +1219,9 @@ bool daNpcChin_c::wait(void* param_0) { u16 eventMask = 0xffff; if (mOrderEvtNo == EVT_CHIN_APPEAR) { - // maybe fakematch? this still doesn't quite match for debug but it's closer + //TODO: maybe fakematch? #if PLATFORM_SHIELD - eventMask = eventMask & 0xff7f; + eventMask &= (u16)~0x80; #else eventMask &= ~0x80; #endif @@ -1360,6 +1363,8 @@ bool daNpcChin_c::demo(void* param_0) { Event_DT(); } + (void)0; + break; } default: { @@ -1434,6 +1439,8 @@ bool daNpcChin_c::watch_game(void* param_0) { } } + (void)0; + break; } default: { diff --git a/src/d/actor/d_a_npc_du.cpp b/src/d/actor/d_a_npc_du.cpp index 5a605916f6..7d62813ac7 100644 --- a/src/d/actor/d_a_npc_du.cpp +++ b/src/d/actor/d_a_npc_du.cpp @@ -98,13 +98,15 @@ static void anm_init(npc_du_class* i_this, int i_index, f32 i_morf, u8 i_mode, f static int nodeCallBack(J3DJoint* i_joint, int param_2) { if (param_2 == 0) { - int jntNo = i_joint->getJntNo(); + J3DJoint* joint = i_joint; + int jntNo = joint->getJntNo(); J3DModel* model = j3dSys.getModel(); npc_du_class* actor = (npc_du_class*)model->getUserArea(); + npc_du_class* actor_copy = actor; if (actor != NULL) { if (jntNo == JNT_NECK2) { MTXCopy(model->getAnmMtx(jntNo), *calc_mtx); - + cMtx_XrotM(*calc_mtx, actor->mNeck2XRot); model->setAnmMtx(jntNo, *calc_mtx); @@ -600,8 +602,8 @@ static int daNpc_Du_Delete(npc_du_class* i_this) { return 1; } -static int useHeapInit(fopAc_ac_c* actor) { - npc_du_class* i_this = (npc_du_class*)actor; +static int useHeapInit(fopAc_ac_c* i_actor) { + npc_du_class* i_this = (npc_du_class*)i_actor; i_this->mpMorf = new mDoExt_McaMorf((J3DModelData*)dComIfG_getObjectRes("Npc_Du", 0xA), NULL, NULL, (J3DAnmTransform*)dComIfG_getObjectRes("Npc_Du", 6), 0, 1.0f, 0, -1, 1, NULL, @@ -611,7 +613,7 @@ static int useHeapInit(fopAc_ac_c* actor) { } J3DModel* model = i_this->mpMorf->getModel(); - model->setUserArea((uintptr_t)actor); + model->setUserArea((uintptr_t)i_this); for (u16 i = 0; i < model->getModelData()->getJointNum(); i++) { model->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack); } @@ -632,45 +634,45 @@ static int useHeapInit(fopAc_ac_c* actor) { return 1; } -static cPhs_Step daNpc_Du_Create(fopAc_ac_c* a_this) { - npc_du_class* i_this = (npc_du_class*)a_this; - fopAcM_ct(a_this, npc_du_class); +static cPhs_Step daNpc_Du_Create(fopAc_ac_c* i_this) { + npc_du_class* du = (npc_du_class*)i_this; + fopAcM_ct(&du->actor, npc_du_class); - cPhs_Step phase = dComIfG_resLoad(&i_this->mPhase, "Npc_Du"); + cPhs_Step phase = dComIfG_resLoad(&du->mPhase, "Npc_Du"); if (phase == cPhs_COMPLEATE_e) { - OS_REPORT("NPC_DU PARAM %x\n", fopAcM_GetParam(a_this)); - i_this->arg0 = fopAcM_GetParam(a_this); - i_this->arg1 = (fopAcM_GetParam(a_this) & 0xFF00) >> 8; - i_this->mMsgFNo = a_this->current.angle.x; - a_this->current.angle.x = a_this->shape_angle.x = 0; - - if (i_this->arg0 == 1) { - i_this->mMsgFNo = 0x2EF; + OS_REPORT("NPC_DU PARAM %x\n", fopAcM_GetParam(i_this)); + du->arg0 = fopAcM_GetParam(i_this); + du->arg1 = (fopAcM_GetParam(i_this) & 0xFF00) >> 8; + du->mMsgFNo = i_this->current.angle.x; + i_this->current.angle.x = i_this->shape_angle.x = 0; + + if (du->arg0 == 1) { + du->mMsgFNo = 0x2EF; } else { - i_this->mMsgFNo = 0x2F0; + du->mMsgFNo = 0x2F0; } OS_REPORT("NPC_DU//////////////NPC_DU SET 1 !!\n"); - if (!fopAcM_entrySolidHeap(a_this, useHeapInit, 0x1280)) { + if (!fopAcM_entrySolidHeap(i_this, useHeapInit, 0x1280)) { OS_REPORT("//////////////NPC_DU SET NON !!\n"); return cPhs_ERROR_e; } OS_REPORT("//////////////NPC_DU SET 2 !!\n"); if (!hio_set) { - i_this->mIsFirstSpawn = 1; + du->mIsFirstSpawn = 1; hio_set = true; l_HIO.id = mDoHIO_CREATE_CHILD("アヒル", &l_HIO); } - i_this->mAction = ACTION_NORMAL; + du->mAction = ACTION_NORMAL; - fopAcM_SetMtx(a_this, i_this->mpMorf->getModel()->getBaseTRMtx()); - i_this->mBgc.Set(fopAcM_GetPosition_p(a_this), fopAcM_GetOldPosition_p(a_this), a_this, 1, &i_this->mAcchCir, - fopAcM_GetSpeed_p(a_this), NULL, NULL); - i_this->mAcchCir.SetWall(20.0f, 25.0f); - i_this->mStts.Init(100, 0, a_this); + fopAcM_SetMtx(i_this, du->mpMorf->getModel()->getBaseTRMtx()); + du->mBgc.Set(fopAcM_GetPosition_p(i_this), fopAcM_GetOldPosition_p(i_this), i_this, 1, &du->mAcchCir, + fopAcM_GetSpeed_p(i_this), NULL, NULL); + du->mAcchCir.SetWall(20.0f, 25.0f); + du->mStts.Init(100, 0, i_this); static dCcD_SrcSph cc_sph_src = { { @@ -684,11 +686,11 @@ static cPhs_Step daNpc_Du_Create(fopAc_ac_c* a_this) { } // mSphAttr }; - i_this->mSph.Set(cc_sph_src); - i_this->mSph.SetStts(&i_this->mStts); - i_this->mFrameCounter = cM_rndF(65536.0f); - a_this->gravity = -5.0f; - daNpc_Du_Execute(i_this); + du->mSph.Set(cc_sph_src); + du->mSph.SetStts(&du->mStts); + du->mFrameCounter = cM_rndF(65536.0f); + i_this->gravity = -5.0f; + daNpc_Du_Execute(du); } return phase; diff --git a/src/d/actor/d_a_obj_movebox.cpp b/src/d/actor/d_a_obj_movebox.cpp index a63568b768..317827d640 100644 --- a/src/d/actor/d_a_obj_movebox.cpp +++ b/src/d/actor/d_a_obj_movebox.cpp @@ -17,12 +17,6 @@ #include "d/actor/d_a_player.h" #include "d/d_path.h" -#define ATTR_F32(x) (*((f32*)&attr().x)) -#define ATTR_S16(x) (*((s16*)&attr().x)) -// There are a lot of attr() problems in debug, -// they seem to be fixed by casting, like `((daObjMovebox::Attr_c*)&attr())->field` -// but sometimes breaks in release - #if DEBUG const char* const daObjMovebox::Hio_c::M_name[8] = { "押引・木・1.5m", // Push-pull type, wood, 1.5m @@ -36,36 +30,6 @@ const char* const daObjMovebox::Hio_c::M_name[8] = { }; #endif -const daObjMovebox::BgcSrc_c daObjMovebox::Bgc_c::M_lin5[] = { - {0.0f, 0.0f, 0.0f, 0.0f}, {-0.5f, -0.5f, 1.0f, 1.0f}, {0.5f, -0.5f, -1.0f, 1.0f}, - {0.5f, 0.5f, -1.0f, -1.0f}, {-0.5f, 0.5f, 1.0f, -1.0f}, -}; - -const daObjMovebox::BgcSrc_c daObjMovebox::Bgc_c::M_lin20[] = { - {0.0f, 0.0f, 0.0f, 0.0f}, {-0.25f, -0.25f, 0.0f, 0.0f}, {-0.5f, -0.5f, 1.0f, 1.0f}, - {0.0f, -0.5f, -1.0f, 1.0f}, {0.0f, 0.0f, -1.0f, -1.0f}, {-0.5f, 0.0f, 1.0f, -1.0f}, - {0.25f, -0.25f, 0.0f, 0.0f}, {0.0f, -0.5f, 1.0f, 1.0f}, {0.5f, -0.5f, -1.0f, 1.0f}, - {0.5f, 0.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f, -1.0f}, {0.25f, 0.25f, 0.0f, 0.0f}, - {0.0f, 0.0f, 1.0f, 1.0f}, {0.5f, 0.0f, -1.0f, 1.0f}, {0.5f, 0.5f, -1.0f, -1.0f}, - {0.0f, 0.5f, 1.0f, -1.0f}, {-0.25f, 0.25f, 0.0f, 0.0f}, {-0.5f, 0.0f, 1.0f, 1.0f}, - {0.0f, 0.0f, -1.0f, 1.0f}, {0.0f, 0.5f, -1.0f, -1.0f}, {-0.5f, 0.5f, 1.0f, -1.0f}, - {-0.75f, 0.25f, 0.0f, 0.0f}, {-0.75f, -0.25f, 0.0f, 0.0f}, -}; - -daObjMovebox::Bgc_c::Bgc_c() { - for (int i = 0; i < 23; i++) { - field_0x0[i] = 0.0f; - field_0x64[i] = cXyz::Zero; - } - - field_0x5c = 0xFFFFFFFF; - field_0x178 = 0xFFFFFFFF; - field_0x17c = FLT_MAX; - field_0x60 = 0.0f; - mState = STATE_0_e; -} - - #if DEBUG namespace daObjMovebox { namespace { @@ -135,13 +99,42 @@ void daObjMovebox::Hio_c::genMessage(JORMContext* context) { #endif +const daObjMovebox::BgcSrc_c daObjMovebox::Bgc_c::M_lin5[] = { + {0.0f, 0.0f, 0.0f, 0.0f}, {-0.5f, -0.5f, 1.0f, 1.0f}, {0.5f, -0.5f, -1.0f, 1.0f}, + {0.5f, 0.5f, -1.0f, -1.0f}, {-0.5f, 0.5f, 1.0f, -1.0f}, +}; + +const daObjMovebox::BgcSrc_c daObjMovebox::Bgc_c::M_lin20[] = { + {0.0f, 0.0f, 0.0f, 0.0f}, {-0.25f, -0.25f, 0.0f, 0.0f}, {-0.5f, -0.5f, 1.0f, 1.0f}, + {0.0f, -0.5f, -1.0f, 1.0f}, {0.0f, 0.0f, -1.0f, -1.0f}, {-0.5f, 0.0f, 1.0f, -1.0f}, + {0.25f, -0.25f, 0.0f, 0.0f}, {0.0f, -0.5f, 1.0f, 1.0f}, {0.5f, -0.5f, -1.0f, 1.0f}, + {0.5f, 0.0f, -1.0f, -1.0f}, {0.0f, 0.0f, 1.0f, -1.0f}, {0.25f, 0.25f, 0.0f, 0.0f}, + {0.0f, 0.0f, 1.0f, 1.0f}, {0.5f, 0.0f, -1.0f, 1.0f}, {0.5f, 0.5f, -1.0f, -1.0f}, + {0.0f, 0.5f, 1.0f, -1.0f}, {-0.25f, 0.25f, 0.0f, 0.0f}, {-0.5f, 0.0f, 1.0f, 1.0f}, + {0.0f, 0.0f, -1.0f, 1.0f}, {0.0f, 0.5f, -1.0f, -1.0f}, {-0.5f, 0.5f, 1.0f, -1.0f}, + {-0.75f, 0.25f, 0.0f, 0.0f}, {-0.75f, -0.25f, 0.0f, 0.0f}, +}; + +daObjMovebox::Bgc_c::Bgc_c() { + for (int i = 0; i < 23; i++) { + field_0x0[i] = 0.0f; + field_0x64[i] = cXyz::Zero; + } + + field_0x5c = 0xFFFFFFFF; + field_0x178 = 0xFFFFFFFF; + field_0x17c = FLT_MAX; + field_0x60 = 0.0f; + mState = STATE_0_e; +} + dBgS_ObjGndChk daObjMovebox::Bgc_c::M_gnd_work[23]; void daObjMovebox::Bgc_c::gnd_pos(const daObjMovebox::Act_c* i_actor, const daObjMovebox::BgcSrc_c* i_bgcSrc, int i_checkNum, f32 param_3) { - cXyz sp50; - cXyz sp5C; + cXyz sp20; + cXyz sp14; f32 var_f31 = -G_CM3D_F_INF; mDoMtx_stack_c::transS(i_actor->current.pos); @@ -149,15 +142,15 @@ void daObjMovebox::Bgc_c::gnd_pos(const daObjMovebox::Act_c* i_actor, field_0x5c = -1; for (int i = 0; i < i_checkNum; i++, i_bgcSrc++) { - sp50.set(i_bgcSrc->field_0xc + i_bgcSrc->field_0x4 * i_actor->attr().field_0x70, param_3, + sp20.set(i_bgcSrc->field_0xc + i_bgcSrc->field_0x4 * i_actor->attr().mScaleXZ, param_3, i_bgcSrc->field_0x8 + i_bgcSrc->field_0x0 * i_actor->attr().field_0x78); - mDoMtx_stack_c::multVec(&sp50, &sp5C); - M_gnd_work[i].SetPos(&sp5C); + mDoMtx_stack_c::multVec(&sp20, &sp14); + M_gnd_work[i].SetPos(&sp14); M_gnd_work[i].SetActorPid(i_actor->base.base.id); field_0x0[i] = dComIfG_Bgsp().GroundCross(&M_gnd_work[i]); #if DEBUG - L_gnd_start[i_actor->mType][i].set(sp50); + L_gnd_start[i_actor->mType][i].set(sp14); L_gnd_flag[i_actor->mType][i] = 1; #endif if (field_0x0[i] > var_f31) { @@ -222,9 +215,9 @@ void daObjMovebox::Bgc_c::wall_pos(daObjMovebox::Act_c const* i_actor, mDoMtx_stack_c::YrotS(sp8C); mDoMtx_stack_c::transM(sp60); - mDoMtx_stack_c::scaleM(i_actor->attr().field_0x70, - i_actor->attr().field_0x64, - i_actor->attr().field_0x70); + mDoMtx_stack_c::scaleM(i_actor->attr().mScaleXZ, + i_actor->attr().mScaleY, + i_actor->attr().mScaleXZ); mDoMtx_stack_c::transM(0.0f, 0.5f, 0.0f); mDoMtx_stack_c::XrotM(0x4000); @@ -261,8 +254,8 @@ void daObjMovebox::Bgc_c::proc_vertical(daObjMovebox::Act_c* i_actor) { State_e var_r29 = mState; mState = STATE_0_e; - gnd_pos(i_actor, i_actor->attr().field_0x9e ? M_lin20 : M_lin5, - i_actor->attr().field_0x9e ? 21 : 5, 100.0f); + gnd_pos(i_actor, i_actor->attr().mUseLargeGrid ? M_lin20 : M_lin5, + i_actor->attr().mUseLargeGrid ? 21 : 5, 100.0f); if (field_0x5c >= 0 && field_0x0[field_0x5c] > i_actor->current.pos.y) { i_actor->current.pos.y = field_0x0[field_0x5c]; @@ -305,6 +298,7 @@ bool daObjMovebox::Bgc_c::chk_wall_pre(daObjMovebox::Act_c const* i_actor, bool daObjMovebox::Bgc_c::chk_wall_touch(daObjMovebox::Act_c const* i_actor, daObjMovebox::BgcSrc_c const* i_bgcSrc, s16 param_2) { static dBgS_ObjLinChk touch_work; + static const f32 bgc_add = 10.0f; const s16 sp8C = i_actor->home.angle.y + param_2; @@ -318,7 +312,7 @@ bool daObjMovebox::Bgc_c::chk_wall_touch(daObjMovebox::Act_c const* i_actor, mDoMtx_stack_c::XrotM(0x4000); sp50.set(i_bgcSrc->field_0xc, 0.0f, i_bgcSrc->field_0x8); mDoMtx_stack_c::multVec(&cXyz::BaseY, &sp68); - sp68 *= i_actor->attr().field_0x70 * 0.5f + 10.0f; + sp68 *= i_actor->attr().mScaleXZ * 0.5f + 10.0f; mDoMtx_stack_c::XrotM(0x4000); sp50.set(i_bgcSrc->field_0xc, 0.0f, i_bgcSrc->field_0x8); @@ -326,10 +320,10 @@ bool daObjMovebox::Bgc_c::chk_wall_touch(daObjMovebox::Act_c const* i_actor, mDoMtx_stack_c::YrotS(sp8C); mDoMtx_stack_c::transM(sp5C); - - mDoMtx_stack_c::scaleM(i_actor->attr().field_0x70, - i_actor->attr().field_0x64, - i_actor->attr().field_0x70); + + mDoMtx_stack_c::scaleM(i_actor->attr().mScaleXZ, + i_actor->attr().mScaleY, + i_actor->attr().mScaleXZ); mDoMtx_stack_c::transM(0.0f, 0.5f, 0.0f); mDoMtx_stack_c::XrotM(0x4000); @@ -436,77 +430,179 @@ const dCcD_SrcCyl daObjMovebox::Act_c::M_cyl_src = { } }; -// __declspec(section ".rodata") const daObjMovebox::Attr_c daObjMovebox::Act_c::M_attr[8] = { { - 0x6, 0xE, 0xA, 0x6, 0xE, 0xA, 75.0f, 90.0f, - -3.0f, 0.005f, 0.001f, 0.0f, 1.8f, 3.9f, -0.39f, -0.2f, - 0.02f, 1000, 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, - 0.075f, 4, 7, 0xC00, 150.0f, 150.0f, 0.0066666668f, 150.0f, - 0.0066666668f, 150.0f, 0x8013C, 0x8013D, 0x80151, 0x8002A, 0x8002D, {-90, -1}, - {-90, 90}, {151, 90}, 0, 0, 0, + // Timing + 6, 14, 10, 6, 14, 10, + // Misc + 75.0f, 90.0f, -3.0f, 0.005f, 0.001f, 0.0f, 1.8f, 3.9f, -0.39f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0xC00, + 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, + // Sound effects + Z2SE_OBJ_MOVE_WBLOCK, Z2SE_OBJ_MOVE_WBLOCK_LIMIT, Z2SE_OBJ_WBOX_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_M, JA_SE_OBJ_FALL_MAGMA_M, + // Cull + {-90, -1, -90, 90, 151, 90}, + // Flags + false, false, false }, { - 0x8, 0x13, 0xD, 0x8, 0x13, 0xD, 75.0f, 90.0f, - -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, - 0.02f, 1000, 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, - 0.075f, 4, 7, 0xC00, 150.0f, 150.0f, 0.0066666668f, 150.0f, - 0.0066666668f, 150.0f, 0x20038, 0x20039, 0x8002F, 0x8002B, 0x8002E, {-90, -1}, - {-90, 90}, {151, 90}, 0, 0, 0, + // Timing + 8, 19, 13, 8, 19, 13, + // Misc + 75.0f, 90.0f, -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0xC00, + 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, + // Sound effects + JA_SE_LK_MOVE_ROCK, JA_SE_LK_MOVE_ROCK_LIMIT, JA_SE_OBJ_BLOCK_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_L, JA_SE_OBJ_FALL_MAGMA_L, + // Cull + {-90, -1, -90, 90, 151, 90}, + // Flags + false, false, false }, { - 0x8, 0x13, 0xD, 0x8, 0x13, 0xD, 50.0f, 110.0f, -5.0f, - 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, 0.02f, 1000, - 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, 4, 7, - 0x1000, 200.0f, 200.0f, 0.005f, 200.0f, 0.005f, 200.0f, 0x80154, 0x80155, - 0x8002F, 0x8002B, 0x8002E, {-110, -1}, {-110, 110}, {210, 110}, 0, 1, 0, + // Timing + 8, 19, 13, 8, 19, 13, + // Misc + 50.0f, 110.0f, -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0x1000, + 200.0f, 200.0f, 1 / 200.0f, 200.0f, 1.0f / 200.0f, 200.0f, + // Sound effects + Z2SE_OBJ_MOVE_ROCK, Z2SE_OBJ_MOVE_ROCK_LIMIT, JA_SE_OBJ_BLOCK_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_L, JA_SE_OBJ_FALL_MAGMA_L, + // Cull + {-110, -1, -110, 110, 210, 110}, + // Flags + false, true, false }, { - 0x8, 0x13, 0xD, 0x8, 0x13, 0xD, 75.0f, 180.0f, - -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, - 0.02f, 1000, 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, - 0.075f, 4, 7, 0xC00, 300.0f, 300.0f, 0.0033333334f, 300.0f, - 0.0033333334f, 300.0f, 0x20038, 0x20039, 0x8002F, 0x8002B, 0x8002E, {-180, -1}, - {-180, 180}, {310, 180}, 0, 0, 0, + // Timing + 8, 19, 13, 8, 19, 13, + // Misc + 75.0f, 180.0f, -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0xC00, + 300.0f, 300.0f, 1.0f / 300.0f, 300.0f, 1.0f / 300.0f, 300.0f, + // Sound effects + JA_SE_LK_MOVE_ROCK, JA_SE_LK_MOVE_ROCK_LIMIT, JA_SE_OBJ_BLOCK_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_L, JA_SE_OBJ_FALL_MAGMA_L, + // Cull + {-180, -1, -180, 180, 310, 180}, + // Flags + false, false, false }, { - 0x8, 0x13, 0xD, 0x8, 0x13, 0xD, 75.0f, 180.0f, - -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, - 0.02f, 1000, 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, - 0.075f, 4, 7, 0x2670, 300.0f, 300.0f, 0.0033333334f, 300.0f, - 0.0033333334f, 300.0f, 0x20038, 0x20039, 0x8002F, 0x8002B, 0x8002E, {-180, -1}, - {-180, 180}, {310, 180}, 0, 0, 0, + // Timing + 8, 19, 13, 8, 19, 13, + // Misc + 75.0f, 180.0f, -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0x2670, + 300.0f, 300.0f, 1.0f / 300.0f, 300.0f, 1.0f / 300.0f, 300.0f, + // Sound effects + JA_SE_LK_MOVE_ROCK, JA_SE_LK_MOVE_ROCK_LIMIT, JA_SE_OBJ_BLOCK_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_L, JA_SE_OBJ_FALL_MAGMA_L, + // Cull + {-180, -1, -180, 180, 310, 180}, + // Flags + false, false, false }, { - 0x8, 0x13, 0xD, 0x8, 0x13, 0xD, 75.0f, 90.0f, - -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, - 0.02f, 1000, 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, - 0.075f, 4, 7, 0xC00, 150.0f, 150.0f, 0.0066666668f, 150.0f, - 0.0066666668f, 150.0f, 0x20038, 0x20039, 0x8002F, 0x8002B, 0x8002E, {-90, -1}, - {-90, 90}, {360, 90}, 0, 0, 0, + // Timing + 8, 19, 13, 8, 19, 13, + // Misc + 75.0f, 90.0f, -5.0f, 0.005f, 0.001f, 0.0f, 1.8f, 4.5f, -0.5f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0xC00, + 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, + // Sound effects + JA_SE_LK_MOVE_ROCK, JA_SE_LK_MOVE_ROCK_LIMIT, JA_SE_OBJ_BLOCK_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_L, JA_SE_OBJ_FALL_MAGMA_L, + // Cull + {-90, -1, -90, 90, 360, 90}, + // Flags + false, false, false }, { - 0x8, 0x13, 0xD, 0x8, 0x13, 0xD, 50.0f, 90.0f, -3.0f, - 0.005f, 0.001f, 0.0f, 1.8f, 3.9f, -0.39f, -0.2f, 0.02f, 1000, - 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, 4, 7, - 0x1620, 200.0f, 200.0f, 0.005f, 230.0f, 0.0043478259f, 100.0f, 0x8013C, 0x8013D, - 0x80151, 0x8002A, 0x8002D, {-130, -10}, {-60, 130}, {210, 60}, 0, 1, 0, + // Timing + 8, 19, 13, 8, 19, 13, + // Misc + 50.0f, 90.0f, -3.0f, 0.005f, 0.001f, 0.0f, 1.8f, 3.9f, -0.39f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0x1620, + 200.0f, 200.0f, 1 / 200.0f, 230.0f, 1.0f / 230.0f, 100.0f, + // Sound effects + Z2SE_OBJ_MOVE_WBLOCK, Z2SE_OBJ_MOVE_WBLOCK_LIMIT, Z2SE_OBJ_WBOX_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_M, JA_SE_OBJ_FALL_MAGMA_M, + // Cull + {-130, -10, -60, 130, 210, 60}, + // Flags + false, true, false }, { - 0x4, 0x4, 0x14, 0x4, 0x4, 0x14, 75.0f, 90.0f, - -3.0f, 0.005f, 0.001f, 0.0f, 1.8f, 3.9f, -0.39f, -0.2f, - 0.02f, 1000, 0.04f, 0.013f, 0.15f, 0.1f, 0.1f, 0.06f, - 0.075f, 4, 7, 0x1620, 150.0f, 150.0f, 0.0066666668f, 150.0f, - 0.0066666668f, 150.0f, 0x8013C, 0x8013D, 0x80151, 0x8002A, 0x8002D, {-90, -1}, - {-90, 90}, {151, 90}, 0, 0, 0, + // Timing + 4, 4, 20, 4, 4, 20, + // Misc + 75.0f, 90.0f, -3.0f, 0.005f, 0.001f, 0.0f, 1.8f, 3.9f, -0.39f, -0.2f, + // Water + 0.02f, 1000, 0.04f, 0.013f, + // Tilt + 0.15f, 0.1f, 0.1f, 0.06f, 0.075f, + // Scales/Limits + 4, 7, 0x1620, + 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, 1.0f / 150.0f, 150.0f, + // Sound effects + Z2SE_OBJ_MOVE_WBLOCK, Z2SE_OBJ_MOVE_WBLOCK_LIMIT, Z2SE_OBJ_WBOX_FALL_NORMAL, + Z2SE_OBJ_FALL_WATER_M, JA_SE_OBJ_FALL_MAGMA_M, + // Cull + {-90, -1, -90, 90, 151, 90}, + // Flags + false, false, false }, }; -const inline daObjMovebox::Attr_c& daObjMovebox::Act_c::attr() const { +// see comment in header +#if PLATFORM_GCN +inline const daObjMovebox::Attr_c& daObjMovebox::Act_c::attr() const { +#else +inline daObjMovebox::Attr_c& daObjMovebox::Act_c::attr() const { +#endif #if DEBUG - return daObjMovebox::Act_c::M_hio[mType].mAttr; + return M_hio[mType].mAttr; #else - return M_attr[mType]; + return const_cast<daObjMovebox::Attr_c&>(M_attr[mType]); #endif } @@ -630,9 +726,9 @@ void daObjMovebox::Act_c::path_save() { int daObjMovebox::Act_c::CreateHeap() { BOOL var_r29 = true; - if (attr().field_0x58 >= 0) { + if (attr().mModelResIdx >= 0) { J3DModelData* modelData = - (J3DModelData*)dComIfG_getObjectRes(M_arcname[mType], attr().field_0x58); + (J3DModelData*)dComIfG_getObjectRes(M_arcname[mType], attr().mModelResIdx); JUT_ASSERT(1403, modelData != NULL); mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); @@ -662,14 +758,14 @@ void daObjMovebox::Act_c::RideCallBack(dBgW* i_bgw, fopAc_ac_c* i_actor, fopAc_a if (fopAcM_GetProfName(i_rideActor) == fpcNm_ALINK_e) { var_f30 = a_this->attr().mPlayerGravity; - var_f27 = a_this->attr().field_0x74 * a_this->attr().mPlayerTiltPower; + var_f27 = a_this->attr().mTiltForceScale * a_this->attr().mPlayerTiltPower; } else { var_f30 = a_this->attr().mMiscGravity; - var_f27 = a_this->attr().field_0x74 * a_this->attr().mMiscTiltPower; + var_f27 = a_this->attr().mTiltForceScale * a_this->attr().mMiscTiltPower; } var_f31 = 1.0f - (JMAFastSqrt(var_f29 * var_f29 + var_f28 * var_f28) * - a_this->attr().field_0x74); + a_this->attr().mTiltForceScale); var_f31 = (var_f31 * 0.9f) + 0.1f; if (var_f31 < 0.0f) { var_f31 = 0.0f; @@ -698,26 +794,28 @@ enum MOVE_DIR { }; fopAc_ac_c* daObjMovebox::Act_c::PPCallBack(fopAc_ac_c* i_bgActor, fopAc_ac_c* i_pushActor, - s16 i_angle, dBgW_Base::PushPullLabel pp_label) { + s16 i_angle, dBgW_Base::PushPullLabel i_pp_label) { UNUSED(i_pushActor); - dBgW::PushPullLabel var_r26 = cLib_checkBit<dBgW::PushPullLabel>( - pp_label, (dBgW::PushPullLabel)(dBgW::PPLABEL_PUSH | dBgW::PPLABEL_PULL)); + static const int pp_field = 3; + + dBgW::PushPullLabel pp_label = cLib_checkBit<dBgW::PushPullLabel>( + i_pp_label, (dBgW::PushPullLabel)(dBgW::PPLABEL_PUSH | dBgW::PPLABEL_PULL)); Act_c* a_this = (Act_c*)i_bgActor; bool sp_e = - a_this->attr().field_0x9e ? - (cLib_checkBit<dBgW::PushPullLabel>(pp_label, dBgW::PPLABEL_HEAVY) ? true : false) : + a_this->attr().mUseLargeGrid ? + (cLib_checkBit<dBgW::PushPullLabel>(i_pp_label, dBgW::PPLABEL_HEAVY) ? true : false) : true; - if (var_r26 && sp_e) { + if (pp_label && sp_e) { s16 sp10 = - cLib_checkBit<dBgW::PushPullLabel>(var_r26, dBgW::PPLABEL_PULL) ? i_angle - 0x8000 : i_angle; + cLib_checkBit<dBgW::PushPullLabel>(pp_label, dBgW::PPLABEL_PULL) ? i_angle - 0x8000 : i_angle; s16 dir = sp10 - a_this->home.angle.y; JUT_ASSERT(1499, pp_label != pp_field); - a_this->mPPLabel = pp_label; + a_this->mPPLabel = i_pp_label; int move_dir; if (dir >= -0x2000 && dir < 0x2000) { move_dir = DIR_SOUTH; @@ -778,10 +876,10 @@ int daObjMovebox::Act_c::Create() { fopAcM_SetMtx(this, mBgMtx); - fopAcM_setCullSizeBox(this, attr().mCullX.min, attr().mCullX.max, attr().mCullY.min, - attr().mCullY.max, attr().mCullZ.min, attr().mCullZ.max); + fopAcM_setCullSizeBox(this, attr().mCull.xMin, attr().mCull.xMax, attr().mCull.yMin, + attr().mCull.yMax, attr().mCull.zMin, attr().mCull.zMax); fopAcM_SetSpeedF(this, 0.0f); - fopAcM_SetGravity(this, ATTR_F32(mGravity)); + fopAcM_SetGravity(this, attr().mGravity); fopAcM_posMoveF(this, NULL); mBgc.proc_vertical(this); @@ -820,17 +918,13 @@ int daObjMovebox::Act_c::Create() { void daObjMovebox::Act_c::afl_sway() { bool var_r22; bool var_r21; - + f32 var_f31 = field_0x8c0 * field_0x8c0 + field_0x8c4 * field_0x8c4; f32 var_f29 = attr().mMaxTiltPower * attr().mMaxTiltPower; - const BgcSrc_c* pbgc; - if (attr().field_0x9e) { - pbgc = mBgc.M_lin20; - } else { - pbgc = mBgc.M_lin5; - } - s32 check_num = attr().field_0x9e ? 21 : 5; + //TODO: possible fakematch, the const_cast is very suspicious + BgcSrc_c* pbgc = const_cast<BgcSrc_c*>(attr().mUseLargeGrid ? mBgc.M_lin20 : mBgc.M_lin5); + s32 check_num = attr().mUseLargeGrid ? 21 : 5; var_r22 = mBgc.chk_wall_touch2(this, pbgc, check_num, M_dir_base[0]) || mBgc.chk_wall_touch2(this, pbgc, check_num, M_dir_base[2]); @@ -900,8 +994,8 @@ int daObjMovebox::Act_c::check_to_walk() { for (int i = 0; i < 4; i++) { if (field_0x8f0[i] >= (s16)var_r28) { - const BgcSrc_c* pbgc = attr().field_0x9e ? mBgc.M_lin20 : mBgc.M_lin5; - int check_num = attr().field_0x9e ? 21 : 5; + const BgcSrc_c* pbgc = attr().mUseLargeGrid ? mBgc.M_lin20 : mBgc.M_lin5; + int check_num = attr().mUseLargeGrid ? 21 : 5; if (!mBgc.chk_wall_pre(this, pbgc, check_num, M_dir_base[i])) { var_r27 = i; @@ -950,7 +1044,7 @@ void daObjMovebox::Act_c::eff_smoke_slip_start() { void daObjMovebox::Act_c::mode_wait_init() { fopAcM_SetSpeedF(this, 0.0f); - fopAcM_SetGravity(this, ATTR_F32(mGravity)); + fopAcM_SetGravity(this, attr().mGravity); mpBgW->SetCrrFunc(dBgS_MoveBGProc_Trans); clr_moment_cnt(); field_0x8e8 = -1; @@ -970,8 +1064,8 @@ void daObjMovebox::Act_c::mode_wait() { path_save(); } - daObj::posMoveF_stream(this, NULL, &cXyz::Zero, ATTR_F32(mViscosityResistance), - ATTR_F32(mInertiaResistance)); + daObj::posMoveF_stream(this, NULL, &cXyz::Zero, attr().mViscosityResistance, + attr().mInertiaResistance); cXyz sp48; mDoMtx_stack_c::transS(home.pos); @@ -991,10 +1085,10 @@ void daObjMovebox::Act_c::mode_wait() { mode_walk_init(); if (cLib_checkBit<dBgW::PushPullLabel>(mPPLabel, dBgW::PPLABEL_PULL)) { - field_0x8f8 = ATTR_S16(mPullMoveTime); + field_0x8f8 = attr().mPullMoveTime; field_0x8e4 = 32768.0f / attr().mPullMoveTime; } else { - field_0x8f8 = ATTR_S16(mPushMoveTime); + field_0x8f8 = attr().mPushMoveTime; field_0x8e4 = 32768.0f / attr().mPushMoveTime; } } @@ -1032,16 +1126,16 @@ void daObjMovebox::Act_c::mode_walk() { sound_slip(); if (var_r28) { - const BgcSrc_c* pbgc = attr().field_0x9e ? mBgc.M_lin20 : mBgc.M_lin5; - int check_num = attr().field_0x9e ? 21 : 5; + const BgcSrc_c* pbgc = attr().mUseLargeGrid ? mBgc.M_lin20 : mBgc.M_lin5; + int check_num = attr().mUseLargeGrid ? 21 : 5; if (mBgc.chk_wall_pre(this, pbgc, check_num, M_dir_base[field_0x8e8])) { sound_limit(); } } - daObj::posMoveF_stream(this, NULL, &cXyz::Zero, ATTR_F32(mViscosityResistance), - ATTR_F32(mInertiaResistance)); + daObj::posMoveF_stream(this, NULL, &cXyz::Zero, attr().mViscosityResistance, + attr().mInertiaResistance); current.pos.x = sp78.x; current.pos.z = sp78.z; @@ -1080,7 +1174,7 @@ void daObjMovebox::Act_c::mode_afl() { } else if (var_f30 <= -attr().field_0x68) { var_f31 = 1.0f; } else { - var_f31 = -var_f30 * attr().field_0x6c; + var_f31 = -var_f30 * attr().mWaterBobScale; } S16_ADD(field_0x8b8, attr().mWaterOscillationAngleSpeed * (cM_rnd() + 1.0f)); @@ -1114,7 +1208,7 @@ static void dummy() { void daObjMovebox::Act_c::mode_proc_call() { typedef void (daObjMovebox::Act_c::*modeFunc)(); - static modeFunc mode_proc[] = { + static const modeFunc mode_proc[] = { &daObjMovebox::Act_c::mode_wait, &daObjMovebox::Act_c::mode_walk, &daObjMovebox::Act_c::mode_afl, @@ -1133,7 +1227,7 @@ void daObjMovebox::Act_c::sound_slip() { } } - mDoAud_seStartLevel(attr().field_0x7c, &eyePos, var_r29, mReverb); + mDoAud_seStartLevel(attr().mSoundSlip, &eyePos, var_r29, mReverb); } void daObjMovebox::Act_c::sound_limit() { @@ -1146,7 +1240,7 @@ void daObjMovebox::Act_c::sound_limit() { } } - mDoAud_seStart(attr().field_0x80, &eyePos, var_r29, mReverb); + mDoAud_seStart(attr().mSoundLimit, &eyePos, var_r29, mReverb); } void daObjMovebox::Act_c::sound_land() { @@ -1159,7 +1253,7 @@ void daObjMovebox::Act_c::sound_land() { } } - mDoAud_seStart(attr().field_0x84, &eyePos, var_r29, mReverb); + mDoAud_seStart(attr().mSoundLand, &eyePos, var_r29, mReverb); } void daObjMovebox::Act_c::vib_land() { @@ -1171,10 +1265,10 @@ f32 dummy_literal(f32 x) { } void daObjMovebox::Act_c::eff_land_smoke() { - daObjEff::Act_c::make_land_smoke(¤t.pos, ATTR_F32(mLandSmokeScale)); + daObjEff::Act_c::make_land_smoke(¤t.pos, attr().mLandSmokeScale); } -void dummy_static() { +void daObjMovebox::Act_c::eff_break() { static cXyz particle_scale; } @@ -1235,7 +1329,7 @@ int daObjMovebox::Act_c::Execute(Mtx** param_0) { if (cLib_checkBit<daObjMovebox::Bgc_c::State_e>(mBgc.mState, daObjMovebox::Bgc_c::STATE_20_e)) { - mDoAud_seStart(attr().field_0x88, &eyePos, 0, mReverb); + mDoAud_seStart(attr().mSoundFallWater, &eyePos, 0, mReverb); } if (field_0x5ac == 0) { @@ -1305,13 +1399,13 @@ int daObjMovebox::Act_c::Draw() { dComIfGd_setList(); } - if (attr().field_0x9d == 0 && mBgc.field_0x5c >= 0) { + if (attr().mDisableShadow == 0 && mBgc.field_0x5c >= 0) { int index = mBgc.field_0x5c; f32 var_f31 = mBgc.field_0x0[index]; cM3dGPla sp40; bool b = dComIfG_Bgsp().GetTriPla(mBgc.M_gnd_work[index], &sp40); if (b && var_f31 != -G_CM3D_F_INF) { - dComIfGd_setSimpleShadow(¤t.pos, var_f31, ATTR_F32(mShadowSize), &sp40.mNormal, + dComIfGd_setSimpleShadow(¤t.pos, var_f31, attr().mShadowSize, &sp40.mNormal, shape_angle.y, -0.4f, NULL); } } @@ -1365,12 +1459,12 @@ int daObjMovebox::Act_c::Mthd_Create() { int phase_state = dComIfG_resLoad(&mPhase, M_arcname[mType]); if (phase_state == cPhs_COMPLEATE_e) { - u32 heap_size = attr().field_0x60; + u32 heap_size = attr().mHeapSize; path_init(); - phase_state = MoveBGCreate(M_arcname[mType], attr().field_0x5c, dBgS_MoveBGProc_Trans, + phase_state = MoveBGCreate(M_arcname[mType], attr().mMoveBGIdx, dBgS_MoveBGProc_Trans, heap_size, NULL); - JUT_ASSERT(0, (phase_state == cPhs_COMPLEATE_e) || (phase_state == cPhs_ERROR_e)); + JUT_ASSERT(1663, (phase_state == cPhs_COMPLEATE_e) || (phase_state == cPhs_ERROR_e)); } return phase_state; diff --git a/src/d/actor/d_a_tag_attack_item.cpp b/src/d/actor/d_a_tag_attack_item.cpp index d07d511934..3c61256e3b 100644 --- a/src/d/actor/d_a_tag_attack_item.cpp +++ b/src/d/actor/d_a_tag_attack_item.cpp @@ -37,6 +37,11 @@ static dCcD_SrcCyl l_cyl_src = { }; #if DEBUG +daTagAtkItem_HIO_c::daTagAtkItem_HIO_c() { + field_0x8 = 0.0f; + show_range = 0; +} + void daTagAtkItem_HIO_c::genMessage(JORMContext* ctx) { // "Attack reaction item" ctx->genLabel("攻撃反応アイテム", 0); @@ -61,11 +66,6 @@ int daTagAtkItem_c::Create() { return 1; } -daTagAtkItem_HIO_c::daTagAtkItem_HIO_c() { - field_0x8 = 0.0f; - show_range = 0; -} - int daTagAtkItem_c::create() { fopAcM_ct(this, daTagAtkItem_c); diff --git a/src/d/actor/d_a_tag_attention.cpp b/src/d/actor/d_a_tag_attention.cpp index 339818c772..a0b8bf0339 100644 --- a/src/d/actor/d_a_tag_attention.cpp +++ b/src/d/actor/d_a_tag_attention.cpp @@ -13,6 +13,11 @@ #if DEBUG daAttp_HIO_c l_HIO; +daAttp_HIO_c::daAttp_HIO_c() { + type_spec = 0; + dist_max = dist_max_release = dist_adjust = upper_y = lower_y = 0.0f; +} + void daAttp_HIO_c::genMessage(JORMContext* ctx) { static const char* l_type_name[37] = { "注目なし - ダミー", // No focus - dummy @@ -258,11 +263,6 @@ int daAttp_c::_delete() { return 1; } -daAttp_HIO_c::daAttp_HIO_c() { - type_spec = 0; - dist_max = dist_max_release = dist_adjust = upper_y = lower_y = 0.0f; -} - static int daAttp_Draw(daAttp_c* i_this) { return i_this->draw(); } @@ -273,13 +273,13 @@ static int daAttp_Execute(daAttp_c* i_this) { } static int daAttp_Delete(daAttp_c* i_this) { - fpc_ProcID id = fopAcM_GetID(i_this); + fopAcM_RegisterDeleteID(i_this, "Attp"); return i_this->_delete(); } static int daAttp_Create(fopAc_ac_c* i_this) { daAttp_c* attp = static_cast<daAttp_c*>(i_this); - fpc_ProcID id = fopAcM_GetID(i_this); + fopAcM_RegisterCreateID(i_this, "Attp"); return attp->create(); } diff --git a/src/d/actor/d_a_tag_camera.cpp b/src/d/actor/d_a_tag_camera.cpp index a25e1a942f..ce5a929c9c 100644 --- a/src/d/actor/d_a_tag_camera.cpp +++ b/src/d/actor/d_a_tag_camera.cpp @@ -136,9 +136,11 @@ u16 daTag_Cam_c::getAreaNoChk() { return home.angle.z & 0x200; } +#if PLATFORM_GCN static u8 const lit_3874[12] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +#endif int daTag_Cam_c::create() { fopAcM_ct(this, daTag_Cam_c); diff --git a/src/d/actor/d_a_tag_hjump.cpp b/src/d/actor/d_a_tag_hjump.cpp index 7f57cbcf44..36613aaaee 100644 --- a/src/d/actor/d_a_tag_hjump.cpp +++ b/src/d/actor/d_a_tag_hjump.cpp @@ -26,6 +26,11 @@ static char const l_arcName[] = "Hfence"; #if DEBUG daTagHjump_HIO_c l_HIO; +daTagHjump_HIO_c::daTagHjump_HIO_c() { + height = 350.0f; + depth = 400.0f; +} + void daTagHjump_HIO_c::genMessage(JORMContext* ctx) { ctx->genSlider("高さ", &height, 0.0f, 500.0f); ctx->genSlider("奥行き", &depth, 0.0f, 1000.0f); @@ -109,11 +114,6 @@ int daTagHjump_c::create() { return phase; } -daTagHjump_HIO_c::daTagHjump_HIO_c() { - height = 350.0f; - depth = 400.0f; -} - static int daTagHjump_Create(fopAc_ac_c* i_this) { daTagHjump_c* hJump = static_cast<daTagHjump_c*>(i_this); int id = fopAcM_GetID(i_this); diff --git a/src/d/actor/d_a_ykgr.cpp b/src/d/actor/d_a_ykgr.cpp index dbbb12d215..980da689f5 100644 --- a/src/d/actor/d_a_ykgr.cpp +++ b/src/d/actor/d_a_ykgr.cpp @@ -198,7 +198,13 @@ inline int daYkgr_c::_execute() { if (m_alpha_flag == 0) { if (m_alpha > 0) { if (m_alpha > l_HIO.field_0xc) { - m_alpha = m_alpha - l_HIO.field_0xc; + // this doesn't feel right but it looks an awful lot + // like the cast only exists in Shield+ShieldD +#if PLATFORM_SHIELD + m_alpha -= (u8)l_HIO.field_0xc; +#else + m_alpha -= l_HIO.field_0xc; +#endif } else { m_alpha = 0; } @@ -206,7 +212,11 @@ inline int daYkgr_c::_execute() { } else { if (m_alpha < 0xff) { if (m_alpha < 0xff - l_HIO.field_0xc) { - m_alpha = m_alpha + l_HIO.field_0xc; +#if PLATFORM_SHIELD + m_alpha += (u8)l_HIO.field_0xc; +#else + m_alpha += l_HIO.field_0xc; +#endif } else { m_alpha = 0xff; } @@ -235,10 +245,12 @@ void daYkgr_c::set_mtx() { MTXCopy(mDoMtx_stack_c::get(), field_0x570); } -inline int daYkgr_c::_draw() { - bool rv; +// typically we would expect an int return type, but debug seems to indicate this returns a bool +inline bool daYkgr_c::_draw() { f32 alpha = 255.0f; if (strcmp(dComIfGp_getStartStageName(), "D_MN04A") == 0) { + int dummy; // force stack pointer into r31 on debug + alpha = dComIfGs_BossLife_public_Get() / 100.0f; m_alpha = alpha * 255.0f; if (m_alpha == 0) { @@ -246,7 +258,7 @@ inline int daYkgr_c::_draw() { } } if (m_alpha == 0) { - rv = true; + return true; } else { set_mtx(); if (m_emitter != NULL) { @@ -258,9 +270,8 @@ inline int daYkgr_c::_draw() { m_emitter->setGlobalAlpha(m_alpha); } } - rv = true; + return true; } - return rv; } static int daYkgrDraw(void* i_this) { |
