diff --git a/include/d/d_kankyo.h b/include/d/d_kankyo.h index 7ac42f8d5..014583fec 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -382,8 +382,6 @@ enum dKy_dice_wether_state { /* 3 */ DICE_STATE_NEXT_e, }; -class sub_kankyo__class; - int dKy_getdaytime_hour(); int dKy_getdaytime_minute(); int dKy_get_dayofweek(); diff --git a/include/d/d_kankyo_wether.h b/include/d/d_kankyo_wether.h index 0f56f17a4..9d1a16328 100644 --- a/include/d/d_kankyo_wether.h +++ b/include/d/d_kankyo_wether.h @@ -331,7 +331,12 @@ struct WINDEFF_SET { /* 0x759 */ u8 field_0x759; }; +void dKyw_wether_init(); +void dKyw_wether_move(); +void dKyw_wether_move_draw(); +void dKyw_wether_draw(); void dKyw_wether_proc(); +void dKyw_wether_delete(); void dKyw_rain_set(int); void dKyw_wind_set(); void dKyw_wind_init(); @@ -346,4 +351,5 @@ void dKyw_pntwind_cut(WIND_INFLUENCE*); void dKyw_pwind_cylinder_set(WIND_INFLUENCE*); void dKyw_evt_wind_set(s16 i_windX, s16 i_windY); void dKyw_evt_wind_set_go(); -#endif /* D_KANKYO_WETHER_H */ \ No newline at end of file + +#endif /* D_KANKYO_WETHER_H */ diff --git a/include/f_op/f_op_kankyo.h b/include/f_op/f_op_kankyo.h index 776dc972b..232a83610 100644 --- a/include/f_op/f_op_kankyo.h +++ b/include/f_op/f_op_kankyo.h @@ -17,8 +17,7 @@ public: struct kankyo_process_profile_definition { /* 0x00 */ leaf_process_profile_definition base; /* 0x24 */ leafdraw_method_class* mSubMtd; - /* 0x28 */ u32 field_0x28[8]; -}; // Size: 0x48 +}; // Size: 0x28 extern leafdraw_method_class g_fopKy_Method; diff --git a/src/d/d_kyeff.cpp b/src/d/d_kyeff.cpp index 68b0d876a..41030616e 100644 --- a/src/d/d_kyeff.cpp +++ b/src/d/d_kyeff.cpp @@ -3,51 +3,185 @@ // Translation Unit: d_kyeff.cpp // -#include "d_kyeff.h" -#include "dolphin/types.h" +#include "f_op/f_op_kankyo.h" +#include "f_op/f_op_camera.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo.h" +#include "d/d_kankyo_data.h" +#include "d/d_kankyo_wether.h" +#include "d/d_procname.h" +#include "d/d_stage.h" +#include "m_Do/m_Do_audio.h" +#include "dolphin/os/OS.h" + +class dKyeff_c : public kankyo_class { +public: + BOOL execute(); +}; /* 80197FE4-80198008 .text dKyeff_Draw__FP8dKyeff_c */ -void dKyeff_Draw(dKyeff_c*) { - /* Nonmatching */ +BOOL dKyeff_Draw(dKyeff_c* i_this) { + dKyw_wether_draw(); + return TRUE; } /* 80198008-8019803C .text get_parcent__Ffff */ -void get_parcent(float, float, float) { - /* Nonmatching */ +f32 get_parcent(f32 param_0, f32 param_1, f32 param_2) { + f32 temp_f1; + f32 temp_f2; + f32 temp_f4 = param_0 - param_1; + + if (0.0f != temp_f4) { + temp_f1 = 1.0f - (param_0 - param_2) / temp_f4; + if (!(temp_f1 >= 1.0f)) { + return temp_f1; + } + } + return 1.0f; } /* 8019803C-8019808C .text s16_data_ratio_set__Fssf */ -void s16_data_ratio_set(short, short, float) { - /* Nonmatching */ +s16 s16_data_ratio_set(s16 param_0, s16 param_1, f32 param_2) { + return param_0 + (s16)(param_2 * (param_1 - param_0)); } + /* 8019808C-8019847C .text menu_vrbox_set__Fv */ void menu_vrbox_set() { - /* Nonmatching */ + /* Nonmatching - regalloc. */ + camera_class * pCamera = dComIfGp_getCamera(0); + + pCamera->mLookat.mEye.x = 9377.0f; + pCamera->mLookat.mEye.y = 0.0f; + pCamera->mLookat.mEye.z = 7644.0f; + pCamera->mLookat.mCenter.x = 4300.0f; + pCamera->mLookat.mCenter.y = 4200.0f; + pCamera->mLookat.mCenter.z = 1000.0f; + + g_env_light.mWind.mWindPower = 0.7f; + f32 curTime = g_env_light.mCurTime; + + g_env_light.mCurTime += 0.03f; + if ((u32)g_env_light.mCurTime >= 360.0f) + g_env_light.mCurTime = 0.0f; + + mDoAud_setHour(curTime / 15.0f); + mDoAud_setMinute(((s32)(curTime * 1000000.0f) % 15000000) / 1000000.0f); + + g_env_light.mpSchejule = dKyd_schejule_menu_getp(); + + u8 palIdx0, palIdx1; + f32 blendPalAB; + for (s32 i = 0; i < 11; i++) { + if (curTime >= g_env_light.mpSchejule[i].mTimeEnd && curTime <= g_env_light.mpSchejule[i].mTimeBegin) { + palIdx0 = g_env_light.mpSchejule[i].mPalIdx0; + palIdx1 = g_env_light.mpSchejule[i].mPalIdx1; + blendPalAB = get_parcent(g_env_light.mpSchejule[i].mTimeBegin, g_env_light.mpSchejule[i].mTimeEnd, curTime); + } + } + + stage_vrbox_info_class* vrbox = dKyd_dmvrbox_getp(); + g_env_light.mpVrboxInfo = vrbox; + + stage_vrbox_info_class* vrbox0 = &vrbox[palIdx0]; + stage_vrbox_info_class* vrbox1 = &vrbox[palIdx1]; + g_env_light.mVrSkyColor.r = s16_data_ratio_set(vrbox0->mSkyColor.r, vrbox1->mSkyColor.r, blendPalAB); + g_env_light.mVrSkyColor.g = s16_data_ratio_set(vrbox0->mSkyColor.g, vrbox1->mSkyColor.g, blendPalAB); + g_env_light.mVrSkyColor.b = s16_data_ratio_set(vrbox0->mSkyColor.b, vrbox1->mSkyColor.b, blendPalAB); + g_env_light.mVrkumoColor.r = s16_data_ratio_set(vrbox0->mKumoColor.r, vrbox1->mKumoColor.r, blendPalAB); + g_env_light.mVrkumoColor.g = s16_data_ratio_set(vrbox0->mKumoColor.g, vrbox1->mKumoColor.g, blendPalAB); + g_env_light.mVrkumoColor.b = s16_data_ratio_set(vrbox0->mKumoColor.b, vrbox1->mKumoColor.b, blendPalAB); + g_env_light.mVrkumoCenterColor.r = s16_data_ratio_set(vrbox0->mKumoCenterColor.r, vrbox1->mKumoCenterColor.r, blendPalAB); + g_env_light.mVrkumoCenterColor.g = s16_data_ratio_set(vrbox0->mKumoCenterColor.g, vrbox1->mKumoCenterColor.g, blendPalAB); + g_env_light.mVrkumoCenterColor.b = s16_data_ratio_set(vrbox0->mKumoCenterColor.b, vrbox1->mKumoCenterColor.b, blendPalAB); + g_env_light.mVrKasumiMaeColor.r = (u8)(g_env_light.mVrkumoColor.r * 0.9f); + g_env_light.mVrKasumiMaeColor.g = (u8)(g_env_light.mVrkumoColor.g * 0.9f); + g_env_light.mVrKasumiMaeColor.b = (u8)(g_env_light.mVrkumoColor.b * 0.9f); + g_env_light.mVrUsoUmiColor.r = (u8)(g_env_light.mVrkumoColor.r * 0.9f); + g_env_light.mVrUsoUmiColor.g = (u8)(g_env_light.mVrkumoColor.g * 0.9f); + g_env_light.mVrUsoUmiColor.b = (u8)(g_env_light.mVrkumoColor.b * 0.9f); + g_env_light.mVrkumoColor.a = 0xFF; } /* 8019847C-801984CC .text execute__8dKyeff_cFv */ -void dKyeff_c::execute() { - /* Nonmatching */ +BOOL dKyeff_c::execute() { + if (strcmp(dComIfGp_getStartStageName(), "Name") == 0) { + menu_vrbox_set(); + } else { + dKyw_wether_move(); + } + + dKyw_wether_move_draw(); + return TRUE; } /* 801984CC-801984EC .text dKyeff_Execute__FP8dKyeff_c */ -void dKyeff_Execute(dKyeff_c*) { - /* Nonmatching */ +BOOL dKyeff_Execute(dKyeff_c* i_this) { + return i_this->execute(); } /* 801984EC-801984F4 .text dKyeff_IsDelete__FP8dKyeff_c */ -void dKyeff_IsDelete(dKyeff_c*) { - /* Nonmatching */ +BOOL dKyeff_IsDelete(dKyeff_c* i_this) { + return TRUE; } /* 801984F4-80198518 .text dKyeff_Delete__FP8dKyeff_c */ -void dKyeff_Delete(dKyeff_c*) { - /* Nonmatching */ +BOOL dKyeff_Delete(dKyeff_c* i_this) { + dKyw_wether_delete(); + return TRUE; } /* 80198518-80198758 .text dKyeff_Create__FP12kankyo_class */ -void dKyeff_Create(kankyo_class*) { - /* Nonmatching */ +s32 dKyeff_Create(kankyo_class* i_ky) { + dKyw_wether_init(); + + if (strcmp(dComIfGp_getStartStageName(), "Name") == 0) { + OSCalendarTime cal; + OSTime curTime = OSGetTime(); + OSTicksToCalendarTime(curTime, &cal); + + g_env_light.mWind.mWindVec.set(1.0f, 0.0f, 0.0f); + g_env_light.mWind.mWindPower = 0.7f; + + g_env_light.mCurTime = 15.0f * cal.hours; + } else if (dKy_checkEventNightStop()) { + u32 stType = dStage_stagInfo_GetSTType(dComIfGp_getStage().getStagInfo()); + if (stType == 0 || stType == 7) { + dKyw_rain_set(250); + g_env_light.mThunderEff.mMode = 1; + } else if (stType == 2) { + if (strcmp(dComIfGp_getStartStageName(), "Ocrogh") == 0 || strcmp(dComIfGp_getStartStageName(), "Omori") == 0 || + strcmp(dComIfGp_getStartStageName(), "Orichh") == 0 || strcmp(dComIfGp_getStartStageName(), "Atorizk") == 0 || + strcmp(dComIfGp_getStartStageName(), "LinkRM") == 0 || strcmp(dComIfGp_getStartStageName(), "Ojhous2") == 0 || + strcmp(dComIfGp_getStartStageName(), "Onobuta") == 0 || strcmp(dComIfGp_getStartStageName(), "Omasao") == 0 || + strcmp(dComIfGp_getStartStageName(), "Obombh") == 0 || strcmp(dComIfGp_getStartStageName(), "Opub") == 0) { + dKyw_rain_set(250); + g_env_light.mThunderEff.mMode = 10; + } + } + } + + return cPhs_COMPLEATE_e; } +leafdraw_method_class l_dKyeff_Method = { + (process_method_func)dKyeff_Create, + (process_method_func)dKyeff_Delete, + (process_method_func)dKyeff_Execute, + (process_method_func)dKyeff_IsDelete, + (process_method_func)dKyeff_Draw, +}; + +extern kankyo_process_profile_definition g_profile_KYEFF = { + fpcLy_CURRENT_e, + 12, + fpcPi_CURRENT_e, + PROC_KYEFF, + &g_fpcLf_Method.mBase, + sizeof(dKyeff_c), + 0, + 0, + &g_fopKy_Method, + 0x005, + &l_dKyeff_Method, +};