From 5812194fadc4f13436784d3150e8d143ec2a6957 Mon Sep 17 00:00:00 2001 From: YunataSavior <58997725+YunataSavior@users.noreply.github.com> Date: Wed, 28 Jan 2026 14:19:46 -0800 Subject: [PATCH] DBG npc_henna and mg_fshop equiv (#3069) * DBG npc_henna almost, some mg_fshop * Fix weed_control * demo_camera_shop OK * misc dbg symbol/etc fixes * Fix e_ym/npc_henna dbg bss splits Thanks @LagoLunatic * dbg mg_fshop equiv * PR comments * DEBUG_CHECK_PAD_TRIG_Z mg_fshop --- config/ShieldD/rels/d_a_e_ymD/splits.txt | 2 +- config/ShieldD/rels/d_a_e_ymD/symbols.txt | 2 +- config/ShieldD/rels/d_a_npc_hennaD/splits.txt | 2 +- .../ShieldD/rels/d_a_npc_hennaD/symbols.txt | 2 +- include/d/actor/d_a_mg_fshop.h | 12 +- include/d/actor/d_a_npc_henna.h | 2 +- include/global.h | 7 + src/d/actor/d_a_e_oc.cpp | 32 +- src/d/actor/d_a_mg_fshop.cpp | 528 ++++++++++-------- src/d/actor/d_a_npc_henna.cpp | 483 ++++++++-------- src/d/actor/d_a_npc_ks.cpp | 87 ++- 11 files changed, 639 insertions(+), 520 deletions(-) diff --git a/config/ShieldD/rels/d_a_e_ymD/splits.txt b/config/ShieldD/rels/d_a_e_ymD/splits.txt index 7d234288988..aff23497426 100644 --- a/config/ShieldD/rels/d_a_e_ymD/splits.txt +++ b/config/ShieldD/rels/d_a_e_ymD/splits.txt @@ -14,4 +14,4 @@ d/actor/d_a_e_ym.cpp: .ctors start:0x00000000 end:0x00000004 .rodata start:0x00000000 end:0x00000164 .data start:0x00000000 end:0x00000624 - .bss start:0x00000004 end:0x00000030 + .bss start:0x00000000 end:0x00000030 diff --git a/config/ShieldD/rels/d_a_e_ymD/symbols.txt b/config/ShieldD/rels/d_a_e_ymD/symbols.txt index 221064170da..e2cf7714c70 100644 --- a/config/ShieldD/rels/d_a_e_ymD/symbols.txt +++ b/config/ShieldD/rels/d_a_e_ymD/symbols.txt @@ -251,7 +251,7 @@ lbl_244_data_300 = .data:0x00000300; // type:object size:0x24 @122156 = .data:0x0000052C; // type:object size:0x11 scope:local data:string @122157 = .data:0x00000554; // type:object size:0xD scope:local data:string lbl_244_data_561 = .data:0x00000561; // type:object size:0xC3 -lbl_244_bss_0 = .bss:0x00000000; // type:object size:0x1 data:byte +lbl_253_bss_8 = .bss:0x00000000; // type:object size:0x1 scope:local data:byte l_HIO = .bss:0x00000004; // type:object size:0x24 scope:global data:byte m_near_obj = .bss:0x00000028; // type:object size:0x4 scope:global data:4byte m_obj_dist = .bss:0x0000002C; // type:object size:0x4 scope:global align:4 data:float diff --git a/config/ShieldD/rels/d_a_npc_hennaD/splits.txt b/config/ShieldD/rels/d_a_npc_hennaD/splits.txt index 2785978ca1b..29bdb474f81 100644 --- a/config/ShieldD/rels/d_a_npc_hennaD/splits.txt +++ b/config/ShieldD/rels/d_a_npc_hennaD/splits.txt @@ -14,4 +14,4 @@ d/actor/d_a_npc_henna.cpp: .ctors start:0x00000000 end:0x00000004 .rodata start:0x00000000 end:0x0000030C .data start:0x00000000 end:0x000004E0 - .bss start:0x00000008 end:0x0000014C + .bss start:0x00000000 end:0x0000014C diff --git a/config/ShieldD/rels/d_a_npc_hennaD/symbols.txt b/config/ShieldD/rels/d_a_npc_hennaD/symbols.txt index bb43a528fcf..97c1e92cf0a 100644 --- a/config/ShieldD/rels/d_a_npc_hennaD/symbols.txt +++ b/config/ShieldD/rels/d_a_npc_hennaD/symbols.txt @@ -257,7 +257,7 @@ __RTTI__17daNpc_Henna_HIO_c = .data:0x00000400; // type:object size:0x8 scope:gl @124836 = .data:0x0000045C; // type:object size:0x11 scope:local data:string @124837 = .data:0x00000484; // type:object size:0xD scope:local data:string lbl_79_data_491 = .data:0x00000491; // type:object size:0x4F -lbl_79_bss_0 = .bss:0x00000000; // type:object size:0x1 data:byte +hio_set = .bss:0x00000000; // type:object size:0x1 scope:local data:byte l_HIO = .bss:0x00000008; // type:object size:0x38 scope:global data:byte lrl = .bss:0x00000040; // type:object size:0x4 scope:global data:4byte lbl_79_bss_44 = .bss:0x00000044; // type:object size:0x1 data:byte diff --git a/include/d/actor/d_a_mg_fshop.h b/include/d/actor/d_a_mg_fshop.h index e92366eae11..1176912ab94 100644 --- a/include/d/actor/d_a_mg_fshop.h +++ b/include/d/actor/d_a_mg_fshop.h @@ -18,7 +18,7 @@ struct fs_weed_s { struct fs_tsubo_s { /* 0x00 */ cXyz field_0x00; - /* 0x0C */ u8 field_0x0c[0x14 - 0x0c]; + /* 0x0C */ csXyz field_0x0c; // unused /* 0x14 */ J3DModel* model; /* 0x18 */ u8 field_0x18[0x1C - 0x18]; /* 0x1C */ f32 field_0x1c; @@ -29,7 +29,7 @@ struct fs_tsubo_s { struct fs_rod_s { /* 0x00 */ cXyz field_0x00; - /* 0x0C */ u8 field_0x0C[0x14 - 0x0C]; + /* 0x0C */ csXyz field_0x0C; // unused /* 0x14 */ J3DModel* model; /* 0x18 */ J3DModel* ringModel[6]; /* 0x30 */ mDoExt_3DlineMat0_c line_mat; @@ -41,9 +41,7 @@ struct fs_rod_s { struct fs_lure_s { /* 0x00 */ cXyz field_0x00; - /* 0x0C */ s16 field_0x0c; - /* 0x0E */ s16 field_0x0e; - /* 0x10 */ s16 field_0x10; + /* 0x0C */ csXyz field_0x0c; /* 0x14 */ J3DModel* model; /* 0x18 */ J3DModel* hookModel[2]; /* 0x20 */ u8 field_0x20[0x24 - 0x20]; @@ -113,6 +111,10 @@ public: /* 0x40B4 */ dBgS_ObjAcch ballAcch; /* 0x428C */ u8 field_0x428c; /* 0x428D */ u8 field_0x428d; +#if PLATFORM_SHIELD + u8 unk_dbg_padding[0x6]; + J3DModel* dbg_models[2]; +#endif /* 0x4290 */ fs_koro2_s mKoro2[100]; /* 0x6B30 */ J3DModel* canoeModel; /* 0x6B34 */ s16 field_0x6b34; diff --git a/include/d/actor/d_a_npc_henna.h b/include/d/actor/d_a_npc_henna.h index 36cab8f25cb..73d11c5269c 100644 --- a/include/d/actor/d_a_npc_henna.h +++ b/include/d/actor/d_a_npc_henna.h @@ -26,7 +26,7 @@ public: /* 0x5BC */ s16 field_0x5bc; /* 0x5BE */ s16 field_0x5be; /* 0x5C0 */ dMsgFlow_c mMsgFlow; - /* 0x60C */ u8 field_0x60c[0x618 - 0x60c]; + /* 0x60C */ cXyz field_0x60c; // unused /* 0x618 */ s16 field_0x618; /* 0x61C */ f32 field_0x61c; /* 0x620 */ s16 field_0x620; diff --git a/include/global.h b/include/global.h index 8be30974cc1..7161d3e2b95 100644 --- a/include/global.h +++ b/include/global.h @@ -145,4 +145,11 @@ static const float INF = 2000000000.0f; #define UNSET_FLAG(var, flag, type) (var) &= ~(flag) #endif +// potential fakematch? +#if DEBUG +#define FABSF fabsf +#else +#define FABSF std::fabsf +#endif + #endif diff --git a/src/d/actor/d_a_e_oc.cpp b/src/d/actor/d_a_e_oc.cpp index 2dc8ee48459..1c1f4c483c5 100644 --- a/src/d/actor/d_a_e_oc.cpp +++ b/src/d/actor/d_a_e_oc.cpp @@ -139,7 +139,7 @@ int daE_OC_c::ctrlJoint(J3DJoint* i_joint, J3DModel* param_1) { mDoMtx_stack_c::YrotM(field_0x6d0); } param_1->setAnmMtx(jnt_no, mDoMtx_stack_c::get()); - mDoMtx_copy(mDoMtx_stack_c::get(), J3DSys::mCurrentMtx); + cMtx_copy(mDoMtx_stack_c::get(), J3DSys::mCurrentMtx); return 1; } @@ -1487,22 +1487,26 @@ void daE_OC_c::executeAttack() { current.pos.x += (my_float - field_0x6a0) * cM_ssin(shape_angle.y); current.pos.z += (my_float - field_0x6a0) * cM_scos(shape_angle.y); field_0x6a0 = my_float; - if (mpMorf->isStop()) { - setBck(0x1c, 2, 5.0f, 1.0f); - mSound.startCreatureVoice(Z2SE_EN_OC_V_WAIT_ST, -1); - if (field_0x6e3) { - setActionMode(E_OC_ACTION_MOVE_OUT, 0); - } else { - if (field_0x6ca && fopAcM_searchPlayerDistance(this) < 500.0f) { - if (abs(shape_angle.y - fopAcM_searchPlayerAngleY(this)) < 0x1000) { - mOcState = 0; - break; - } - } + if (!mpMorf->isStop()) { + break; + } - setActionMode(E_OC_ACTION_FIND, 0); + setBck(0x1c, 2, 5.0f, 1.0f); + mSound.startCreatureVoice(Z2SE_EN_OC_V_WAIT_ST, -1); + if (field_0x6e3) { + setActionMode(E_OC_ACTION_MOVE_OUT, 0); + break; + } + + if (field_0x6ca && fopAcM_searchPlayerDistance(this) < 500.0f) { + if (abs(shape_angle.y - fopAcM_searchPlayerAngleY(this)) < 0x1000) { + mOcState = 0; + break; } } + + setActionMode(E_OC_ACTION_FIND, 0); + int _; // forces b in dbg asm break; } } diff --git a/src/d/actor/d_a_mg_fshop.cpp b/src/d/actor/d_a_mg_fshop.cpp index 87b27246def..990da93a06f 100644 --- a/src/d/actor/d_a_mg_fshop.cpp +++ b/src/d/actor/d_a_mg_fshop.cpp @@ -7,7 +7,7 @@ #include "d/actor/d_a_mg_fshop.h" #include "d/actor/d_a_npc_henna.h" -#include "d/actor/d_a_mg_rod.h" +#include "d/actor/d_a_mg_fish.h" #include "d/actor/d_a_player.h" #include "f_op/f_op_camera_mng.h" #include "d/d_timer.h" @@ -32,78 +32,6 @@ enum koro2_parts { KORO2_PART_SLOPE_R, }; -static void ride_call_back(dBgW* i_bgw, fopAc_ac_c* i_bgActor, fopAc_ac_c* i_rideActor) { - if (i_rideActor->field_0x567 == 0) { - i_rideActor->field_0x567 = 1; - ((fshop_class*)i_rideActor)->field_0x428c = 0; - } -} - -static int Reel_CallBack(J3DJoint* i_joint, int param_1) { - J3DJoint* var_r27; - - if (param_1 == 0) { - var_r27 = i_joint; - int jnt_no = var_r27->getJntNo(); - J3DModel* model = j3dSys.getModel(); - fs_rod_s* rod = (fs_rod_s*)model->getUserArea(); - MTXCopy(model->getAnmMtx(jnt_no), *calc_mtx); - cMtx_XrotM(*calc_mtx, rod->rot_x); - model->setAnmMtx(jnt_no, *calc_mtx); - MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); - } - - return 1; -} - -static int frog_CallBack(J3DJoint* i_joint, int param_1) { - fs_lure_s* lure; - J3DJoint* var_r27; - - if (param_1 == 0) { - var_r27 = i_joint; - int jnt_no = var_r27->getJntNo(); - J3DModel* model = j3dSys.getModel(); - lure = (fs_lure_s*)model->getUserArea(); - - if (jnt_no == 1) { - MTXCopy(model->getAnmMtx(jnt_no), *calc_mtx); - cMtx_YrotM(*calc_mtx, JREG_S(7) + -8800); - MtxScale(JREG_F(10) + 2.0f, JREG_F(11) + 1.0f, JREG_F(12) + 1.5f, 1); - model->setAnmMtx(jnt_no, *calc_mtx); - MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); - } - } - - return 1; -} - -static cXyz BallStartPos; - -static cXyz BallEndPos; - -static J3DModel* ArcIX_A_crwaku_model[1]; - -static void koro2_draw(fshop_class* i_this) { - fopAc_ac_c* actor = &i_this->actor; - - if (actor->scale.x > 5.0f) { - dComIfGd_setListBG(); - } - - g_env_light.setLightTevColorType_MAJI(ArcIX_A_crwaku_model[0], &actor->tevStr); - mDoExt_modelUpdateDL(ArcIX_A_crwaku_model[0]); - - for (int i = 0; i < ARRAY_SIZE(i_this->mKoro2); i++) { - if (i_this->mKoro2[i].model != NULL) { - g_env_light.setLightTevColorType_MAJI(i_this->mKoro2[i].model, &actor->tevStr); - mDoExt_modelUpdateDL(i_this->mKoro2[i].model); - } - } - - dComIfGd_setList(); -} - /** * Koro2 (Rollgoal) map data works as a 15x15 grid * Each grid value represents a piece to be placed there (koro2_parts enum) @@ -267,6 +195,59 @@ static s8* koro2_map_d[8] = { koro2_map_LV5, koro2_map_LV6, koro2_map_LV7, koro2_map_LV8, }; +static void ride_call_back(dBgW*, fopAc_ac_c*, fopAc_ac_c* i_rideActor) { + if (i_rideActor->field_0x567 == 0) { + i_rideActor->field_0x567 = 1; + ((fshop_class*)i_rideActor)->field_0x428c = 0; + } +} + +static int Reel_CallBack(J3DJoint* i_joint, int param_1) { + J3DJoint* var_r27; + + if (param_1 == 0) { + var_r27 = i_joint; + int jnt_no = var_r27->getJntNo(); + J3DModel* model = j3dSys.getModel(); + fs_rod_s* rod = (fs_rod_s*)model->getUserArea(); + MTXCopy(model->getAnmMtx(jnt_no), *calc_mtx); + cMtx_XrotM(*calc_mtx, rod->rot_x); + model->setAnmMtx(jnt_no, *calc_mtx); + MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); + } + + return 1; +} + +static int frog_CallBack(J3DJoint* i_joint, int param_1) { + fs_lure_s* lure; + J3DJoint* var_r27; + + if (param_1 == 0) { + var_r27 = i_joint; + int jnt_no = var_r27->getJntNo(); + J3DModel* model = j3dSys.getModel(); + lure = (fs_lure_s*)model->getUserArea(); + + if (jnt_no == 1) { + MTXCopy(model->getAnmMtx(jnt_no), *calc_mtx); + cMtx_YrotM(*calc_mtx, JREG_S(7) + -8800); + MtxScale(JREG_F(10) + 2.0f, JREG_F(11) + 1.0f, JREG_F(12) + 1.5f, 1); + model->setAnmMtx(jnt_no, *calc_mtx); + MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); + } + } + + return 1; +} + +static cXyz BallStartPos; + +static cXyz BallEndPos; + +#if !PLATFORM_SHIELD +static J3DModel* ArcIX_A_crwaku_model; + static J3DModel* ArcIX_A_crstart_model[1]; static J3DModel* ArcIX_A_crgoal_model[1]; @@ -283,6 +264,33 @@ static J3DModel** koro2_union_model[6] = { ArcIX_A_crstart_model, ArcIX_A_crgoal_model, ArcIX_A_crbox_model, ArcIX_A_crcurve_a_model, ArcIX_A_crcurve_b_model, ArcIX_A_crsaka_model, }; +#endif + +#if PLATFORM_SHIELD + #define GET_CRWAKU_MODEL(ptr) (ptr)->mpA_crwaku_model +#else + #define GET_CRWAKU_MODEL(ptr) ArcIX_A_crwaku_model +#endif + +static void koro2_draw(fshop_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; + + if (actor->scale.x > 5.0f) { + dComIfGd_setListBG(); + } + + g_env_light.setLightTevColorType_MAJI(GET_CRWAKU_MODEL(i_this), &actor->tevStr); + mDoExt_modelUpdateDL(GET_CRWAKU_MODEL(i_this)); + + for (int i = 0; i < ARRAY_SIZE(i_this->mKoro2); i++) { + if (i_this->mKoro2[i].model != NULL) { + g_env_light.setLightTevColorType_MAJI(i_this->mKoro2[i].model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->mKoro2[i].model); + } + } + + dComIfGd_setList(); +} static int daFshop_Draw(fshop_class* i_this) { fopAc_ac_c* actor = &i_this->actor; @@ -336,7 +344,7 @@ static int daFshop_Draw(fshop_class* i_this) { {0x64, 0x96, 0x14, 0xFF}, {0x96, 0x14, 0x14, 0xFF}, }; - i_this->mRod[i].line_mat.update(8, rod_color[i], &actor->tevStr); + i_this->mRod[i].line_mat.update(8, rod_color[i], &i_this->actor.tevStr); dComIfGd_set3DlineMat(&i_this->mRod[i].line_mat); for (int j = 0; j < 6; j++) { @@ -350,7 +358,7 @@ static int daFshop_Draw(fshop_class* i_this) { } static GXColor l_color = {0x32, 0x64, 0x1E, 0xFF}; - i_this->field_0x3f88.update(15, TREG_F(11) + 1.2f, l_color, 2, &actor->tevStr); + i_this->field_0x3f88.update(15, TREG_F(11) + 1.2f, l_color, 2, &i_this->actor.tevStr); dComIfGd_set3DlineMat(&i_this->field_0x3f88); g_env_light.setLightTevColorType_MAJI(i_this->canoeModel, &actor->tevStr); @@ -401,8 +409,8 @@ static void lure_set(fshop_class* i_this) { pLure->field_0x3c = cM_rndF(1000.0f) + 500.0f; } - pLure->field_0x34 += 4000; - pLure->field_0x36 += 4000; + pLure->field_0x34 += (s16) 4000; + pLure->field_0x36 += (s16) 4000; pLure->field_0x32 = pLure->field_0x3c * cM_ssin(pLure->field_0x36); pLure->field_0x30 = pLure->field_0x38 * cM_ssin(pLure->field_0x34); @@ -426,21 +434,21 @@ static void lure_set(fshop_class* i_this) { mDoMtx_stack_c::ZrotM(pLure->field_0x32); mDoMtx_stack_c::XrotM(pLure->field_0x30); mDoMtx_stack_c::transM(0.0f, -fVar2, 0.0f); - mDoMtx_stack_c::YrotM(pLure->field_0x0e); - mDoMtx_stack_c::XrotM(pLure->field_0x0c); - mDoMtx_stack_c::ZrotM(pLure->field_0x10); + mDoMtx_stack_c::YrotM(pLure->field_0x0c.y); + mDoMtx_stack_c::XrotM(pLure->field_0x0c.x); + mDoMtx_stack_c::ZrotM(pLure->field_0x0c.z); mDoMtx_stack_c::scaleM(pLure->field_0x2c, pLure->field_0x2c, pLure->field_0x28); - mDoMtx_stack_c::transM(0.0f, 0.0f, 0.0f); + mDoMtx_stack_c::transM(0.0f, 0.0f, AREG_F(18)); pLure->model->setBaseTRMtx(mDoMtx_stack_c::get()); if (pLure->field_0x24 != 3) { mDoMtx_stack_c::push(); - mDoMtx_stack_c::transM(0.0f, hook_1_offy[pLure->field_0x24], 1.0f); + mDoMtx_stack_c::transM(ZREG_F(0), hook_1_offy[pLure->field_0x24] + ZREG_F(1), 1.0f + ZREG_F(2)); mDoMtx_stack_c::XrotM(-10000); pLure->hookModel[0]->setBaseTRMtx(mDoMtx_stack_c::get()); mDoMtx_stack_c::pop(); - mDoMtx_stack_c::transM(0.0f, hook_2_offy[pLure->field_0x24], - hook_2_offz[pLure->field_0x24]); + mDoMtx_stack_c::transM(ZREG_F(3), hook_2_offy[pLure->field_0x24] + ZREG_F(4), + hook_2_offz[pLure->field_0x24] + ZREG_F(5)); mDoMtx_stack_c::XrotM(0x4000); pLure->hookModel[1]->setBaseTRMtx(mDoMtx_stack_c::get()); } @@ -453,27 +461,27 @@ static void rod_set(fshop_class* i_this) { for (int i = 0; i < 3; i++, pRod++) { mDoMtx_stack_c::transS(pRod->field_0x00.x, pRod->field_0x00.y, pRod->field_0x00.z); if (i == 0) { - mDoMtx_stack_c::YrotM(-12000.0f); + mDoMtx_stack_c::YrotM(KREG_S(0) - 12000); } else if (i == 1) { - mDoMtx_stack_c::YrotM(-9000.0f); + mDoMtx_stack_c::YrotM(KREG_S(0) - 9000); } else { - mDoMtx_stack_c::YrotM(-16000.0f); + mDoMtx_stack_c::YrotM(KREG_S(0) - 16000); } - mDoMtx_stack_c::XrotM(1300); - mDoMtx_stack_c::YrotM(0); + mDoMtx_stack_c::XrotM(KREG_S(1) + 1300); + mDoMtx_stack_c::YrotM(s16(KREG_S(2))); pRod->model->setBaseTRMtx(mDoMtx_stack_c::get()); cXyz* local_64 = pRod->line_mat.getPos(0); if (pRod->field_0x4c == 0) { - mDoMtx_stack_c::transM(0.0f, 15.0f, 0.0f); + mDoMtx_stack_c::transM(0.0f, 15.0f + BREG_F(1), 0.0f); } else { - mDoMtx_stack_c::transM(0.0f, 15.0f, -0.8f); + mDoMtx_stack_c::transM(0.0f, 15.0f + BREG_F(1), -0.8f); } cXyz cStack_1c; cXyz cStack_28; - cXyz local_34; - for (int j = 0; j < 8; j++) { + cXyz vec_0x4c; + for (int j = 0; j < 8; j++, local_64++) { mDoMtx_stack_c::multVecZero(local_64); if (j == 0) { cStack_1c = *local_64; @@ -481,16 +489,15 @@ static void rod_set(fshop_class* i_this) { cStack_28 = *local_64; } mDoMtx_stack_c::transM(0.0f, pRod->field_0x54, 0.0f); - local_64++; } static f32 guide_p[6] = {0.0f, 0.1f, 0.22f, 0.36f, 0.52f, 0.7f}; static f32 guide_s[6] = {0.5f, 0.5f, 0.55f, 0.6f, 0.65f, 0.8f}; for (int j = 0; j < 6; j++) { - cXyz local_34 = cStack_28 + (cStack_1c - cStack_28) * guide_p[j]; - mDoMtx_stack_c::transS(local_34.x, local_34.y, local_34.z); + vec_0x4c = cStack_28 + (cStack_1c - cStack_28) * guide_p[j]; + mDoMtx_stack_c::transS(vec_0x4c.x, vec_0x4c.y, vec_0x4c.z); mDoMtx_stack_c::scaleM(guide_s[j], guide_s[j], guide_s[j]); - mDoMtx_stack_c::transM(0.0f, 4.0f, 0.0f); + mDoMtx_stack_c::transM(VREG_F(0), 4.0f + VREG_F(1), VREG_F(2)); mDoMtx_stack_c::YrotM(0x4000); pRod->ringModel[j]->setBaseTRMtx(mDoMtx_stack_c::get()); } @@ -498,22 +505,23 @@ static void rod_set(fshop_class* i_this) { } static void* s_fish_sub(void* i_actor, void* i_data) { - mg_fish_class* fish = (mg_fish_class*)i_actor; - fs_weed_s* weed = (fs_weed_s*)i_data; + (void) i_data; + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_MG_FISH) { + if (((mg_fish_class*)i_actor)->actor.speedF > 0.1f) { + fs_weed_s* weed = (fs_weed_s*)i_data; + f32 x_dist = ((mg_fish_class*)i_actor)->actor.current.pos.x - weed->field_0x00[0].x; + f32 y_dist = ((mg_fish_class*)i_actor)->actor.current.pos.y - weed->field_0x00[0].y; + f32 z_dist = ((mg_fish_class*)i_actor)->actor.current.pos.z - weed->field_0x00[0].z; - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_MG_FISH && fish->actor.speedF > 0.1f) { - f32 x_dist = fish->actor.current.pos.x - weed->field_0x00[0].x; - f32 y_dist = fish->actor.current.pos.y - weed->field_0x00[0].y; - f32 z_dist = fish->actor.current.pos.z - weed->field_0x00[0].z; + f32 dVar3 = ((mg_fish_class*)i_actor)->mJointScale; + if (dVar3 > 0.7f) { + dVar3 = 0.7f; + } - f32 dVar3 = fish->mJointScale; - if (dVar3 > 0.7f) { - dVar3 = 0.7f; - } - - if (fabsf(y_dist) < 60.0f * weed->field_0xb4 && JMAFastSqrt(SQUARE(x_dist) + SQUARE(z_dist)) < dVar3 * 35.0f) { - cLib_addCalc2(&weed->field_0xb8, dVar3, 0.1f, 0.05f); - return i_actor; + if (fabsf(y_dist) < (60.0f + AREG_F(14)) * weed->field_0xb4 && JMAFastSqrt(SQUARE(x_dist) + SQUARE(z_dist)) < dVar3 * 35.0f) { + cLib_addCalc2(&weed->field_0xb8, dVar3, 0.1f, 0.05f); + return i_actor; + } } } @@ -525,6 +533,7 @@ static void tsubo_set(fshop_class* i_this) { fs_tsubo_s* pTsubo = i_this->mTsubo; cXyz local_40; + f32 reg_f31 = 1.0f; s16 xrot; s16 zrot; for (int i = 0; i < 2; i++, pTsubo++) { @@ -550,20 +559,21 @@ static void tsubo_set(fshop_class* i_this) { xrot = cM_ssin(pTsubo->field_0x20) * pTsubo->field_0x1c; zrot = cM_ssin(pTsubo->field_0x22) * pTsubo->field_0x1c; pTsubo->field_0x20 += pTsubo->field_0x24; - pTsubo->field_0x22 += pTsubo->field_0x24 + 700; - cLib_addCalcAngleS2(&pTsubo->field_0x24, 9000, 1, 200); + ADD_ANGLE_2(pTsubo->field_0x22, pTsubo->field_0x24 + 700); + cLib_addCalcAngleS2(&pTsubo->field_0x24, 9000 + TREG_S(8), 1, 200); mDoMtx_stack_c::transS(pTsubo->field_0x00.x, pTsubo->field_0x00.y, pTsubo->field_0x00.z); mDoMtx_stack_c::XrotM(xrot); mDoMtx_stack_c::ZrotM(zrot); - mDoMtx_stack_c::scaleM(1.0f, 1.0f, 1.0f); + mDoMtx_stack_c::scaleM(reg_f31, reg_f31, reg_f31); pTsubo->model->setBaseTRMtx(mDoMtx_stack_c::get()); - cLib_addCalc0(&pTsubo->field_0x1c, 1.0f, 50.0f); + cLib_addCalc0(&pTsubo->field_0x1c, 1.0f, 50.0f + TREG_F(18)); } } static void weed_control(fshop_class* i_this, fs_weed_s* i_weed) { + UNUSED(i_this); int i; cXyz local_84; cXyz local_90; @@ -573,18 +583,23 @@ static void weed_control(fshop_class* i_this, fs_weed_s* i_weed) { local_84.y = 0.0f; local_84.z = i_weed->field_0xb4 * 5.0f; - f32 dVar11 = i_weed->field_0xb8 + 0.5f; + f32 reg_f29 = i_weed->field_0xb8 + 0.5f; + f32 reg_f28; + f32 reg_f27; + f32 reg_f26; + f32 reg_f31; + f32 reg_f30; i_weed->field_0xbc += (s16)(i_weed->field_0xb8 * 600.0f + 200.0f); cLib_addCalc0(&i_weed->field_0xb8, 0.05f, 0.02f); for (i = 1; i < 15; i++, pfVar7++) { - f32 dVar10 = dVar11 * cM_ssin(i_weed->field_0xbc + i * -5000); - f32 dVar8 = cM_ssin(i_weed->field_0xbc + i * -5500); - f32 dVar4 = dVar10 + (pfVar7[0].x - pfVar7[-1].x); - f32 dVar12 = (pfVar7[0].y - pfVar7[-1].y) + 3.0f; - f32 dVar6 = dVar11 * dVar8 + (pfVar7[0].z - pfVar7[-1].z); - cMtx_XrotS(*calc_mtx, -cM_atan2s(dVar12, dVar6)); - cMtx_YrotM(*calc_mtx, (s16)cM_atan2s(dVar4, JMAFastSqrt(SQUARE(dVar12) + SQUARE(dVar6)))); + reg_f27 = reg_f29 * cM_ssin(i_weed->field_0xbc + i * (AREG_S(7)-5000)); + reg_f26 = reg_f29 * cM_ssin(i_weed->field_0xbc + i * (AREG_S(8)-5500)); + reg_f28 = reg_f27 + (pfVar7[0].x - pfVar7[-1].x); + reg_f31 = (pfVar7[0].y - pfVar7[-1].y) + 3.0f + KREG_F(7); + reg_f30 = reg_f26 + (pfVar7[0].z - pfVar7[-1].z); + cMtx_XrotS(*calc_mtx, -cM_atan2s(reg_f31, reg_f30)); + cMtx_YrotM(*calc_mtx, (s16)cM_atan2s(reg_f28, JMAFastSqrt(SQUARE(reg_f31) + SQUARE(reg_f30)))); MtxPosition(&local_84, &local_90); pfVar7[0].x = pfVar7[-1].x + local_90.x; @@ -666,16 +681,18 @@ static void koro2_mtx_set(fshop_class* i_this) { } static void* s_sel_sub(void* i_actor, void* i_data) { + (void) i_data; if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_FSHOP) { if (((fshop_class*)i_actor)->field_0x400e == (u8)((((fshop_class*)i_data)->field_0x400c & 7) + 1)) { return i_actor; } } - + return NULL; } static void* s_ball_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_FSHOP && (fopAcM_GetParam(i_actor) & 0xFF) == 0x23) { return i_actor; } @@ -693,16 +710,15 @@ static void koro2_game(fshop_class* i_this) { switch (i_this->field_0x4010) { case 0: i_this->field_0x4014.x = 284.0f; - i_this->field_0x4014.y = 87.8f; + i_this->field_0x4014.y = 87.8f + VREG_F(8); i_this->field_0x4014.z = 432.0; - i_this->field_0x4020.z = 0; - i_this->field_0x4020.x = 0; + i_this->field_0x4020.x = i_this->field_0x4020.z = 0; break; case 1: - i_this->field_0x4014.x = 204.0f; - i_this->field_0x4014.y = -1352.2f; - i_this->field_0x4014.z = 430.0; - i_this->field_0x4020.y = -0x4000; + i_this->field_0x4014.x = 204.0f + YREG_F(8); + i_this->field_0x4014.y = 147.8f + YREG_F(9) - 1500.0f; + i_this->field_0x4014.z = 430.0f + YREG_F(10); + i_this->field_0x4020.y = YREG_S(0) - 0x4000; cLib_addCalcAngleS2(&i_this->field_0x4020.x, 0, 2, 0x200); cLib_addCalcAngleS2(&i_this->field_0x4020.z, 0, 2, 0x200); @@ -715,53 +731,52 @@ static void koro2_game(fshop_class* i_this) { (mDoCPd_c::getSubStickX(PAD_1) <= -0.8f && old_stick_x > -0.8f)) { if (mDoCPd_c::getSubStickX(PAD_1) > 0.0f) { - i_this->field_0x4062 += 0x4000; + i_this->field_0x4062 += (s16) 0x4000; } else { - i_this->field_0x4062 += -0x4000; + i_this->field_0x4062 += (s16) -0x4000; } } old_stick_x = mDoCPd_c::getSubStickX(PAD_1); cLib_addCalcAngleS2(&i_this->field_0x4060, i_this->field_0x4062, 4, 0x1000); - mDoMtx_YrotS(*calc_mtx, -i_this->field_0x4060); + cMtx_YrotS(*calc_mtx, -i_this->field_0x4060); sp5C.x = mDoCPd_c::getStickX3D(PAD_1); sp5C.y = 0.0f; sp5C.z = mDoCPd_c::getStickY(PAD_1); MtxPosition(&sp5C, &sp68); - f32 var_f2 = sp68.x; - f32 var_f3 = sp68.z; + f32 reg_f31 = sp68.x; + f32 reg_f30 = sp68.z; - f32 var_f31 = var_f2;; - if (var_f2 > 0.15f) { - var_f31-= 0.15f; - } else if (var_f2 < -0.15f) { - var_f31 += 0.15f; + if (reg_f31 > 0.15f) { + reg_f31 -= 0.15f; + } else if (reg_f31 < -0.15f) { + reg_f31 += 0.15f; } else { - var_f31 = 0.0f; + reg_f31 = 0.0f; } - if (var_f3 > 0.15f) { - var_f3 -= 0.15f; - } else if (var_f3 < -0.15f) { - var_f3 += 0.15f; + if (reg_f30 > 0.15f) { + reg_f30 -= 0.15f; + } else if (reg_f30 < -0.15f) { + reg_f30 += 0.15f; } else { - var_f3 = 0.0f; + reg_f30 = 0.0f; } - cLib_addCalcAngleS2(&i_this->field_0x4020.x, var_f3 * -6000.0f, 4, 0x200); - cLib_addCalcAngleS2(&i_this->field_0x4020.z, var_f31 * -6000.0f, 4, 0x200); + cLib_addCalcAngleS2(&i_this->field_0x4020.x, reg_f30 * (-6000.0f + JREG_F(7)), 4, 0x200); + cLib_addCalcAngleS2(&i_this->field_0x4020.z, reg_f31 * (-6000.0f + JREG_F(8)), 4, 0x200); } break; } - i_this->field_0x4008 = (fshop_class*)fpcM_Search(s_sel_sub, i_this); + i_this->field_0x4008 = (fshop_class*)fpcM_Search(s_sel_sub, actor); if (i_this->field_0x4008 != NULL) { stage_copy(i_this->field_0x4008, i_this); i_this->field_0x4008->field_0x400d = 0; - fshop_class* ball_p = (fshop_class*)fpcM_Search(s_ball_sub, i_this); + fshop_class* ball_p = (fshop_class*)fpcM_Search(s_ball_sub, actor); if (ball_p != NULL) { ball_p->field_0x4008 = i_this->field_0x4008; } @@ -809,6 +824,12 @@ static int ball_wall_check(fshop_class* i_this) { return 0; } +#if DEBUG + #define DEBUG_CHECK_PAD_TRIG_Z 1 +#else + #define DEBUG_CHECK_PAD_TRIG_Z 0 +#endif + static int daFshop_Execute(fshop_class* i_this) { fopAc_ac_c* actor = &i_this->actor; fopAc_ac_c* pPlayer = dComIfGp_getPlayer(0); @@ -838,13 +859,13 @@ static int daFshop_Execute(fshop_class* i_this) { switch (i_this->field_0x0572) { case 0: actor->current.pos = BallStartPos; - actor->current.pos.y += 4.0f; + actor->current.pos.y += 4.0f + XREG_F(7); actor->old.pos = actor->current.pos; i_this->field_0x428d = 10; break; case 1: actor->current.pos = BallStartPos; - actor->current.pos.y += 4.0f; + actor->current.pos.y += 4.0f + XREG_F(7); actor->old.pos = actor->current.pos; actor->speed.zero(); @@ -893,7 +914,7 @@ static int daFshop_Execute(fshop_class* i_this) { if (actor->current.pos.y < -2500.0f) { actor->field_0x567 = 1; } - + npc_henna_class* henna = (npc_henna_class*)fopAcM_SearchByName(PROC_NPC_HENNA); if (henna != NULL && henna->field_0x7b9 != 0 && (actor->field_0x567 == 1 || dTimer_getRestTimeMs() == 0)) { BOOL bVar5 = FALSE; @@ -911,7 +932,7 @@ static int daFshop_Execute(fshop_class* i_this) { } else { henna->actor.health = 2; } - + henna->cam_mode = 73; henna->field_0x754 = 0; henna->field_0x7b9 = 0; @@ -919,7 +940,11 @@ static int daFshop_Execute(fshop_class* i_this) { } else { if (actor->field_0x567 == 0) { local_cc = BallEndPos - actor->current.pos; - if (local_cc.abs() < 65.0f) { + if (local_cc.abs() < 65.0f + hREG_F(16) +#if DEBUG_CHECK_PAD_TRIG_Z + || mDoCPd_c::getTrigZ(PAD_1) +#endif + ) { npc_henna_class* henna = (npc_henna_class*)fopAcM_SearchByName(PROC_NPC_HENNA); if (henna != NULL) { BOOL bVar5 = FALSE; @@ -930,6 +955,12 @@ static int daFshop_Execute(fshop_class* i_this) { } } +#if DEBUG_CHECK_PAD_TRIG_Z + if (mDoCPd_c::getTrigZ(PAD_1)) { + bVar5 = FALSE; + } +#endif + if (bVar5) { henna->actor.health = 3; henna->cam_mode = 73; @@ -960,13 +991,16 @@ static int daFshop_Execute(fshop_class* i_this) { i_this->field_0x428c++; dBgS_GndChk adStack_b4; - cXyz local_e4 = actor->current.pos; + cXyz local_e4; + local_e4 = actor->current.pos; local_e4.y += 10.0f; local_e4.z += 1.0f; adStack_b4.SetPos(&local_e4); local_e4.y = dComIfG_Bgsp().GroundCross(&adStack_b4); - s16 local_160 = -cM_atan2s(local_e4.y - actor->current.pos.y, - local_e4.z - actor->current.pos.z); + f32 reg_f29; + f32 reg_f31 = local_e4.y - actor->current.pos.y; + f32 reg_f28 = local_e4.z - actor->current.pos.z; + s16 local_160 = -cM_atan2s(reg_f31, reg_f28); if (local_160 > 0x3000) { local_160 = 0x3000; } else if (local_160 < -0x3000) { @@ -977,8 +1011,9 @@ static int daFshop_Execute(fshop_class* i_this) { local_e4.x += 1.0f; adStack_b4.SetPos(&local_e4); local_e4.y = dComIfG_Bgsp().GroundCross(&adStack_b4); - s16 local_162 = (s16)cM_atan2s(local_e4.y - actor->current.pos.y, - local_e4.x - actor->current.pos.x); + reg_f31 = local_e4.y - actor->current.pos.y; + reg_f29 = local_e4.x - actor->current.pos.x; + s16 local_162 = (s16)cM_atan2s(reg_f31, reg_f29); if (local_162 > 0x3000) { local_162 = 0x3000; } else if (local_162 < -0x3000) { @@ -988,7 +1023,7 @@ static int daFshop_Execute(fshop_class* i_this) { cMtx_XrotS(*calc_mtx, local_160); cMtx_ZrotM(*calc_mtx, local_162); local_cc.x = 0.0f; - local_cc.y = 30.0f; + local_cc.y = 30.0f + AREG_F(13); local_cc.z = 0.0f; MtxPosition(&local_cc, &local_d8); @@ -1001,7 +1036,7 @@ static int daFshop_Execute(fshop_class* i_this) { actor->current.pos.z); mDoMtx_stack_c::scaleM(actor->scale.x, actor->scale.x, actor->scale.x); - mDoMtx_stack_c::transM(0.0f, 190.0f * actor->scale.x, 0.0f); + mDoMtx_stack_c::transM(0.0f, (190.0f + hREG_F(11)) * actor->scale.x, 0.0f); local_cc = pmVar11->lookat.eye - actor->current.pos; mDoMtx_stack_c::YrotM(cM_atan2s(local_cc.x, local_cc.z)); mDoMtx_stack_c::XrotM(-cM_atan2s(local_cc.y, JMAFastSqrt((local_cc.x * local_cc.x + local_cc.z * local_cc.z)))); @@ -1013,17 +1048,19 @@ static int daFshop_Execute(fshop_class* i_this) { tsubo_set(i_this); fs_weed_s* pWeed = i_this->mWeed; + cXyz* local_148; for (int i = 0; i < 60; i++, pWeed++) { weed_control(i_this, pWeed); - cXyz* local_148 = i_this->field_0x3f88.getPos(i); + local_148 = i_this->field_0x3f88.getPos(i); for (int local_150 = 0; local_150 < 15; local_150++, local_148++) { *local_148 = pWeed->field_0x00[local_150]; } fpcM_Search(s_fish_sub, pWeed); } - cXyz cStack_f0(-720.0f, 30.0f, 70.0f); - cXyz cStack_fc(0.5f, 0.5f, 0.5f); + cXyz cStack_f0(-720.0f, 30.0f + KREG_F(14), 70.0f); + f32 reg_f30 = 0.5f + KREG_F(15); + cXyz cStack_fc(reg_f30, reg_f30, reg_f30); for (int i = 0; i < 2; i++) { if (i == 0) { cStack_f0.z = -30.0f; @@ -1035,20 +1072,20 @@ static int daFshop_Execute(fshop_class* i_this) { } if (daPy_getPlayerActorClass()->checkFrontRollCrash()) { - i_this->field_0x6b34 = 30; + i_this->field_0x6b34 = 30 + JREG_S(3); } - s16 iVar6 = i_this->field_0x6b34 * cM_ssin(i_this->field_0x6b34 * 5000) * 30.0f; + s16 iVar6 = i_this->field_0x6b34 * cM_ssin(i_this->field_0x6b34 * 5000) * (30.0f + JREG_F(17)); if (i_this->field_0x6b34 != 0) { i_this->field_0x6b34--; } - mDoMtx_stack_c::transS(-450.0f, 25.0f, -250.0f); + mDoMtx_stack_c::transS(-450.0f + NREG_F(7), 25.0f + NREG_F(8), -250.0f + NREG_F(9)); mDoMtx_stack_c::YrotM(0x4000); - mDoMtx_stack_c::ZrotM(iVar6 + 2000); + mDoMtx_stack_c::ZrotM(2000 + NREG_S(8) + iVar6); i_this->canoeModel->setBaseTRMtx(mDoMtx_stack_c::get()); - mDoMtx_stack_c::transS(-450.0f, 0.0f, -250.0f); - mDoMtx_stack_c::scaleM(4.0f, 1.5f, 1.0f); + mDoMtx_stack_c::transS(-450.0f + NREG_F(13), 0.0f, -250.0f + NREG_F(14)); + mDoMtx_stack_c::scaleM(4.0f + NREG_F(15), 1.5f + NREG_F(16), 1.0f + NREG_F(17)); MTXCopy(mDoMtx_stack_c::get(), i_this->field_0x6b38); i_this->tableBgw->Move(); @@ -1062,17 +1099,17 @@ static int daFshop_Execute(fshop_class* i_this) { i_this->field_0x4000 = cM_rndF(600.0f) + 1300.0f; } - i_this->field_0x3ff8 += 4000; - i_this->field_0x3ffa += 4000; + i_this->field_0x3ff8 += (s16) 4000; + i_this->field_0x3ffa += (s16) 4000; s16 iVar10 = i_this->field_0x4000 * cM_ssin(i_this->field_0x3ffa); s16 iVar11 = i_this->field_0x3ffc * cM_ssin(i_this->field_0x3ff8); cLib_addCalc0(&i_this->field_0x3ffc, 1.0f, 40.0f); cLib_addCalc0(&i_this->field_0x4000, 1.0f, 40.0f); - mDoMtx_stack_c::transS(325.0f, 140.0f, 237.0f); - mDoMtx_stack_c::XrotM((s16)iVar10); - mDoMtx_stack_c::ZrotM(iVar11 + 15000); - mDoMtx_stack_c::transM(-10.0f, -7.0f, 0.0f); + mDoMtx_stack_c::transS(325.0f + AREG_F(17), 140.0f + AREG_F(18), 237.0f + AREG_F(19)); + mDoMtx_stack_c::XrotM(iVar10 + YREG_S(7)); + mDoMtx_stack_c::ZrotM(iVar11 + 15000 + YREG_S(9)); + mDoMtx_stack_c::transM(-10.0f + AREG_F(14), -7.0f + AREG_F(15), 0.0f + AREG_F(16)); i_this->hatModel->setBaseTRMtx(mDoMtx_stack_c::get()); koro2_game(i_this); @@ -1081,13 +1118,13 @@ static int daFshop_Execute(fshop_class* i_this) { return 1; } -static int daFshop_IsDelete(fshop_class* i_this) { +static int daFshop_IsDelete(fshop_class*) { return 1; } static int daFshop_Delete(fshop_class* i_this) { fopAc_ac_c* actor = &i_this->actor; - fopAcM_GetID(i_this); + fopAcM_RegisterDeleteID(i_this, "Fshop"); if (i_this->field_0x6b7c != 0) { J3DModelData* pModelData = (J3DModelData*) dComIfG_getObjectRes("Fshop", 5); @@ -1112,6 +1149,12 @@ static int daFshop_Delete(fshop_class* i_this) { } static int koro2_heapinit(fopAc_ac_c* actor) { +#if PLATFORM_SHIELD + static int sg_bmd[2] = { + 0x0F, 0x0D, + }; +#endif + static int koro2_bmd[15] = { 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0F, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x0E, 0x0E, 0x0E, @@ -1122,7 +1165,7 @@ static int koro2_heapinit(fopAc_ac_c* actor) { 0x21, 0x21, 0x21, 0x23, 0x23, 0x23, 0x23, }; - static u8 pande_d[16] = { + static s8 pande_d[16] = { 0x00, 0x01, 0x03, 0x02, 0x05, 0x04, 0x06, 0x07, 0x09, 0x08, 0x0B, 0x0A, 0x0C, 0x0D, 0x0F, 0x0E, }; @@ -1134,17 +1177,37 @@ static int koro2_heapinit(fopAc_ac_c* actor) { return 0; } - cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes("Fshop", 37); - if (i_this->koro2WakuBgw->Set(dzb, 1, &i_this->field_0x4030) == 1) { + if (i_this->koro2WakuBgw->Set((cBgD_t*)dComIfG_getObjectRes("Fshop", 37), 1, &i_this->field_0x4030) == 1) { return 0; } i_this->koro2WakuBgw->SetCrrFunc(dBgS_MoveBGProc_Typical); i_this->koro2WakuBgw->SetRideCallback(ride_call_back); - i_this->mpA_crwaku_model = ArcIX_A_crwaku_model[0]; +#if PLATFORM_SHIELD + i_this->field_0x4020.y = -16384.0f + cM_rndFX(2000.0f); + J3DModelData* modelData = (J3DModelData*) dComIfG_getObjectRes("Fshop", 16); + JUT_ASSERT(2554, modelData != NULL); + i_this->mpA_crwaku_model = mDoExt_J3DModel__create(modelData, J3DMdlFlag_DifferedDLBuffer, 0x11000084); + if (i_this->mpA_crwaku_model == NULL) { + return FALSE; + } + + for (int sp_0x44 = 0; sp_0x44 < 2; ++sp_0x44) { + modelData = (J3DModelData*) dComIfG_getObjectRes("Fshop", sg_bmd[sp_0x44]); + JUT_ASSERT(2571, modelData != NULL); + i_this->dbg_models[sp_0x44] = mDoExt_J3DModel__create(modelData, J3DMdlFlag_DifferedDLBuffer, 0x11000084); + if (i_this->dbg_models[sp_0x44] == NULL) { + return FALSE; + } + } +#else + i_this->mpA_crwaku_model = ArcIX_A_crwaku_model; +#endif int part_no = 0; - int flag567 = actor->field_0x567 & 8; + int index; + int sp_0x38 = actor->field_0x567 & 0x7; + int sp_0x34 = actor->field_0x567 & 0x8; int crstart_model_idx = 0; int crgoal_model_idx = 0; int crbox_model_idx = 0; @@ -1152,13 +1215,13 @@ static int koro2_heapinit(fopAc_ac_c* actor) { int crcurve_b_model_idx = 0; int crcurve_c_model_idx = 0; - s8* mapData = koro2_map_d[actor->field_0x567 & 7]; + s8* mapData = koro2_map_d[sp_0x38]; for (int column = 0; column < 9; column++) { for (int row = 0; row < 15; row++) { - int index = (row * 9) + column; + index = (row * 9) + column; if (mapData[index] != 0) { - if (flag567) { + if (sp_0x34) { i_this->mKoro2[part_no].part_id = pande_d[mapData[index]]; i_this->mKoro2[part_no].pos.x = 2.5f * (8 - column); } else { @@ -1166,7 +1229,7 @@ static int koro2_heapinit(fopAc_ac_c* actor) { i_this->mKoro2[part_no].pos.x = 2.5f * column; } - i_this->mKoro2[part_no].pos.y = 2.0f; + i_this->mKoro2[part_no].pos.y = 2.0f + VREG_F(1); i_this->mKoro2[part_no].pos.z = 2.5f * row; if (i_this->mKoro2[part_no].part_id == KORO2_PART_START) { @@ -1200,7 +1263,12 @@ static int koro2_heapinit(fopAc_ac_c* actor) { } else if (i_this->mKoro2[part_no].part_id == KORO2_PART_SLOPE_R) { i_this->mKoro2[part_no].rot_y = 0x4000; } - + +#if PLATFORM_SHIELD + modelData = (J3DModelData*) dComIfG_getObjectRes("Fshop", koro2_bmd[i_this->mKoro2[part_no].part_id - 1]); + JUT_ASSERT(2704, modelData != NULL); + i_this->mKoro2[part_no].model = mDoExt_J3DModel__create(modelData, J3DMdlFlag_DifferedDLBuffer, 0x11000084); +#else if (koro2_bmd[i_this->mKoro2[part_no].part_id - 1] == 10) { i_this->mKoro2[part_no].model = ArcIX_A_crbox_model[crbox_model_idx]; crbox_model_idx++; @@ -1220,18 +1288,19 @@ static int koro2_heapinit(fopAc_ac_c* actor) { i_this->mKoro2[part_no].model = ArcIX_A_crsaka_model[crcurve_c_model_idx]; crcurve_c_model_idx++; } - +#endif + if (i_this->mKoro2[part_no].model == NULL) { return 0; } - + i_this->mKoro2[part_no].bgw = new dBgW(); if (i_this->mKoro2[part_no].bgw == NULL) { return 0; } - cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes("Fshop",koro2_dzb[i_this->mKoro2[part_no].part_id - 1]); - if (i_this->mKoro2[part_no].bgw->Set(dzb, 1, &i_this->mKoro2[part_no].bgMtx) == 1) { + if (i_this->mKoro2[part_no].bgw->Set((cBgD_t*)dComIfG_getObjectRes("Fshop",koro2_dzb[i_this->mKoro2[part_no].part_id - 1]), + 1, &i_this->mKoro2[part_no].bgMtx) == 1) { return 0; } @@ -1261,8 +1330,8 @@ static int useHeapInit(fopAc_ac_c* actor) { if (i >= 32 && i <= 33) { i_this->mLure[i].field_0x24 = 3; - i_this->mLure[i].field_0x0c = JREG_S(4) - 0x4000; - i_this->mLure[i].field_0x0e = cM_rndFX2(32768.0f); + i_this->mLure[i].field_0x0c.x = JREG_S(4) - 0x4000; + i_this->mLure[i].field_0x0c.y = cM_rndFX2(32768.0f); i_this->mLure[i].field_0x28 = 1.2f + JREG_F(0); i_this->mLure[i].field_0x2c = 1.2f + JREG_F(0); i_this->mLure[i].field_0x00.y += 13.0f; @@ -1277,8 +1346,8 @@ static int useHeapInit(fopAc_ac_c* actor) { } } - i_this->mLure[i].field_0x0c = JREG_S(3) + 0x4000; - i_this->mLure[i].field_0x0e = cM_rndFX2(65536.0f); + i_this->mLure[i].field_0x0c.x = JREG_S(3) + 0x4000; + i_this->mLure[i].field_0x0c.y = cM_rndFX2(65536.0f); i_this->mLure[i].field_0x28 = 0.8f + JREG_F(0) + cM_rndFX2(0.1f); if (i_this->mLure[i].field_0x24 == 2) { @@ -1427,18 +1496,18 @@ static int useHeapInit(fopAc_ac_c* actor) { modelData = dComIfG_getObjectRes("Fshop", 0x15); JUT_ASSERT(3069, modelData != NULL); - i_this->hatModel = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); + i_this->hatModel = mDoExt_J3DModel__create((J3DModelData*)modelData, J3DMdlFlag_DifferedDLBuffer, 0x11000084); if (i_this->hatModel == NULL) { return 0; } - #if !PLATFORM_SHIELD +#if !PLATFORM_SHIELD i_this->field_0x4020.y = cM_rndFX(2000.0f) + -16384.0f; modelData = dComIfG_getObjectRes("Fshop", 16); JUT_ASSERT(3069, modelData != NULL); - ArcIX_A_crwaku_model[0] = mDoExt_J3DModel__create((J3DModelData*)modelData, 0x80000, 0x11000084); - if (ArcIX_A_crwaku_model[0] == NULL) { + ArcIX_A_crwaku_model = mDoExt_J3DModel__create((J3DModelData*)modelData, J3DMdlFlag_DifferedDLBuffer, 0x11000084); + if (ArcIX_A_crwaku_model == NULL) { return 0; } @@ -1472,13 +1541,11 @@ static int useHeapInit(fopAc_ac_c* actor) { } } } - #endif - - #if PLATFORM_SHIELD +#else if (!koro2_heapinit(actor)) { return 0; } - #endif +#endif if ((int)dComIfGs_getEventReg(0xF47F) >= 10) { modelData = dComIfG_getObjectRes("Fshop", 0x11); @@ -1507,7 +1574,7 @@ static int BalluseHeapInit(fopAc_ac_c* actor) { static int daFshop_Create(fopAc_ac_c* actor) { fshop_class* i_this = (fshop_class*)actor; - fopAcM_ct(actor, fshop_class); + fopAcM_ct(&i_this->actor, fshop_class); int phase_state = dComIfG_resLoad(&i_this->mPhase, "Fshop"); if (phase_state == cPhs_COMPLEATE_e) { @@ -1528,7 +1595,20 @@ static int daFshop_Create(fopAc_ac_c* actor) { i_this->field_0x400e = (fopAcM_GetParam(actor) & 0xFF) - 100; actor->field_0x567 = ((i_this->field_0x400e - 1) | (dComIfGs_getEventReg(0xF63F) & 8)); - u32 heapsizes[] = { + u32 heapsizes[] = +#if PLATFORM_SHIELD + { + 0x171C0, + 0x18EF0, + 0x20970, + 0x28E40, + 0x14F50, + 0x19FA0, + 0xF250, + 0x1BF50, + }; +#else + { 0x84A0, 0x9AC0, 0xB440, @@ -1538,24 +1618,27 @@ static int daFshop_Create(fopAc_ac_c* actor) { 0x64E0, 0xA9E0, }; +#endif if (!fopAcM_entrySolidHeap(actor, koro2_heapinit, heapsizes[i_this->field_0x400e - 1])) { OS_REPORT("//////////////FSHOP KORO222 SET NON !!\n"); return cPhs_ERROR_e; } - if (i_this->koro2WakuBgw != NULL && dComIfG_Bgsp().Regist(i_this->koro2WakuBgw, actor)) { + if (i_this->koro2WakuBgw != NULL && dComIfG_Bgsp().Regist(i_this->koro2WakuBgw, &i_this->actor)) { return cPhs_ERROR_e; } for (int i = 0; i < 100; i++) { - if (i_this->mKoro2[i].bgw != NULL && dComIfG_Bgsp().Regist(i_this->mKoro2[i].bgw, actor)) { + if (i_this->mKoro2[i].bgw != NULL && dComIfG_Bgsp().Regist(i_this->mKoro2[i].bgw, &i_this->actor)) { return cPhs_ERROR_e; } } i_this->field_0x428d = 30; +#if !PLATFORM_SHIELD i_this->field_0x400d = 1; +#endif return phase_state; } @@ -1564,14 +1647,20 @@ static int daFshop_Create(fopAc_ac_c* actor) { OS_REPORT("FSHOP//////////////FSHOP SET 1 !!\n"); - if (!fopAcM_entrySolidHeap(actor, useHeapInit, 0x5B000)) { +#if PLATFORM_SHIELD + #define HEAP_SIZE 0x522E0 +#else + #define HEAP_SIZE 0x5B000 +#endif + + if (!fopAcM_entrySolidHeap(actor, useHeapInit, HEAP_SIZE)) { OS_REPORT("//////////////FSHOP SET NON !!\n"); return cPhs_ERROR_e; } OS_REPORT("//////////////FSHOP SET 2 !!\n"); - if (i_this->tableBgw != NULL && dComIfG_Bgsp().Regist(i_this->tableBgw, actor)) { + if (i_this->tableBgw != NULL && dComIfG_Bgsp().Regist(i_this->tableBgw, &i_this->actor)) { return cPhs_ERROR_e; } @@ -1612,21 +1701,25 @@ static int daFshop_Create(fopAc_ac_c* actor) { fopAcM_createChild(PROC_FSHOP, fopAcM_GetID(actor), 0xFFFFFF23, &actor->current.pos, fopAcM_GetRoomNo(actor), NULL, NULL, -1, NULL); - u8 sp10 = 1; - #if VERSION == VERSION_GCN_PAL || VERSION == VERSION_WII_PAL + u8 sp10; +#if VERSION == VERSION_GCN_PAL || VERSION == VERSION_WII_PAL if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGUAGE_ENGLISH) { sp10 = 2; } else { sp10 = 0; } - #elif PLATFORM_SHIELD +#elif PLATFORM_SHIELD if (dComIfGs_getPalLanguage() == dSv_player_config_c::LANGUAGE_GERMAN) { sp10 = 2; } else { sp10 = 0; } - #endif +#else + sp10 = 1; +#endif + u32 parameters; + int sp24; for (int i = 0; i <= 3; i++) { static u16 check_kind[] = { 0xF57F, @@ -1635,7 +1728,6 @@ static int daFshop_Create(fopAc_ac_c* actor) { 0xF27F, }; - int sp24; if (sp10 == 1) { #if VERSION == VERSION_GCN_JPN sp24 = dComIfGs_getEventReg(check_kind[i]); @@ -1647,7 +1739,7 @@ static int daFshop_Create(fopAc_ac_c* actor) { } if (sp24 >= 10) { - u32 parameters = (sp24 << 8) | 0xFFFF0000 | i; + parameters = (sp24 << 8) | 0xFFFF0000 | i; fopAcM_create(PROC_MG_FISH, parameters, &actor->current.pos, fopAcM_GetRoomNo(actor), NULL, NULL, -1); } } diff --git a/src/d/actor/d_a_npc_henna.cpp b/src/d/actor/d_a_npc_henna.cpp index d5246395dfe..7cb4c9e2ee3 100644 --- a/src/d/actor/d_a_npc_henna.cpp +++ b/src/d/actor/d_a_npc_henna.cpp @@ -81,6 +81,13 @@ daNpc_Henna_HIO_c::daNpc_Henna_HIO_c() { mSeason3LightAngle = -45; } +#if DEBUG +void daNpc_Henna_HIO_c::genMessage(JORMContext* ctx) { + // Ms Henna + ctx->genLabel("ヘナさま", 0x80000001); +} +#endif + static void anm_init(npc_henna_class* i_this, int i_resIndex, f32 i_morf, u8 i_mode, f32 i_speed) { i_this->mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("Henna", i_resIndex), i_mode, i_morf, i_speed, 0.0f, -1.0f, NULL); @@ -93,6 +100,7 @@ static int nodeCallBack(J3DJoint* i_joint, int param_1) { s32 jointNo = joint->getJntNo(); J3DModel* model = j3dSys.getModel(); npc_henna_class* a_this = (npc_henna_class*)model->getUserArea(); + fopAc_ac_c* actor = &a_this->actor; if (a_this != 0) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); if (jointNo == 1) { @@ -259,23 +267,25 @@ static void* s_koro2ball_sub(void* param_0, void* param_1) { } static void message_shop(npc_henna_class* i_this) { - s16 angle = i_this->field_0x620 - dComIfGp_getPlayer(0)->shape_angle.y + 0x8000; + fopAc_ac_c* actor = &i_this->actor; + fopAc_ac_c* pla = dComIfGp_getPlayer(0); + s16 angle = i_this->field_0x620 - pla->shape_angle.y + 0x8000; if (angle > 0x1800 || angle < -0x1800 || (u16)i_this->field_0x620 < 0x2e00 || (u16)i_this->field_0x620 > 0xa800 || i_this->field_0x61c > 270.0f) { i_this->field_0x750 = 1; } if (i_this->field_0x750 != 0) { - fopAcM_OffStatus(&i_this->actor, NULL); - cLib_offBit(i_this->actor.attention_info.flags, fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e); + fopAcM_OffStatus(actor, NULL); + cLib_offBit(actor->attention_info.flags, fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e); } else { - fopAcM_OnStatus(&i_this->actor, 0); - cLib_onBit(i_this->actor.attention_info.flags, fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e); - i_this->actor.attention_info.distances[fopAc_attn_TALK_e] = 4; - i_this->actor.attention_info.distances[fopAc_attn_SPEAK_e] = 4; - i_this->actor.eventInfo.onCondition(1); + fopAcM_OnStatus(actor, 0); + cLib_onBit(actor->attention_info.flags, fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e); + actor->attention_info.distances[fopAc_attn_TALK_e] = 4; + actor->attention_info.distances[fopAc_attn_SPEAK_e] = 4; + actor->eventInfo.onCondition(1); if (dComIfGp_event_runCheck() && i_this->cam_mode == 0 && - i_this->actor.eventInfo.checkCommandTalk() != 0) + actor->eventInfo.checkCommandTalk() != 0) { dComIfGp_event_reset(); i_this->cam_mode = 10; @@ -284,14 +294,13 @@ static void message_shop(npc_henna_class* i_this) { } static void henna_shop(npc_henna_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; s16 unkInt1 = 0x800; switch (i_this->move_mode) { case 0: { anm_init(i_this, 26, 1.0f, 2, 1.0f); - i_this->actor.current.angle.y = 0x8000; - i_this->actor.shape_angle.y = 0x8000; - i_this->field_0x618 = 0x8000; + i_this->field_0x618 = actor->shape_angle.y = actor->current.angle.y = 0x8000; i_this->move_mode = 1; case 1: unkInt1 = 0; @@ -363,7 +372,7 @@ static void henna_shop(npc_henna_class* i_this) { } } - s16 angle = i_this->field_0x620 - i_this->actor.shape_angle.y; + s16 angle = i_this->field_0x620 - actor->shape_angle.y; if (angle > 0x2000 || angle < -0x2000) { if (angle > 0) { @@ -373,11 +382,11 @@ static void henna_shop(npc_henna_class* i_this) { } } if (i_this->cam_mode >= 80 && i_this->field_0x754 > 10) { - f32 dX = -661.0f - i_this->actor.current.pos.x; - f32 dZ = 376.0f - i_this->actor.current.pos.z; + f32 dX = -661.0f - actor->current.pos.x; + f32 dZ = 376.0f - actor->current.pos.z; i_this->field_0x618 = cM_atan2s(dX, dZ); } - cLib_addCalcAngleS2(&i_this->actor.current.angle.y, i_this->field_0x618, 2, unkInt1); + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->field_0x618, 2, unkInt1); /* dSv_event_flag_c::F_0461 - Fishing Pond - First time entered fishing house */ if ((!dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[461]) || data_80450C9C != 0) && i_this->field_0x7d7 == 0 && i_this->field_0x6a0 == 56 + TREG_S(7)) @@ -410,11 +419,10 @@ static void* s_rod_sub(void* param_0, void* param_1) { } static void* s_fish_sub(void* param_0, void* param_1) { - if (fopAcM_IsActor(param_0) != 0) { - fopAc_ac_c* a_param_1 = (fopAc_ac_c*)param_0; + (void) param_1; + if (fopAcM_IsActor(param_0)) { if (fopAcM_GetName(param_0) == PROC_NPC_DU || fopAcM_GetName(param_0) == PROC_MG_FISH) { - fopAc_ac_c* a_param_2 = (fopAc_ac_c*)param_1; - cXyz offset = a_param_1->current.pos - a_param_2->current.pos; + cXyz offset = ((fopAc_ac_c*)param_0)->current.pos - ((fopAc_ac_c*)param_1)->current.pos; if (offset.abs() < 500.0f + TREG_F(12)) { return param_0; } @@ -655,13 +663,15 @@ static void henna_ride(npc_henna_class* i_this) { vecToPlayer = actor->eyePos - camera->lookat.eye; lookat_pos = camera->lookat.center - camera->lookat.eye; - s16 rot = (s16)cM_atan2s(lookat_pos.x, lookat_pos.z); - rot -= (s16)cM_atan2s(vecToPlayer.x, vecToPlayer.z); - if (rot < 0x400 && rot > -0x400) { - s16 pitch = (s16)-cM_atan2s(lookat_pos.y, JMAFastSqrt(lookat_pos.x * lookat_pos.x + lookat_pos.z * lookat_pos.z)); - pitch -= (s16)-cM_atan2s(vecToPlayer.y, JMAFastSqrt(vecToPlayer.x * vecToPlayer.x + + s16 reg_r27 = (s16)cM_atan2s(lookat_pos.x, lookat_pos.z); + s16 sp_0x8 = (s16)cM_atan2s(vecToPlayer.x, vecToPlayer.z); + reg_r27 -= sp_0x8; + if (reg_r27 < 0x400 && reg_r27 > -0x400) { + reg_r27 = (s16)-cM_atan2s(lookat_pos.y, JMAFastSqrt(lookat_pos.x * lookat_pos.x + lookat_pos.z * lookat_pos.z)); + sp_0x8 = (s16)-cM_atan2s(vecToPlayer.y, JMAFastSqrt(vecToPlayer.x * vecToPlayer.x + vecToPlayer.z * vecToPlayer.z)); - if (pitch < 0x400 && pitch > -0x400 && i_this->timer[3] == 0) { + reg_r27 -= sp_0x8; + if (reg_r27 < 0x400 && reg_r27 > -0x400 && i_this->timer[3] == 0) { i_this->timer[3] = 0xa0; i_this->field_0x6ba = 60; } @@ -680,19 +690,19 @@ static void action(npc_henna_class* i_this) { i_this->field_0x620 = fopAcM_searchPlayerAngleY(actor); if (i_this->field_0x7b8 != 0) { - i_this->field_0x7b8 -= 1; + --i_this->field_0x7b8; } if (i_this->field_0x7d5 != 0) { - i_this->field_0x7d5 -= 1; + --i_this->field_0x7d5; } if (i_this->field_0x7b5 != 0) { - i_this->field_0x7b5 -= 1; + --i_this->field_0x7b5; } if (i_this->field_0x750 != 0) { - i_this->field_0x750 -= 1; + --i_this->field_0x750; } if (i_this->field_0x709 != 0) { - i_this->field_0x709 -= 1; + --i_this->field_0x709; } fpcM_Search(s_du_sub, i_this); @@ -708,7 +718,7 @@ static void action(npc_henna_class* i_this) { i_this->field_0x70d = 1; msg_class* msg = ((dMsgObject_c*)sub_actor)->getActor(); - if (msg != 0 && msg->mode == 6 && ((dMsgObject_c*)sub_actor)->isMouthCheck() != 0 && + if (msg != 0 && msg->mode == 6 && dMsgObject_isMouthCheck() && (lrl == 0 || lrl->play_cam_mode != 30)) { i_this->field_0x6a6 = 15; @@ -738,10 +748,10 @@ static void action(npc_henna_class* i_this) { if (i_this->field_0x7e1 == 0) { i_this->field_0x6c4 = 0; } else { - player = fopAcM_SearchByID(i_this->boat_id); - if (player != NULL) { - cLib_addCalcAngleS2(&i_this->field_0x6c4, player->shape_angle.z * (-0.75f + ZREG_F(0)), - 4, 500.0f + ZREG_F(0)); + fopAc_ac_c* boat = fopAcM_SearchByID(i_this->boat_id); + if (boat != NULL) { + s16 sp_0x10 = boat->shape_angle.z * (-0.75f + ZREG_F(0)); + cLib_addCalcAngleS2(&i_this->field_0x6c4, sp_0x10, 4, 500 + ZREG_S(0)); } } @@ -752,7 +762,7 @@ static void action(npc_henna_class* i_this) { i_this->field_0x662 = 8; } if (i_this->field_0x662 != 0) { - i_this->field_0x662 -= 1; + --i_this->field_0x662; i_this->field_0x69c = i_this->field_0x662; if (i_this->field_0x69c > 5.0f) { i_this->field_0x69c = 0.0f; @@ -764,23 +774,18 @@ static void action(npc_henna_class* i_this) { s16 unkTarget1 = 0; s16 unkTarget2 = 0; -#if VERSION == VERSION_WII_USA_R0 s16 unkTarget2Limit = 9000 + BREG_S(0); s16 unkTarget1Limit = 10000 + BREG_S(1); -#else - s16 unkTarget2Limit = 9000 + BREG_F(0); - s16 unkTarget1Limit = 10000 + BREG_F(1); -#endif if (i_this->field_0x70d == 10 || (i_this->field_0x70d == 1 && i_this->field_0x61c < 700.0f)) { if (i_this->field_0x70c != 0) { mae = sub_actor->eyePos - actor->eyePos; mae.y += i_this->field_0x72c * (20.0f + TREG_F(5)) + TREG_F(2); } else { mae = sub_actor->eyePos - actor->current.pos; - if (i_this->field_0x7e1 == 0) { - mae.y += -150.0f + TREG_F(1); + if (i_this->field_0x7e1 != 0) { + mae.y += TREG_F(2); } else { - mae.y += 0.0f + TREG_F(2); + mae.y += -150.0f + TREG_F(1); } } s16 angle = actor->shape_angle.y - i_this->field_0x620; @@ -807,7 +812,7 @@ static void action(npc_henna_class* i_this) { if (unkTarget2 > unkTarget2Limit) { unkTarget2 = unkTarget2Limit; - } else if (unkTarget2 < -unkTarget2Limit) { + } else if (unkTarget2 < (s16) -unkTarget2Limit) { unkTarget2 = -unkTarget2Limit; } @@ -820,7 +825,9 @@ static void action(npc_henna_class* i_this) { } else { i_this->field_0x6b6 = i_this->field_0x6b0 * (TREG_F(3) + -0.65f); } + i_this->field_0x6b6 += (s16)((0.15f + TREG_F(13)) * fabsf(i_this->field_0x6ac)); + s16 sp_0x8 = 0; // unused } static void cam_3d_morf(npc_henna_class* i_this, f32 param_1) { @@ -839,26 +846,26 @@ static void cam_3d_morf(npc_henna_class* i_this, f32 param_1) { } static void demo_camera(npc_henna_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; camera_class* camera; - daCanoe_c* boat; fopAc_ac_c* unused1 = dComIfGp_getPlayer(0); camera = dComIfGp_getCamera(dComIfGp_getPlayerCameraID(0)); camera_class* unused2 = dComIfGp_getCamera(0); cXyz unkXyz; - cXyz unkXyz2; - cXyz unkXyz3; - cXyz unkXyz4; + cXyz unkXyz2; // unused + cXyz unkXyz3; // unused + cXyz unkXyz4; // unused switch (i_this->cam_mode) { case 0: lbl_82_bss_90 = 0; break; case 100: - if (!i_this->actor.eventInfo.checkCommandDemoAccrpt()) { - fopAcM_orderPotentialEvent(&i_this->actor, dEvtCnd_CANDEMO_e, -1, 0); - i_this->actor.eventInfo.onCondition(dEvtCnd_CANDEMO_e); + if (!actor->eventInfo.checkCommandDemoAccrpt()) { + fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, -1, 0); + actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); return; } i_this->cam_mode = 101; @@ -873,10 +880,10 @@ static void demo_camera(npc_henna_class* i_this) { daPy_getPlayerActorClass()->changeDemoMode(4, 3, 0, 0); i_this->action = 20; i_this->move_mode = 0; - boat = (daCanoe_c*)fopAcM_SearchByID(i_this->boat_id); + daCanoe_c* boat = (daCanoe_c*)fopAcM_SearchByID(i_this->boat_id); if (boat != NULL) { - unkXyz4.set(-2815.0f, boat->current.pos.y, 4603.0f); - boat->setPosAndAngle(&unkXyz4, 0x76d9); + unkXyz.set(-2815.0f, boat->current.pos.y, 4603.0f); + boat->setPosAndAngle(&unkXyz, 0x76d9); } } @@ -884,8 +891,7 @@ static void demo_camera(npc_henna_class* i_this) { camera->mCamera.Reset(i_this->field_0x76c, i_this->field_0x760); camera->mCamera.Start(); dComIfGp_event_reset(); - daPy_py_c* player = daPy_getPlayerActorClass(); - player->cancelOriginalDemo(); + daPy_getPlayerActorClass()->cancelOriginalDemo(); /* dSv_event_flag_c::F_0464 - Fishing Pond - Reserved for fishing */ if (!dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[0x1d0])) { i_this->field_0x70a = 10; @@ -902,7 +908,7 @@ static void demo_camera(npc_henna_class* i_this) { } if (i_this->cam_mode != 0) { - i_this->field_0x754 = i_this->field_0x754 + 1; + ++i_this->field_0x754; if (i_this->field_0x754 > 10000) { i_this->field_0x754 = 10000; } @@ -975,27 +981,19 @@ static void demo_camera_shop(npc_henna_class* i_this) { static f32 old_stick_sx; static s8 unk_bss_5138; + fopAc_ac_c* actor = &i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); camera_class* playerCamera = dComIfGp_getCamera(dComIfGp_getPlayerCameraID(0)); camera_class* camera = dComIfGp_getCamera(0); - fopAc_ac_c* actor = &i_this->actor; - - fshop_class* fshop; - fshop_class* koro_shop; - fs_koro2_s* koro; cXyz unkXyz_78; cXyz unkXyz_6c; cXyz unkXyz_60; cXyz unkXyz_54; - f32 unkFloat1; s16 unkShort1; - s32 unkInt1; - s32 hour; u32 unkIntArr1[8]; - u32 unkIntArr2[1]; - s8 unkBool1 = FALSE; + s8 unkBool1 = false; if (!dComIfGp_event_runCheck() /* dSv_event_flag_c::F_0465 - Fishing Pond - Reserved for fishing */ @@ -1054,7 +1052,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { if (dComIfGp_checkPlayerStatus0(0, 0x2000) != 0) { for (s32 i = 0; i < 20; i++) { if (i != 11 || dComIfGs_getEventReg(check_kind[1]) != 0) { - if (i >= 12 && i <= 17 || i == 11) { + if ((i >= 12 && i <= 17) || i == 11) { unkShort1 = 0x600; } else { if (i == 0 || i == 5 || i == 7) { @@ -1064,7 +1062,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { } } if (zoom_check(i_this, &zoom_check_pos[i], unkShort1) != FALSE) { - i_this->field_0x7b6 += 2; + i_this->field_0x7b6 += (u8) 2; if (i_this->field_0x7b6 >= 10) { i_this->cam_mode = 0x28; i_this->field_0x7a8 = zoom_check_pos[i]; @@ -1081,9 +1079,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { break; } case 1: { - if (i_this->actor.eventInfo.checkCommandDemoAccrpt() == 0) { + if (actor->eventInfo.checkCommandDemoAccrpt() == 0) { fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, -1, 0); - i_this->actor.eventInfo.onCondition(dEvtCnd_CANDEMO_e); + actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); return; } playerCamera->mCamera.Stop(); @@ -1118,12 +1116,12 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->field_0x784.set(-270.0f, 155.0f, 103.0f); i_this->field_0x778.set(-45.0f, 153.0f, 169.0f); - i_this->field_0x790.x = std::fabsf(i_this->field_0x778.x - i_this->field_0x760.x); - i_this->field_0x790.y = std::fabsf(i_this->field_0x778.y - i_this->field_0x760.y); - i_this->field_0x790.z = std::fabsf(i_this->field_0x778.z - i_this->field_0x760.z); - i_this->field_0x79c.x = std::fabsf(i_this->field_0x784.x - i_this->field_0x76c.x); - i_this->field_0x79c.y = std::fabsf(i_this->field_0x784.y - i_this->field_0x76c.y); - i_this->field_0x79c.z = std::fabsf(i_this->field_0x784.z - i_this->field_0x76c.z); + i_this->field_0x790.x = FABSF(i_this->field_0x778.x - i_this->field_0x760.x); + i_this->field_0x790.y = FABSF(i_this->field_0x778.y - i_this->field_0x760.y); + i_this->field_0x790.z = FABSF(i_this->field_0x778.z - i_this->field_0x760.z); + i_this->field_0x79c.x = FABSF(i_this->field_0x784.x - i_this->field_0x76c.x); + i_this->field_0x79c.y = FABSF(i_this->field_0x784.y - i_this->field_0x76c.y); + i_this->field_0x79c.z = FABSF(i_this->field_0x784.z - i_this->field_0x76c.z); i_this->cam_mode = 3; i_this->field_0x7c0 = 0.0f; @@ -1140,7 +1138,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { if (i_this->field_0x754 == 160) { i_this->mMsgFlow.init(actor, 0x321, 0, NULL); unkXyz_6c.set(-67.0f, 0.0f, 105.0f); - daPy_getPlayerActorClass()->setPlayerPosAndAngle(&unkXyz_6c, 0xffffe1c5, 0); + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&unkXyz_6c, -7739, 0); } i_this->mMsgFlow.doFlow(actor, NULL, 0); if (i_this->mMsgFlow.getNowMsgNo() == 0x1f42) { @@ -1153,9 +1151,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { break; } case 10: { - if (i_this->actor.eventInfo.checkCommandDemoAccrpt() == 0) { + if (actor->eventInfo.checkCommandDemoAccrpt() == 0) { fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, 0xff7f, 0); - i_this->actor.eventInfo.onCondition(dEvtCnd_CANDEMO_e); + actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); return; } playerCamera->mCamera.Stop(); @@ -1172,10 +1170,10 @@ static void demo_camera_shop(npc_henna_class* i_this) { unkXyz_78.y = 160.0f + XREG_F(0); unkXyz_78.z = 120.0f + XREG_F(1); MtxPosition(&unkXyz_78, &i_this->field_0x760); - i_this->field_0x760 += i_this->actor.current.pos; - i_this->field_0x76c.x = i_this->actor.current.pos.x; - i_this->field_0x76c.y = i_this->actor.current.pos.y + 150.0f + XREG_F(2); - i_this->field_0x76c.z = i_this->actor.current.pos.z; + i_this->field_0x760 += actor->current.pos; + i_this->field_0x76c.x = actor->current.pos.x; + i_this->field_0x76c.y = actor->current.pos.y + 150.0f + XREG_F(2); + i_this->field_0x76c.z = actor->current.pos.z; cLib_addCalc2(&i_this->field_0x7bc, 55.0f, 0.5f, 5.0f); if (i_this->field_0x754 == 0) { if (i_this->field_0x5be == 1) { @@ -1336,8 +1334,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { break; } case 30: { + unkBool1 = true; if (actor->eventInfo.checkCommandDemoAccrpt() == 0) { - fopAcM_orderPotentialEvent(&i_this->actor, dEvtCnd_CANDEMO_e, 0xffff, 0); + fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, 0xffff, 0); actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); return; } @@ -1346,8 +1345,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->field_0x754 = 0; playerCamera->mCamera.SetTrimSize(1); } + // fallthrough intentional case 31: { - unkBool1 = TRUE; + unkBool1 = true; if (i_this->field_0x754 >= 5) { if (i_this->field_0x754 == 5) { if (i_this->field_0x7b5 > 25) { @@ -1370,9 +1370,10 @@ static void demo_camera_shop(npc_henna_class* i_this) { break; } case 35: { - if (i_this->actor.eventInfo.checkCommandDemoAccrpt() == 0) { + unkBool1 = true; + if (actor->eventInfo.checkCommandDemoAccrpt() == 0) { fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, 0xffff, 0); - i_this->actor.eventInfo.onCondition(dEvtCnd_CANDEMO_e); + actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); return; } playerCamera->mCamera.Stop(); @@ -1380,8 +1381,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->field_0x754 = 0; playerCamera->mCamera.SetTrimSize(1); } + // fallthrough intentional case 36: { - unkBool1 = TRUE; + unkBool1 = true; if (i_this->field_0x754 >= 5) { if (i_this->field_0x754 == 5) { i_this->mMsgFlow.init(actor, 0x322, 0, NULL); @@ -1405,7 +1407,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { playerCamera->mCamera.SetTrimSize(1); daPy_getPlayerActorClass()->onPlayerNoDraw(); unkXyz_78 = camera->lookat.center - camera->lookat.eye; - i_this->field_0x758 = cM_atan2s(unkXyz_78.x, unkXyz_78.z); + i_this->field_0x758 = (s16) cM_atan2s(unkXyz_78.x, unkXyz_78.z); i_this->field_0x75c = -cM_atan2s( unkXyz_78.y, JMAFastSqrt(unkXyz_78.x * unkXyz_78.x + unkXyz_78.z * unkXyz_78.z)); i_this->field_0x7c4 = unkXyz_78.abs(); @@ -1431,27 +1433,31 @@ static void demo_camera_shop(npc_henna_class* i_this) { if (i_this->field_0x7b4 != 8 && i_this->field_0x7b4 != 7 && i_this->field_0x7b4 != 6 && i_this->field_0x7b4 != 2 && i_this->field_0x7b4 != 4 && i_this->field_0x7b4 != 0) { - unkFloat1 = (130.0f + BREG_F(8)) - unkXyz_78.abs(); - unkFloat1 = unkFloat1 * (0.4f + BREG_F(9)) + 50.0f; - if (unkFloat1 > 70.0f) { - unkFloat1 = 70.0f; - } else if (unkFloat1 < 30.0f) { - unkFloat1 = 30.0f; + f32 reg_f29 = unkXyz_78.abs(); + f32 reg_f31 = 50.0f; + reg_f29 = (130.0f + BREG_F(8)) - reg_f29; + reg_f31 = reg_f29 * (0.4f + BREG_F(9)) + 50.0f; + if (reg_f31 > 70.0f) { + reg_f31 = 70.0f; + } else if (reg_f31 < 30.0f) { + reg_f31 = 30.0f; } - cLib_addCalc2(&i_this->field_0x7bc, unkFloat1, 0.2f, 2.0f); + cLib_addCalc2(&i_this->field_0x7bc, reg_f31, 0.2f, 2.0f); } else { - unkFloat1 = 200.0f + BREG_F(8) - unkXyz_78.abs(); - unkFloat1 = unkFloat1 * 0.4f + (50.0f + BREG_F(9)); - if (unkFloat1 > 80.0f) { - unkFloat1 = 80.0f; - } else if (unkFloat1 < 50.0f) { - unkFloat1 = 50.0f; + f32 reg_f28 = unkXyz_78.abs(); + f32 reg_f30 = 70.0f; + reg_f28 = 200.0f + BREG_F(8) - reg_f28; + reg_f30 = reg_f28 * (0.4f + BREG_F(9)) + 50.0f; + if (reg_f30 > 80.0f) { + reg_f30 = 80.0f; + } else if (reg_f30 < 50.0f) { + reg_f30 = 50.0f; } - cLib_addCalc2(&i_this->field_0x7bc, unkFloat1, 0.2f, 2.0f); + cLib_addCalc2(&i_this->field_0x7bc, reg_f30, 0.2f, 2.0f); } if (i_this->field_0x754 >= 15) { if (i_this->field_0x754 == 15) { - unkInt1 = 0; + int unkInt1 = 0; switch (i_this->field_0x7b4) { case 0: for (s32 i = 0; i <= 3; i++) { @@ -1464,12 +1470,10 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->mMsgFlow.init(actor, 0x333, 0, NULL); } else if (unkInt1 >= 4) { i_this->mMsgFlow.init(actor, 0x336, 0, NULL); + } else if (dComIfGs_getEventReg(check_kind[1]) >= 10) { + i_this->mMsgFlow.init(actor, 0x335, 0, NULL); } else { - if (dComIfGs_getEventReg(check_kind[1]) >= 10) { - i_this->mMsgFlow.init(actor, 0x335, 0, NULL); - } else { - i_this->mMsgFlow.init(actor, 0x334, 0, NULL); - } + i_this->mMsgFlow.init(actor, 0x334, 0, NULL); } break; case 2: @@ -1488,7 +1492,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { break; case 5: i_this->mMsgFlow.init(actor, 0x33b, 0, NULL); - data_80450C9D |= 0x80; + data_80450C9D |= (u8) 0x80; break; case 6: i_this->mMsgFlow.init(actor, 0x33d, 0, NULL); @@ -1499,7 +1503,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { case 8: { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); if (kankyo->raincnt == 0) { - hour = kankyo->daytime / 15.0f; + int hour = kankyo->daytime / 15.0f; if (hour < 8 || hour > 16) { i_this->mMsgFlow.init(actor, 0x371, 0, NULL); } else { @@ -1508,11 +1512,15 @@ static void demo_camera_shop(npc_henna_class* i_this) { } else { i_this->mMsgFlow.init(actor, 0x347, 0, NULL); } + } + // fallthrough intentional + case 9: { break; } - case 0xb: + case 0xb: { i_this->mMsgFlow.init(actor, 0x35f, 0, NULL); break; + } case 0xc: i_this->mMsgFlow.init(actor, 0x344, 0, NULL); break; @@ -1534,15 +1542,15 @@ static void demo_camera_shop(npc_henna_class* i_this) { case 0x12: i_this->mMsgFlow.init(actor, 0x33c, 0, NULL); break; - case 0x13: + case 0x13: { /* dSv_event_flag_c::KORO2_ALLCLEAR - Fishing - After all stages (8-8) of roll * goal game cleared */ if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[0x335])) { i_this->mMsgFlow.init(actor, 0x366, 0, NULL); } else { dComIfGp_event_offHindFlag(0x80); - dComIfGp_setMessageCountNumber( - (s16)((s16)((lbl_82_bss_91 & 7) + (lbl_82_bss_91 >> 3) * 10) + 11)); + s16 sp_0xa = ((lbl_82_bss_91 & 7) + (lbl_82_bss_91 >> 3) * 10); + dComIfGp_setMessageCountNumber(s16(sp_0xa + 11)); if (lbl_82_bss_91 == 0) { i_this->mMsgFlow.init(actor, 0x348, 0, NULL); } else if (lbl_82_bss_91 == 0x3f) { @@ -1551,6 +1559,8 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->mMsgFlow.init(actor, 0x34b, 0, NULL); } } + break; + } } } if (i_this->mMsgFlow.doFlow(actor, NULL, 0) != 0) { @@ -1610,9 +1620,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { break; } case 50: { - if (i_this->actor.eventInfo.checkCommandDemoAccrpt() == 0) { + if (actor->eventInfo.checkCommandDemoAccrpt() == 0) { fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, 0xffff, 0); - i_this->actor.eventInfo.onCondition(dEvtCnd_CANDEMO_e); + actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); dComIfGp_event_reset(); return; } @@ -1635,12 +1645,12 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->field_0x784.set(-538.0f, 130.0f, 116.0f); i_this->field_0x778.set(-263.0f, 142.0f, 162.0f); - i_this->field_0x790.x = std::fabsf(i_this->field_0x778.x - i_this->field_0x760.x); - i_this->field_0x790.y = std::fabsf(i_this->field_0x778.y - i_this->field_0x760.y); - i_this->field_0x790.z = std::fabsf(i_this->field_0x778.z - i_this->field_0x760.z); - i_this->field_0x79c.x = std::fabsf(i_this->field_0x784.x - i_this->field_0x76c.x); - i_this->field_0x79c.y = std::fabsf(i_this->field_0x784.y - i_this->field_0x76c.y); - i_this->field_0x79c.z = std::fabsf(i_this->field_0x784.z - i_this->field_0x76c.z); + i_this->field_0x790.x = FABSF(i_this->field_0x778.x - i_this->field_0x760.x); + i_this->field_0x790.y = FABSF(i_this->field_0x778.y - i_this->field_0x760.y); + i_this->field_0x790.z = FABSF(i_this->field_0x778.z - i_this->field_0x760.z); + i_this->field_0x79c.x = FABSF(i_this->field_0x784.x - i_this->field_0x76c.x); + i_this->field_0x79c.y = FABSF(i_this->field_0x784.y - i_this->field_0x76c.y); + i_this->field_0x79c.z = FABSF(i_this->field_0x784.z - i_this->field_0x76c.z); } case 51: { if (i_this->field_0x754 >= 15) { @@ -1685,7 +1695,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { } } if (i_this->mMsgFlow.doFlow(actor, NULL, 0) != 0 && i_this->field_0x754 > 0x3c) { - daPy_getPlayerActorClass()->setPlayerPosAndAngle(&player->current.pos, 0xffffb01c, 0); + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&player->current.pos, -20452, 0); i_this->cam_mode = 53; i_this->field_0x754 = 0; } @@ -1698,9 +1708,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { break; } case 60: { - if (i_this->actor.eventInfo.checkCommandDemoAccrpt() == 0) { + if (actor->eventInfo.checkCommandDemoAccrpt() == 0) { fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, 0xffff, 0); - i_this->actor.eventInfo.onCondition(dEvtCnd_CANDEMO_e); + actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); return; } playerCamera->mCamera.Stop(); @@ -1719,7 +1729,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { unkXyz_78.z = 120.0f + XREG_F(1); MtxPosition(&unkXyz_78, &i_this->field_0x760); - i_this->field_0x760 += i_this->actor.current.pos; + i_this->field_0x760 += actor->current.pos; i_this->field_0x76c.x = actor->current.pos.x; i_this->field_0x76c.y = actor->current.pos.y + 150.0f + XREG_F(2); @@ -1758,7 +1768,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { } case 70: { if (i_this->field_0x754 == 10) { - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); if (fshop != NULL) { fshop->field_0x4010 = 1; } @@ -1771,7 +1781,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { playerCamera->mCamera.SetTrimSize(1); } if (i_this->field_0x754 == 0xb) { - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); i_this->field_0x76c = fshop->field_0x4014; i_this->field_0x76c.x += WREG_F(0); @@ -1784,7 +1794,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->field_0x760.z += WREG_F(5); } if (i_this->field_0x754 == 0x12) { - koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); + fshop_class* koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); if (koro_shop != NULL) { koro_shop->field_0x0572 = 1; } @@ -1805,25 +1815,23 @@ static void demo_camera_shop(npc_henna_class* i_this) { if (i_this->field_0x754 >= 2) { if (i_this->field_0x754 == 2) { __memcpy(unkIntArr1, unkLimitsMs1, sizeof(unkLimitsMs1)); - dTimer_createTimer(6, unkIntArr1[lbl_82_bss_91 >> 3], 1, 0, 210.0f, 410.0f, 32.0f, - 419.0f); + int sp_0x54 = lbl_82_bss_91 >> 3; + dTimer_createTimer(6, unkIntArr1[sp_0x54], 1, 0, 210.0f, 410.0f, 32.0f, 419.0f); } - dTimer_c* timer = dComIfG_getTimerPtr(); - if (timer != 0 && i_this->mMsgFlow.doFlow(actor, NULL, 0) != 0) { + if (dComIfG_getTimerPtr() != 0 && i_this->mMsgFlow.doFlow(actor, NULL, 0) != 0) { i_this->cam_mode = 0x48; dComIfG_TimerStart(6, 0); Z2GetAudioMgr()->subBgmStart(Z2BGM_KOROKORO_GAME); - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); - fshop->field_0x4062 = 0; - fshop->field_0x4060 = 0; + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop->field_0x4060 = fshop->field_0x4062 = 0; - koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); - if (koro_shop != NULL) { - koro_shop->field_0x0572 = 1; + fshop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); + if (fshop != NULL) { + fshop->field_0x0572 = 1; } } } @@ -1831,14 +1839,13 @@ static void demo_camera_shop(npc_henna_class* i_this) { } case 72: { if (i_this->field_0x7b9 == 0) { - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); if (fshop != NULL && dTimer_isStart() != 0) { fshop->field_0x4010 = 2; i_this->field_0x7b9 = 1; for (s32 i = 0; i < 100; i++) { - koro = &fshop->field_0x4008->mKoro2[i]; - if ((koro->part_id >= 2 && koro->part_id <= 5) || - (koro->part_id >= 8 && koro->part_id <= 11)) + if ((fshop->field_0x4008->mKoro2[i].part_id >= 2 && fshop->field_0x4008->mKoro2[i].part_id <= 5) || + (fshop->field_0x4008->mKoro2[i].part_id >= 8 && fshop->field_0x4008->mKoro2[i].part_id <= 11)) { fshop->field_0x4008->mKoro2[i].field_0x60 = 1; } @@ -1847,9 +1854,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { } } case 73: { - koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); + fshop_class* koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); unkXyz_54 = koro_shop->actor.current.pos; - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); cMtx_YrotS(*calc_mtx, fshop->field_0x4060); unkXyz_78.x = -500.0f; unkXyz_78.y = 600.0f; @@ -1868,11 +1875,12 @@ static void demo_camera_shop(npc_henna_class* i_this) { cLib_addCalc2(&i_this->field_0x760.y, unkXyz_60.y, 0.3f, 70.0f); cLib_addCalc2(&i_this->field_0x760.z, unkXyz_60.z, 0.3f, 70.0f); } + if (i_this->cam_mode == 0x49) { if (i_this->field_0x754 == 2) { - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); - if (fshop != NULL) { - fshop->field_0x4010 = 1; + fshop_class* fshop2 = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + if (fshop2 != NULL) { + fshop2->field_0x4010 = 1; } dComIfG_TimerDeleteRequest(6); Z2GetAudioMgr()->subBgmStop(); @@ -1891,6 +1899,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { Z2GetAudioMgr()->subBgmStart(Z2BGM_FISHING_BARE); } } + int _; // forces b asm in dbg break; } case 74: { @@ -1906,10 +1915,9 @@ static void demo_camera_shop(npc_henna_class* i_this) { dComIfGp_setItemRupeeCount(0xfffffffb); i_this->cam_mode = 71; i_this->field_0x754 = 0; - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); if (fshop != NULL) { - fshop->field_0x4020.z = 0; - fshop->field_0x4020.x = 0; + fshop->field_0x4020.x = fshop->field_0x4020.z = 0; } koro2_reset = 1; } else { @@ -1927,21 +1935,22 @@ static void demo_camera_shop(npc_henna_class* i_this) { case 75: { i_this->cam_mode = 100; daPy_getPlayerActorClass()->offPlayerNoDraw(); - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); if (fshop != NULL) { fshop->field_0x4010 = 0; fshop->field_0x4020.y = cM_rndFX(2000.0f) + -16384.0f; } - koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); - if (koro_shop != NULL) { - koro_shop->field_0x0572 = 0; + fshop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); + if (fshop != NULL) { + fshop->field_0x0572 = 0; } + int _; // forces b asm in dbg break; } case 76: { if (i_this->field_0x754 == 2) { dComIfG_TimerDeleteRequest(6); - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); if (fshop != NULL) { fshop->field_0x4010 = 1; } @@ -1984,7 +1993,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { } case 77: { if (i_this->field_0x754 == 10) { - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); if (fshop != NULL) { fshop->field_0x4010 = 1; } @@ -1994,7 +2003,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { playerCamera->mCamera.SetTrimSize(1); } if (i_this->field_0x754 == 11) { - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); i_this->field_0x76c = fshop->field_0x4014; i_this->field_0x76c.x += WREG_F(0); @@ -2008,7 +2017,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { } if (i_this->field_0x754 == 0x12) { - koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); + fshop_class* koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); if (koro_shop != NULL) { koro_shop->field_0x0572 = 1; } @@ -2018,7 +2027,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->cam_mode = 78; i_this->field_0x754 = 0; i_this->field_0x756 = 200; - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); fshop->field_0x400c = unk_bss_5134; } break; @@ -2030,6 +2039,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { dComIfGp_setDoStatusForce(0x22, 0); +#if VERSION != VERSION_SHIELD_DEBUG if (unk_bss_5136 == 0) { old_stick_x = 0.0f; unk_bss_5136 = 1; @@ -2038,11 +2048,12 @@ static void demo_camera_shop(npc_henna_class* i_this) { old_stick_sx = 0.0f; unk_bss_5138 = 1; } +#endif - if ((mDoCPd_c::getStickX3D(0) >= 0.8f && old_stick_x < 0.8f || - mDoCPd_c::getStickX3D(0) <= -0.8f && old_stick_x > -0.8f || - mDoCPd_c::getSubStickX(0) >= 0.8f && old_stick_sx < 0.8f || - mDoCPd_c::getSubStickX(0) <= -0.8f && old_stick_sx > -0.8f) && + if (((mDoCPd_c::getStickX3D(0) >= 0.8f && old_stick_x < 0.8f) || + (mDoCPd_c::getStickX3D(0) <= -0.8f && old_stick_x > -0.8f) || + (mDoCPd_c::getSubStickX(0) >= 0.8f && old_stick_sx < 0.8f) || + (mDoCPd_c::getSubStickX(0) <= -0.8f && old_stick_sx > -0.8f)) && i_this->field_0x754 >= 15) { if (mDoCPd_c::getStickX3D(0) >= 0.5f || mDoCPd_c::getSubStickX(0) >= 0.5f) { @@ -2050,7 +2061,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { } else { unk_bss_5134--; } - unk_bss_5134 &= 7; + unk_bss_5134 &= (u8) 7; mDoAud_seStart(Z2SE_SY_CURSOR_FLOOR, 0, 0, 0); i_this->mMsgFlow.remove(); i_this->field_0x754 = 1; @@ -2059,7 +2070,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { old_stick_x = mDoCPd_c::getStickX3D(0); old_stick_sx = mDoCPd_c::getSubStickX(0); - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); fshop->field_0x400c = unk_bss_5134; if (i_this->field_0x754 >= 2) { @@ -2073,10 +2084,11 @@ static void demo_camera_shop(npc_henna_class* i_this) { } } - koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); + fshop_class* koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); if (koro_shop != NULL) { koro_shop->field_0x0572 = 1; } + int _; // forces b asm in dbg break; } case 79: { @@ -2084,33 +2096,33 @@ static void demo_camera_shop(npc_henna_class* i_this) { if (i_this->field_0x754 >= 2) { if (i_this->field_0x754 == 2) { i_this->mMsgFlow.init(actor, 0x34c, 0, NULL); + u32 unkIntArr2[1]; __memcpy(unkIntArr2, unkLimitsMs2, sizeof(unkLimitsMs2)); dTimer_createTimer(6, unkIntArr2[0], 1, 0, 210.0f, 410.0f, 32.0f, 419.0f); } - dTimer_c* timer = dComIfG_getTimerPtr(); - if (timer != 0 && i_this->mMsgFlow.doFlow(actor, NULL, 0) != 0) { + + if (dComIfG_getTimerPtr() != 0 && i_this->mMsgFlow.doFlow(actor, NULL, 0) != 0) { i_this->cam_mode = 0x48; dComIfG_TimerStart(6, 0); Z2GetAudioMgr()->subBgmStart(Z2BGM_KOROKORO_GAME); - fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); - fshop->field_0x4062 = 0; - fshop->field_0x4060 = 0; + fshop_class* fshop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); + fshop->field_0x4060 = fshop->field_0x4062 = 0; - koro_shop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); - if (koro_shop != NULL) { - koro_shop->field_0x0572 = 1; + fshop = (fshop_class*)fpcM_Search(s_koro2ball_sub, i_this); + if (fshop != NULL) { + fshop->field_0x0572 = 1; } } } break; } case 80: { - if (i_this->actor.eventInfo.checkCommandDemoAccrpt() == 0) { + if (actor->eventInfo.checkCommandDemoAccrpt() == 0) { fopAcM_orderPotentialEvent(actor, dEvtCnd_CANDEMO_e, 0xffff, 0); - i_this->actor.eventInfo.onCondition(dEvtCnd_CANDEMO_e); + actor->eventInfo.onCondition(dEvtCnd_CANDEMO_e); return; } playerCamera->mCamera.Stop(); @@ -2163,7 +2175,7 @@ static void demo_camera_shop(npc_henna_class* i_this) { i_this->field_0x750 = 0x14; } if (i_this->cam_mode != 0) { - i_this->field_0x754 = i_this->field_0x754 + 1; + ++i_this->field_0x754; if (i_this->field_0x754 > 10000) { i_this->field_0x754 = 10000; } @@ -2244,7 +2256,8 @@ static void message_guide(npc_henna_class* i_this) { } static void* s_boat_sub(void* param_0, void* param_1) { - if (fopAc_IsActor(param_0)) { + UNUSED(param_1); + if (fopAcM_IsActor(param_0)) { if (fopAcM_GetName(param_0) == PROC_CANOE) { return param_0; } @@ -2297,7 +2310,7 @@ static void env_control(npc_henna_class* i_this) { } if ((counter & mask) == 0 && cM_rndF(1.0f) < unkFloat1) { - OS_REPORT(" FISHING WETHER: %d\n", cDmr_FishingWether); + OS_REPORT(" FISHING WETHER %d\n", cDmr_FishingWether); if (cDmr_FishingWether == 0) { env->wether = 1; } else if (cDmr_FishingWether == 1) { @@ -2316,6 +2329,7 @@ static void env_control(npc_henna_class* i_this) { } static int daNpc_Henna_Execute(npc_henna_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; fopAc_ac_c* unusedPlayer = dComIfGp_getPlayer(0); cXyz lookat_pos; @@ -2323,7 +2337,7 @@ static int daNpc_Henna_Execute(npc_henna_class* i_this) { env_control(i_this); if (i_this->field_0x70a != 0) { - i_this->field_0x70a -= 1; + --i_this->field_0x70a; if (i_this->field_0x70b == 0) { i_this->field_0x694 = 1; i_this->field_0x693 = 0; @@ -2379,30 +2393,30 @@ static int daNpc_Henna_Execute(npc_henna_class* i_this) { daCanoe_c* boat = (daCanoe_c*)fopAcM_SearchByID(i_this->boat_id); if (boat != NULL) { MTXCopy(model->getAnmMtx(2), mDoMtx_stack_c::get()); - mDoMtx_stack_c::multVecZero(&i_this->actor.current.pos); - i_this->actor.current.angle.y = boat->shape_angle.y; + mDoMtx_stack_c::multVecZero(&actor->current.pos); + actor->current.angle.y = boat->shape_angle.y; MTXCopy(boat->getModelMtx(), mDoMtx_stack_c::get()); } else { - mDoMtx_stack_c::transS(i_this->actor.current.pos.x, i_this->actor.current.pos.y, - i_this->actor.current.pos.z); + mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y, + actor->current.pos.z); } } else { - mDoMtx_stack_c::transS(i_this->actor.current.pos.x, - i_this->actor.current.pos.y + i_this->field_0x72c, - i_this->actor.current.pos.z); - mDoMtx_stack_c::YrotM((s16)i_this->actor.shape_angle.y); + mDoMtx_stack_c::transS(actor->current.pos.x, + actor->current.pos.y + i_this->field_0x72c, + actor->current.pos.z); + mDoMtx_stack_c::YrotM((s16)actor->shape_angle.y); mDoMtx_stack_c::transM(0.0f, i_this->field_0x72c, i_this->field_0x730); } mDoMtx_stack_c::scaleM(l_HIO.field_0x8, l_HIO.field_0x8, l_HIO.field_0x8); model->setBaseTRMtx(mDoMtx_stack_c::get()); - i_this->mpMorf->play(&i_this->actor.eyePos, 0, 0); + i_this->mpMorf->play(&actor->eyePos, 0, 0); if ((i_this->mAnmResIndex == 9 || i_this->mAnmResIndex == 10) && (i_this->mpMorf->checkFrame(1.5f) != 0 || i_this->mpMorf->checkFrame(9.5f) != 0 || i_this->mpMorf->checkFrame(17.5f) != 0)) { - fopAcM_seStart(&i_this->actor, Z2SE_HENA_CLAP, 0); + fopAcM_seStart(actor, Z2SE_HENA_CLAP, 0); } if (i_this->field_0x6ba != 0) { @@ -2478,13 +2492,13 @@ static int daNpc_Henna_Execute(npc_henna_class* i_this) { if (i_this->arg0 == 1) { fshop_class* shop = (fshop_class*)fpcM_Search(s_shop_sub, i_this); if (shop != NULL) { - s32 unkInt1 = shop->field_0x6b34 * cM_ssin(shop->field_0x6b34 * 6500) * + s16 sp_0xe = shop->field_0x6b34 * cM_ssin(shop->field_0x6b34 * 6500) * (-50.0f + JREG_F(7)); mDoMtx_stack_c::transS(-460.0f + AREG_F(0), 51.0f + AREG_F(1), -240.0f + AREG_F(2)); mDoMtx_stack_c::YrotM(-17729 + AREG_S(0)); - mDoMtx_stack_c::XrotM(32505 + AREG_S(1)); - mDoMtx_stack_c::ZrotM(unkInt1 + 2000 + AREG_S(2)); + mDoMtx_stack_c::XrotM(AREG_S(1) - 0x8107); + mDoMtx_stack_c::ZrotM(AREG_S(2) + 2000 + sp_0xe); } else { mDoMtx_stack_c::transS(-790.0f + AREG_F(0), 153.0f + AREG_F(1), 590.0f + AREG_F(2)); @@ -2501,10 +2515,10 @@ static int daNpc_Henna_Execute(npc_henna_class* i_this) { i_this->mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); MTXCopy(model->getAnmMtx(4), mDoMtx_stack_c::get()); - mDoMtx_stack_c::multVecZero(&i_this->actor.eyePos); - i_this->actor.eyePos.x = i_this->actor.eyePos.x + NREG_F(8); - i_this->actor.attention_info.position = i_this->actor.eyePos; - i_this->actor.attention_info.position.y += 40.0f; + mDoMtx_stack_c::multVecZero(&actor->eyePos); + actor->eyePos.y += NREG_F(8); + actor->attention_info.position = actor->eyePos; + actor->attention_info.position.y += 40.0f; if (i_this->arg0 == 1) { message_shop(i_this); @@ -2523,11 +2537,10 @@ static int daNpc_Henna_Execute(npc_henna_class* i_this) { lookat_pos.z = camera->lookat.center.z - camera->lookat.eye.z; s16 camera_rot = cM_atan2s(lookat_pos.x, lookat_pos.z); - lookat_pos.x = i_this->actor.current.pos.x - camera->lookat.eye.x; - lookat_pos.z = i_this->actor.current.pos.z - camera->lookat.eye.z; - s16 lookat_rot = cM_atan2s(lookat_pos.x, lookat_pos.z); + lookat_pos.x = actor->current.pos.x - camera->lookat.eye.x; + lookat_pos.z = actor->current.pos.z - camera->lookat.eye.z; - s16 angle_diff = lookat_rot - camera_rot; + s16 angle_diff = cM_atan2s(lookat_pos.x, lookat_pos.z) - camera_rot; if (i_this->cam_mode == 0 && (angle_diff > 0x4000 || angle_diff < -0x4000) && JMAFastSqrt(lookat_pos.x * lookat_pos.x + lookat_pos.z * lookat_pos.z) > AREG_F(11) + 500.0f) { @@ -2536,11 +2549,11 @@ static int daNpc_Henna_Execute(npc_henna_class* i_this) { } if (lbl_82_bss_90 != 0) { + GXColor lightColor; dScnKy_env_light_c* kankyo = dKy_getEnvlight(); f32 lightDist; s16 lightAngle; - GXColor lightColor; if (kankyo->fishing_hole_season == 2) { lightColor.r = l_HIO.mSeason2ColorR; lightColor.g = l_HIO.mSeason2ColorG; @@ -2562,26 +2575,29 @@ static int daNpc_Henna_Execute(npc_henna_class* i_this) { } lightColor.a = -1; - cMtx_YrotS(*calc_mtx, i_this->actor.shape_angle.y + lightAngle * 0xb6); + cMtx_YrotS(*calc_mtx, actor->shape_angle.y + lightAngle * 0xb6); lookat_pos.x = 0.0f; lookat_pos.y = 200.0f + BREG_F(10); lookat_pos.z = 500.0f + BREG_F(11); MtxPosition(&lookat_pos, &target_pos); - target_pos += i_this->actor.current.pos; + target_pos += actor->current.pos; dKy_BossLight_set(&target_pos, &lightColor, lightDist, 0); } return 1; } -static bool daNpc_Henna_IsDelete(npc_henna_class* param_0) { - return true; +static int daNpc_Henna_IsDelete(npc_henna_class*) { + return 1; } static int daNpc_Henna_Delete(npc_henna_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; // unused + fopAcM_RegisterDeleteID(i_this, "Npc_Henna"); dComIfG_resDelete(&i_this->phase, "Henna"); if (i_this->hio_init != 0) { hio_set = 0; + mDoHIO_DELETE_CHILD(l_HIO.id); } return 1; } @@ -2615,7 +2631,7 @@ static int useHeapInit(fopAc_ac_c* i_this) { } J3DModel* morfModel = a_this->mpMorf->getModel(); - morfModel->setUserArea((s32)i_this); + morfModel->setUserArea((s32)a_this); for (u16 i = 0; i < morfModel->getModelData()->getJointNum(); i++) { morfModel->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack); @@ -2626,9 +2642,10 @@ static int useHeapInit(fopAc_ac_c* i_this) { if (a_this->mpBtkAnms[i] == NULL) { return 0; } - J3DAnmTextureSRTKey* srtKey = (J3DAnmTextureSRTKey*)dComIfG_getObjectRes("Henna", btk_d[i]); - morfModel = a_this->mpMorf->getModel(); - if (a_this->mpBtkAnms[i]->init(morfModel->getModelData(), srtKey, 1, 0, 1.0f, 0, -1) == 0) { + + if (a_this->mpBtkAnms[i]->init(a_this->mpMorf->getModel()->getModelData(), + (J3DAnmTextureSRTKey*) dComIfG_getObjectRes("Henna", btk_d[i]), + 1, 0, 1.0f, 0, -1) == 0) { return 0; } } @@ -2638,10 +2655,10 @@ static int useHeapInit(fopAc_ac_c* i_this) { if (a_this->mpBtpAnms[i] == NULL) { return 0; } - J3DAnmTexPattern* texPattern = (J3DAnmTexPattern*)dComIfG_getObjectRes("Henna", btp_d[i]); - morfModel = a_this->mpMorf->getModel(); - if (a_this->mpBtpAnms[i]->init(morfModel->getModelData(), texPattern, 1, 2, 1.0f, 0, -1) == - 0) + + if (a_this->mpBtpAnms[i]->init(a_this->mpMorf->getModel()->getModelData(), + (J3DAnmTexPattern*) dComIfG_getObjectRes("Henna", btp_d[i]), + 1, 2, 1.0f, 0, -1) == 0) { return 0; } @@ -2652,12 +2669,12 @@ static int useHeapInit(fopAc_ac_c* i_this) { if (a_this->mpBckAnms[i] == 0) { return 0; } - J3DAnmTransform* anmTransform = - (J3DAnmTransform*)dComIfG_getObjectRes("Henna", facebck_d[i]); - if (a_this->mpBckAnms[i]->init(anmTransform, 1, 2, 1.0f, 0, -1, false) == 0) { + + if (a_this->mpBckAnms[i]->init((J3DAnmTransform*)dComIfG_getObjectRes("Henna", facebck_d[i]), 1, 2, 1.0f, 0, -1, false) == 0) { return 0; } } + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Henna", 0x24); JUT_ASSERT(6547, modelData != NULL); a_this->mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); @@ -2669,8 +2686,8 @@ static int useHeapInit(fopAc_ac_c* i_this) { } static int daNpc_Henna_Create(fopAc_ac_c* i_this) { - fopAcM_ct(i_this, npc_henna_class); npc_henna_class* a_this = (npc_henna_class*)i_this; + fopAcM_ct(&a_this->actor, npc_henna_class); cPhs_Step loadResult = dComIfG_resLoad(&a_this->phase, "Henna"); if (loadResult == cPhs_COMPLEATE_e) { @@ -2697,7 +2714,7 @@ static int daNpc_Henna_Create(fopAc_ac_c* i_this) { a_this->field_0x70c = 1; a_this->action = 0x32; a_this->timer[5] = cM_rndF(1000.0f) + 1000.0f; - i_this->current.pos.set(-380.0f + TREG_F(10), 0.0f, 450.0f + TREG_F(10)); + i_this->current.pos.set(-380.0f + TREG_F(10), 0.0f, 450.0f + TREG_F(11)); i_this->old = i_this->current; s16 newAngle = 0x6000; if (data_80450C9C != 0) { @@ -2734,10 +2751,10 @@ static int daNpc_Henna_Create(fopAc_ac_c* i_this) { } else { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); if (strcmp(dComIfGp_getStartStageName(), "F_SP127") == 0) { + cXyz npcDfPos; a_this->action = 0x3c; a_this->cam_mode = 100; lbl_82_bss_90 = 1; - cXyz npcDfPos; if (kankyo->fishing_hole_season == 3) { fopAc_ac_c* player = dComIfGp_getPlayer(0); npcDfPos.set(player->current.pos.x, player->current.pos.y + 700.0f, @@ -2783,23 +2800,25 @@ static int daNpc_Henna_Create(fopAc_ac_c* i_this) { cXyz mae; cXyz ato; csXyz angl(0.0f, 0.0f, 0.0f); - s32 parameter; - for (s32 i = 0; i < 50; i++) { - parameter = (s32)(cM_rndFX(5.0f) + 30.0f) << 8 | 0x5; - mDoMtx_YrotS(*calc_mtx, cM_rndF(65536.0f)); + int sp_0x18, sp_0x14, i; + for (i = 0; i < 50; i++) { + sp_0x18 = 5; + sp_0x14 = (cM_rndFX(5.0f) + 30.0f); + sp_0x18 |= (sp_0x14 << 8); + cMtx_YrotS(*calc_mtx, cM_rndF(65536.0f)); ato.x = 0.0f; ato.y = cM_rndFX(50.0f) + -160.0f; ato.z = cM_rndF(2300.0f); MtxPosition(&ato, &mae); angl.y = cM_rndF(65536.0f); - fopAcM_create(PROC_MG_FISH, parameter, &mae, fopAcM_GetRoomNo(i_this), + fopAcM_create(PROC_MG_FISH, sp_0x18, &mae, fopAcM_GetRoomNo(i_this), &angl, NULL, -1); } fopAcM_create(PROC_NPC_NE, 0xffffff01, &i_this->home.pos, fopAcM_GetRoomNo(i_this), NULL, NULL, -1); } + a_this->boat_id = -1; - csXyz unused; if (kankyo->fishing_hole_season != 4 && cDmr_FishingWether == 6) { cDmr_FishingWether = 0; } else if (kankyo->fishing_hole_season == 4 && @@ -2807,12 +2826,14 @@ static int daNpc_Henna_Create(fopAc_ac_c* i_this) { { cDmr_FishingWether = 0; } + kankyo->wether = cDmr_FishingWether; lbl_82_bss_289 = 1; daNpc_Henna_Execute(a_this); lbl_82_bss_289 = 0; } } + return loadResult; } diff --git a/src/d/actor/d_a_npc_ks.cpp b/src/d/actor/d_a_npc_ks.cpp index de11edd71d6..6c5d3832f41 100644 --- a/src/d/actor/d_a_npc_ks.cpp +++ b/src/d/actor/d_a_npc_ks.cpp @@ -326,13 +326,6 @@ static void* s_b_sub(void* i_actor, void* i_data) { static int target_bgc[10]; -// FIXME: possible fakematch? -#if DEBUG -#define NPC_KS_FABSF fabsf -#else -#define NPC_KS_FABSF std::fabsf -#endif - static fopAc_ac_c* search_bomb(npc_ks_class* i_this, int param_2) { fopAc_ac_c* actor = &i_this->actor; fopAc_ac_c* actor_p; @@ -362,7 +355,7 @@ static fopAc_ac_c* search_bomb(npc_ks_class* i_this, int param_2) { if (target_bgc[i] != 0 || fopAcM_otherBgCheck(actor, actor_p)) { target_bgc[i] = 1; - } else if (NPC_KS_FABSF(sp4c.y) <= 300.0f) { + } else if (FABSF(sp4c.y) <= 300.0f) { s16 sVar1 = actor->shape_angle.y - cM_atan2s(sp4c.x, sp4c.z); if (sVar1 < 0) { sVar1 = -1 * sVar1; @@ -448,7 +441,7 @@ static fopAc_ac_c* search_enemy(npc_ks_class* i_this, int param_2, f32 param_3) if (target_bgc[i] != 0 || fopAcM_otherBgCheck(actor, enemy_p)) { target_bgc[i] = 1; - } else if (NPC_KS_FABSF(mae.y) <= fVar2) { + } else if (FABSF(mae.y) <= fVar2) { s16 sVar1 = actor->shape_angle.y - cM_atan2s(mae.x, mae.z); if (sVar1 < 0) { sVar1 = -1 * sVar1; @@ -1241,7 +1234,7 @@ static int npc_ks_demo_02(npc_ks_class* i_this) { cLib_addCalc2(&actor->current.pos.z, ato.z, 1.0f, 10.0f); cLib_addCalc2(&actor->current.pos.y, i_this->ObjAcch.GetGroundH(), 1.0f, l_HIO.demo_speed); - if (NPC_KS_FABSF(actor->current.pos.y - i_this->ObjAcch.GetGroundH()) < 1.0f) { + if (FABSF(actor->current.pos.y - i_this->ObjAcch.GetGroundH()) < 1.0f) { anm_init(i_this, 26, 5.0f, 2, 1.0f); actor->speedF = 0.0f; i_this->timer[0] = 20; @@ -2709,9 +2702,9 @@ static void demo_camera(npc_ks_class* i_this) { i_this->field_0xb6c.y = i_this->field_0xb6c.y - 150.0f; i_this->field_0xb6c.z = saru_p[sw_p->field_0x91c - 2]->actor.current.pos.z; - i_this->field_0xb84.x = NPC_KS_FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); - i_this->field_0xb84.y = NPC_KS_FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); - i_this->field_0xb84.z = NPC_KS_FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); + i_this->field_0xb84.x = FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); + i_this->field_0xb84.y = FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); + i_this->field_0xb84.z = FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); i_this->field_0xbc4 = 0.0f; i_this->demo_camera_no = 5; } else { @@ -3032,12 +3025,12 @@ static void demo_camera(npc_ks_class* i_this) { i_this->field_0xb6c.set(12772.0f, 3940.0f, 3565.0f); i_this->field_0xb54.set(13003.0f, 4022.0f, 3613.0f); - i_this->field_0xb78.x = NPC_KS_FABSF(i_this->field_0xb54.x - i_this->demo_way.x); - i_this->field_0xb78.y = NPC_KS_FABSF(i_this->field_0xb54.y - i_this->demo_way.y); - i_this->field_0xb78.z = NPC_KS_FABSF(i_this->field_0xb54.z - i_this->demo_way.z); - i_this->field_0xb84.x = NPC_KS_FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); - i_this->field_0xb84.y = NPC_KS_FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); - i_this->field_0xb84.z = NPC_KS_FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); + i_this->field_0xb78.x = FABSF(i_this->field_0xb54.x - i_this->demo_way.x); + i_this->field_0xb78.y = FABSF(i_this->field_0xb54.y - i_this->demo_way.y); + i_this->field_0xb78.z = FABSF(i_this->field_0xb54.z - i_this->demo_way.z); + i_this->field_0xb84.x = FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); + i_this->field_0xb84.y = FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); + i_this->field_0xb84.z = FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); i_this->field_0xbc4 = 0.0f; // fallthrough case 111: @@ -3104,9 +3097,9 @@ static void demo_camera(npc_ks_class* i_this) { i_this->demo_way.set(-22672.0f, 311.0f, -15080.0f); i_this->field_0xb6c.set(-22343.0f, 273.0f, -15017.0f); i_this->field_0xb78.set(0.0f, 0.0f, 0.0f); - i_this->field_0xb84.x = NPC_KS_FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); - i_this->field_0xb84.y = NPC_KS_FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); - i_this->field_0xb84.z = NPC_KS_FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); + i_this->field_0xb84.x = FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); + i_this->field_0xb84.y = FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); + i_this->field_0xb84.z = FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); i_this->field_0xbc4 = 0.0f; /* dSv_event_flag_c::F_0224 - Faron Woods - Flag for lantern guide monkey cutscene */ dComIfGs_onEventBit(u16(dSv_event_flag_c::saveBitLabels[0xE0])); @@ -3314,12 +3307,12 @@ static void demo_camera(npc_ks_class* i_this) { i_this->field_0xb6c.set(-36574.0f, 421.0f, -21554.0f); i_this->field_0xb54.set(-36397.0f, 374.0f, -20263.0f); - i_this->field_0xb78.x = NPC_KS_FABSF(i_this->field_0xb54.x - i_this->demo_way.x); - i_this->field_0xb78.y = NPC_KS_FABSF(i_this->field_0xb54.y - i_this->demo_way.y); - i_this->field_0xb78.z = NPC_KS_FABSF(i_this->field_0xb54.z - i_this->demo_way.z); - i_this->field_0xb84.x = NPC_KS_FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); - i_this->field_0xb84.y = NPC_KS_FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); - i_this->field_0xb84.z = NPC_KS_FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); + i_this->field_0xb78.x = FABSF(i_this->field_0xb54.x - i_this->demo_way.x); + i_this->field_0xb78.y = FABSF(i_this->field_0xb54.y - i_this->demo_way.y); + i_this->field_0xb78.z = FABSF(i_this->field_0xb54.z - i_this->demo_way.z); + i_this->field_0xb84.x = FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); + i_this->field_0xb84.y = FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); + i_this->field_0xb84.z = FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); i_this->field_0xbc4 = 0.0f; i_this->demo_mode = 352; i_this->demo_camera_no = 0; @@ -3370,12 +3363,12 @@ static void demo_camera(npc_ks_class* i_this) { i_this->field_0xb6c.set(-38113.0f, 1234.0f, -22897.0f); i_this->field_0xb54.set(-37882.0f, 1182.0f, -22713.0f); - i_this->field_0xb78.x = NPC_KS_FABSF(i_this->field_0xb54.x - i_this->demo_way.x); - i_this->field_0xb78.y = NPC_KS_FABSF(i_this->field_0xb54.y - i_this->demo_way.y); - i_this->field_0xb78.z = NPC_KS_FABSF(i_this->field_0xb54.z - i_this->demo_way.z); - i_this->field_0xb84.x = NPC_KS_FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); - i_this->field_0xb84.y = NPC_KS_FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); - i_this->field_0xb84.z = NPC_KS_FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); + i_this->field_0xb78.x = FABSF(i_this->field_0xb54.x - i_this->demo_way.x); + i_this->field_0xb78.y = FABSF(i_this->field_0xb54.y - i_this->demo_way.y); + i_this->field_0xb78.z = FABSF(i_this->field_0xb54.z - i_this->demo_way.z); + i_this->field_0xb84.x = FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); + i_this->field_0xb84.y = FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); + i_this->field_0xb84.z = FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); i_this->field_0xbc4 = 0.0f; anm_init(i_this, 39, 5.0f, 2, 1.0f); i_this->mode = 41; @@ -3412,12 +3405,12 @@ static void demo_camera(npc_ks_class* i_this) { i_this->field_0xb6c.set(-36467.0f, 426.0f, -20914.0f); i_this->field_0xb54.set(-36244.0f, 409.0f, -20714.0f); - i_this->field_0xb78.x = NPC_KS_FABSF(i_this->field_0xb54.x - i_this->demo_way.x); - i_this->field_0xb78.y = NPC_KS_FABSF(i_this->field_0xb54.y - i_this->demo_way.y); - i_this->field_0xb78.z = NPC_KS_FABSF(i_this->field_0xb54.z - i_this->demo_way.z); - i_this->field_0xb84.x = NPC_KS_FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); - i_this->field_0xb84.y = NPC_KS_FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); - i_this->field_0xb84.z = NPC_KS_FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); + i_this->field_0xb78.x = FABSF(i_this->field_0xb54.x - i_this->demo_way.x); + i_this->field_0xb78.y = FABSF(i_this->field_0xb54.y - i_this->demo_way.y); + i_this->field_0xb78.z = FABSF(i_this->field_0xb54.z - i_this->demo_way.z); + i_this->field_0xb84.x = FABSF(i_this->field_0xb6c.x - i_this->demo_eye.x); + i_this->field_0xb84.y = FABSF(i_this->field_0xb6c.y - i_this->demo_eye.y); + i_this->field_0xb84.z = FABSF(i_this->field_0xb6c.z - i_this->demo_eye.z); i_this->field_0xbc4 = 0.0f; } i_this->msg_flow.doFlow(actor, NULL, 0); @@ -3943,7 +3936,7 @@ static int npc_ks_option(npc_ks_class* i_this) { gnd_chk.SetPos(&ato); ato.y = dComIfG_Bgsp().GroundCross(&gnd_chk); yuka_jump_x *= -1.0f; - if (NPC_KS_FABSF(ato.y - player->current.pos.y) < 20.0f) { + if (FABSF(ato.y - player->current.pos.y) < 20.0f) { i_this->mode = 51; i_this->guide_path = ato; i_this->field_0x910 = actor->current.pos; @@ -4048,7 +4041,7 @@ static int npc_ks_option(npc_ks_class* i_this) { fopAc_ac_c* player3 = (fopAc_ac_c*) dComIfGp_getPlayer(0); if (iVar2 != 0) { - if (NPC_KS_FABSF(player3->current.pos.y - actor->current.pos.y) > 3000.0f || + if (FABSF(player3->current.pos.y - actor->current.pos.y) > 3000.0f || (fopAcM_CheckCondition(actor, 4) != 0 && fopAcM_otherBgCheck(actor, dComIfGp_getPlayer(0)))) { if (iVar1 != 0 && player3->speedF > 2.0f) { camera_class* camera = (camera_class*) dComIfGp_getCamera(0); @@ -4063,7 +4056,7 @@ static int npc_ks_option(npc_ks_class* i_this) { dBgS_GndChk gnd_chk; gnd_chk.SetPos(&ato); - if (NPC_KS_FABSF(ato.y - dComIfG_Bgsp().GroundCross(&gnd_chk)) < 500.0f) { + if (FABSF(ato.y - dComIfG_Bgsp().GroundCross(&gnd_chk)) < 500.0f) { actor->current.pos = ato; actor->old = actor->current; OS_REPORT("////////KS OP RESET \n"); @@ -6441,7 +6434,7 @@ static void action(npc_ks_class* i_this) { } } - if (int_0x2c && i_this->dis < 500.0f + KREG_F(15) && NPC_KS_FABSF(actor->current.pos.y - player->current.pos.y) < 1000.0f) { + if (int_0x2c && i_this->dis < 500.0f + KREG_F(15) && FABSF(actor->current.pos.y - player->current.pos.y) < 1000.0f) { daPy_py_c::setLookPos(&actor->eyePos); } @@ -6787,9 +6780,9 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { if (i_this->field_0x620 != 0) { if (i_this->field_0x620 == 1) { - cLib_addCalc2(&obj_pos.x, i_this->field_0x614.x, 1.0f, NPC_KS_FABSF(i_this->field_0x624.x) + 4.0f); - cLib_addCalc2(&obj_pos.y, i_this->field_0x614.y, 1.0f, NPC_KS_FABSF(i_this->field_0x624.y) + 4.0f); - cLib_addCalc2(&obj_pos.z, i_this->field_0x614.z, 1.0f, NPC_KS_FABSF(i_this->field_0x624.z) + 4.0f); + cLib_addCalc2(&obj_pos.x, i_this->field_0x614.x, 1.0f, FABSF(i_this->field_0x624.x) + 4.0f); + cLib_addCalc2(&obj_pos.y, i_this->field_0x614.y, 1.0f, FABSF(i_this->field_0x624.y) + 4.0f); + cLib_addCalc2(&obj_pos.z, i_this->field_0x614.z, 1.0f, FABSF(i_this->field_0x624.z) + 4.0f); mae.x = obj_pos.x - i_this->field_0x614.x; mae.z = obj_pos.z - i_this->field_0x614.z; if ((mae.x * mae.x + mae.z * mae.z) <= 15.0f) {