From 3ed6cb7bb355c590e76cbac041d41d78876228a3 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 3 Aug 2024 00:45:25 -0700 Subject: [PATCH] d_a_kytag02, d_a_kytag03 work --- include/d/actor/d_a_kytag03.h | 6 +- include/d/d_kankyo.h | 2 + src/d/actor/d_a_kytag02.cpp | 93 +++++++++++++++++++----- src/d/actor/d_a_kytag03.cpp | 129 +++++++++++++++++++++++++++++---- src/d/actor/d_a_obj_gaship.cpp | 4 - 5 files changed, 197 insertions(+), 37 deletions(-) diff --git a/include/d/actor/d_a_kytag03.h b/include/d/actor/d_a_kytag03.h index dab7e0485..b0f31b252 100644 --- a/include/d/actor/d_a_kytag03.h +++ b/include/d/actor/d_a_kytag03.h @@ -10,12 +10,14 @@ class kytag03_class : public fopAc_ac_c { public: /* 0x290 */ request_of_phase_process_class mPhs; /* 0x298 */ mDoExt_McaMorf* mpModel; - /* 0x29C */ u8 m29C[0x2A1 - 0x29C]; + /* 0x29C */ u32 field_0x29c; + /* 0x2A0 */ u8 field_0x2a0; /* 0x2A1 */ u8 mSwitchID; /* 0x2A2 */ u8 mbRoomActive; /* 0x2A3 */ u8 mbVisible; /* 0x2A4 */ u8 mbIsActive; - /* 0x2A5 */ u8 m2A5[0x2AC - 0x2A5]; + /* 0x2A5 */ u8 m2A5; + /* 0x2A8 */ f32 field_0x2a8; }; #endif /* D_A_KYTAG03_H */ diff --git a/include/d/d_kankyo.h b/include/d/d_kankyo.h index fc67e13ae..6b0af5dda 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -455,5 +455,7 @@ u8 dKy_get_schbit(); int dKy_rain_check(); void dKy_setLight_mine(dKy_tevstr_c* pTevStr); BOOL dKy_daynighttact_stop_chk(); +void dKy_contrast_flg_set(u8); +u8 dKy_contrast_flg_get(); #endif /* D_KANKYO_D_KANKYO_H */ diff --git a/src/d/actor/d_a_kytag02.cpp b/src/d/actor/d_a_kytag02.cpp index 7785723bb..5b8753168 100644 --- a/src/d/actor/d_a_kytag02.cpp +++ b/src/d/actor/d_a_kytag02.cpp @@ -4,56 +4,113 @@ // #include "d/actor/d_a_kytag02.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo_rain.h" #include "d/d_procname.h" +#include "f_op/f_op_actor_mng.h" /* 00000078-000000C0 .text set_path_info__FP10fopAc_ac_c */ -void set_path_info(fopAc_ac_c*) { - /* Nonmatching */ +dPath* set_path_info(fopAc_ac_c* i_ac) { + dPath* ret = NULL; + u8 pathId = (fopAcM_GetParam(i_ac) >> 16); + if (pathId != 0xFF) + ret = dPath_GetRoomPath(pathId, i_ac->current.roomNo); + return ret; } /* 000000C0-000000F0 .text set_next_path_info__FP13kytag02_classP5dPath */ -void set_next_path_info(kytag02_class*, dPath*) { - /* Nonmatching */ +dPath* set_next_path_info(kytag02_class* i_this, dPath* path) { + return dPath_GetNextRoomPath(path, i_this->current.roomNo); } /* 000000F0-0000017C .text get_railwind_vec__FP5dPathi */ -void get_railwind_vec(dPath*, int) { +cXyz get_railwind_vec(dPath* path, int i_no) { /* Nonmatching */ + cXyz ret; + cXyz p0 = path->mpPnt[i_no + 0].mPos; + cXyz p1 = path->mpPnt[i_no + 1].mPos; + dKyr_get_vectle_calc(&p0, &p1, &ret); + return ret; } /* 0000017C-000002E8 .text get_nearpos_rail__FP13kytag02_classP5dPathP4cXyzPi */ -void get_nearpos_rail(kytag02_class*, dPath*, cXyz*, int*) { +dPath* get_nearpos_rail(kytag02_class* i_this, dPath* i_path, cXyz* pos, int* i_no) { /* Nonmatching */ + dPath* path; + dPath* bestPath; + f32 best; + int bestIdx; + + bestIdx = 0; + path = i_path; + best = 1000000000.0f; + bestPath = path; + + while (true) { + for (s32 i = 0; i < path->m_num; i++) { + f32 dx = path->mpPnt[i].mPos.x - pos->x; + f32 dz = path->mpPnt[i].mPos.z - pos->z; + f32 dist = sqrtf(dx*dx + dz*dz); + if (best > dist) { + bestPath = path; + bestIdx = i; + best = dist; + } + } + + if (path->mNextPathId == 0xFFFF) + break; + path = set_next_path_info(i_this, path); + } + if (bestIdx == i_path->m_num - 1) + bestIdx--; + *i_no = bestIdx; + return bestPath; } /* 000002E8-000003D4 .text windtag_move__FP13kytag02_class */ -void windtag_move(kytag02_class*) { - /* Nonmatching */ +void windtag_move(kytag02_class* i_this) { + fopAc_ac_c* player = dComIfGp_getPlayer(0); + int i_no; + + if (i_this->mpPath != NULL) { + dPath* path = get_nearpos_rail(i_this, i_this->mpPath, &player->current.pos, &i_no); + i_this->mWindVec = get_railwind_vec(path, i_no); + g_env_light.mWind.mpWindVecOverride = &i_this->mWindVec; + dPath__Point* pnt = &path->mpPnt[i_no]; + u32 strength = (s32)pnt->mArg3 != 0xFF ? pnt->mArg3 : path->mArg0; + g_env_light.mWind.mWindStrengthOverride = (f32)strength / 100.0f; + } } /* 000003D4-000003DC .text daKytag02_Draw__FP13kytag02_class */ -static BOOL daKytag02_Draw(kytag02_class*) { - /* Nonmatching */ +static BOOL daKytag02_Draw(kytag02_class* i_this) { + return TRUE; } /* 000003DC-00000400 .text daKytag02_Execute__FP13kytag02_class */ -static BOOL daKytag02_Execute(kytag02_class*) { - /* Nonmatching */ +static BOOL daKytag02_Execute(kytag02_class* i_this) { + windtag_move(i_this); + return TRUE; } /* 00000400-00000408 .text daKytag02_IsDelete__FP13kytag02_class */ -static BOOL daKytag02_IsDelete(kytag02_class*) { - /* Nonmatching */ +static BOOL daKytag02_IsDelete(kytag02_class* i_this) { + return TRUE; } /* 00000408-00000420 .text daKytag02_Delete__FP13kytag02_class */ -static BOOL daKytag02_Delete(kytag02_class*) { - /* Nonmatching */ +static BOOL daKytag02_Delete(kytag02_class* i_this) { + g_env_light.mWind.mpWindVecOverride = NULL; + return TRUE; } /* 00000420-0000047C .text daKytag02_Create__FP10fopAc_ac_c */ -static s32 daKytag02_Create(fopAc_ac_c*) { - /* Nonmatching */ +static s32 daKytag02_Create(fopAc_ac_c* i_ac) { + kytag02_class* i_this = (kytag02_class*)i_ac; + fopAcM_SetupActor(i_this, kytag02_class); + i_this->mpPath = set_path_info(i_this); + return cPhs_COMPLEATE_e; } static actor_method_class l_daKytag02_Method = { diff --git a/src/d/actor/d_a_kytag03.cpp b/src/d/actor/d_a_kytag03.cpp index 01c6c09be..d810df478 100644 --- a/src/d/actor/d_a_kytag03.cpp +++ b/src/d/actor/d_a_kytag03.cpp @@ -4,41 +4,144 @@ // #include "d/actor/d_a_kytag03.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo.h" #include "d/d_procname.h" +#include "d/res/res_m_door.h" /* 00000078-0000015C .text useHeapInit__FP10fopAc_ac_c */ -static BOOL useHeapInit(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL useHeapInit(fopAc_ac_c* i_ac) { + kytag03_class* i_this = (kytag03_class*)i_ac; + i_this->mpModel = new mDoExt_McaMorf( + (J3DModelData*)dComIfG_getObjectRes("M_DOOR", M_DOOR_BDL_MYAMIF), + NULL, NULL, NULL, J3DFrameCtrl::LOOP_REPEAT_e, 0.0f, 0, -1, 1, NULL, 0x0, 0x11020203 + ); + + if (i_this->mpModel == NULL || i_this->mpModel->getModel() == NULL) + return FALSE; + + return TRUE; } /* 0000015C-000001D8 .text daKytag03_Draw__FP13kytag03_class */ -static BOOL daKytag03_Draw(kytag03_class*) { - /* Nonmatching */ +static BOOL daKytag03_Draw(kytag03_class* i_this) { + J3DModel* model = i_this->mpModel->getModel(); + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->current.pos, &i_this->tevStr); + g_env_light.setLightTevColorType(model, &i_this->tevStr); + if (i_this->mbVisible) + i_this->mpModel->updateDL(); + return TRUE; } /* 000001D8-00000280 .text draw_SUB__FP13kytag03_class */ -void draw_SUB(kytag03_class*) { - /* Nonmatching */ +void draw_SUB(kytag03_class* i_this) { + J3DModel* model = i_this->mpModel->getModel(); + model->setBaseScale(i_this->scale); + mDoMtx_stack_c::transS(i_this->current.pos); + mDoMtx_stack_c::YrotM(i_this->shape_angle.y); + mDoMtx_stack_c::XrotM(i_this->shape_angle.x); + mDoMtx_stack_c::ZrotM(i_this->shape_angle.z); + model->setBaseTRMtx(mDoMtx_stack_c::get()); } /* 00000280-0000050C .text daKytag03_Execute__FP13kytag03_class */ -static BOOL daKytag03_Execute(kytag03_class*) { +static BOOL daKytag03_Execute(kytag03_class* i_this) { /* Nonmatching */ + fopAc_ac_c* player = dComIfGp_getPlayer(0); + if (!dComIfGp_event_runCheck() || !dComIfGp_event_chkEventFlag(dEvtFlag_STAFF_ALL_e)) { + if (i_this->tevStr.mRoomNo == dStage_roomControl_c::getStayNo()) { + i_this->mbRoomActive = true; + if (i_this->mSwitchID != 0xFF) { + if (dComIfGs_isSwitch(i_this->mSwitchID, i_this->tevStr.mRoomNo)) { + if (!dKy_contrast_flg_get()) { + dKy_contrast_flg_set(true); + dKy_change_colpat(4); + } + + i_this->mbIsActive = true; + } else { + if (dKy_contrast_flg_get()) { + dKy_contrast_flg_set(false); + dKy_change_colpat(0); + } + + i_this->mbIsActive = false; + } + } + } + } else if (!i_this->mbRoomActive) { + if (i_this->tevStr.mRoomNo != dStage_roomControl_c::getStayNo()) { + if (i_this->mSwitchID != 0xFF) { + if (dComIfGs_isSwitch(i_this->mSwitchID, i_this->tevStr.mRoomNo)) { + if (!dKy_contrast_flg_get()) { + dKy_contrast_flg_set(true); + dKy_change_colpat(4); + } + + i_this->mbIsActive = true; + } else { + if (dKy_contrast_flg_get()) { + dKy_contrast_flg_set(false); + dKy_change_colpat(0); + } + + i_this->mbIsActive = false; + } + } + } + } else if (i_this->tevStr.mRoomNo != dStage_roomControl_c::getStayNo()) { + if (!i_this->mbIsActive && dKy_contrast_flg_get()) { + if (!i_this->mbVisible) { + s16 angleY = 0; + cXyz pos; + pos.x = cM_scos(angleY) * cM_ssin(player->shape_angle.y); + pos.y = cM_ssin(angleY); + pos.z = cM_scos(angleY) * cM_scos(player->shape_angle.y); + i_this->current.pos = player->current.pos + pos * -100.0f; + i_this->current.angle.y = player->current.angle.y; + i_this->shape_angle.y = player->shape_angle.y; + } + i_this->mbVisible = true; + } + } + + if (i_this->mbVisible) { + i_this->mpModel->play(NULL, 0, 0); + draw_SUB(i_this); + } + + return TRUE; } /* 0000050C-00000514 .text daKytag03_IsDelete__FP13kytag03_class */ -static BOOL daKytag03_IsDelete(kytag03_class*) { - /* Nonmatching */ +static BOOL daKytag03_IsDelete(kytag03_class* i_this) { + return TRUE; } /* 00000514-00000544 .text daKytag03_Delete__FP13kytag03_class */ -static BOOL daKytag03_Delete(kytag03_class*) { - /* Nonmatching */ +static BOOL daKytag03_Delete(kytag03_class* i_this) { + dComIfG_resDelete(&i_this->mPhs, "M_DOOR"); + return TRUE; } /* 00000544-00000604 .text daKytag03_Create__FP10fopAc_ac_c */ -static s32 daKytag03_Create(fopAc_ac_c*) { - /* Nonmatching */ +static s32 daKytag03_Create(fopAc_ac_c* i_ac) { + kytag03_class* i_this = (kytag03_class*)i_ac; + fopAcM_SetupActor(i_this, kytag03_class); + s32 ret = dComIfG_resLoad(&i_this->mPhs, "M_DOOR"); + if (ret == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(i_this, useHeapInit, 0x4c30)) { + return cPhs_ERROR_e; + } + + i_this->field_0x2a0 = 0; + i_this->field_0x2a8 = 0.0f; + i_this->mSwitchID = fopAcM_GetParam(i_this); + i_this->mbRoomActive = false; + i_this->mbIsActive = false; + i_this->mbVisible = false; + } + return ret; } static actor_method_class l_daKytag03_Method = { diff --git a/src/d/actor/d_a_obj_gaship.cpp b/src/d/actor/d_a_obj_gaship.cpp index e1ffa6988..9fb326a47 100644 --- a/src/d/actor/d_a_obj_gaship.cpp +++ b/src/d/actor/d_a_obj_gaship.cpp @@ -16,8 +16,6 @@ static f32 dummy[19]; /* 000000EC-000002DC .text birth_flag__Q211daObjGaship5Act_cFv */ void daObjGaship::Act_c::birth_flag() { - /* Nonmatching */ - for (s32 i = 0; i < 2; i++) { if (!birthFlag[i]) { static cXyz flag_offset[2] = { @@ -47,7 +45,6 @@ BOOL daObjGaship::Act_c::solidHeapCB(fopAc_ac_c* i_ac) { /* 00000378-00000448 .text create_heap__Q211daObjGaship5Act_cFv */ bool daObjGaship::Act_c::create_heap() { - /* Nonmatching */ J3DModelData* mdl_data = static_cast(dComIfG_getObjectRes(M_arcname, GASHIP_BDL_GASHIP)); JUT_ASSERT(0x8c, mdl_data != NULL); if (mdl_data != NULL) @@ -60,7 +57,6 @@ bool daObjGaship::Act_c::create_heap() { /* 00000448-000004F8 .text _create__Q211daObjGaship5Act_cFv */ s32 daObjGaship::Act_c::_create() { - /* Nonmatching */ fopAcM_SetupActor(this, Act_c); s32 ret = dComIfG_resLoad(&mPhs, M_arcname);