From 623622b9b6aba64d43831ffa32291599b7dcf820 Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Wed, 2 Aug 2023 01:29:00 -0700 Subject: [PATCH] more kankyo work / d_a_kytag08 work --- include/JSystem/J3DGraphBase/J3DMatBlock.h | 6 +- include/d/a/d_a_player.h | 1 + include/d/d_stage.h | 5 +- include/d/kankyo/d_kankyo.h | 4 + include/d/kankyo/d_kankyo_wether.h | 1 + include/m_Do/m_Do_audio.h | 8 + .../rel/d/a/kytag/d_a_kytag08/d_a_kytag08.h | 8 +- .../tag/d_a_tag_lightball/d_a_tag_lightball.h | 6 +- rel/d/a/kytag/d_a_kytag08/d_a_kytag08.cpp | 281 +++++++++- .../d_a_tag_lightball/d_a_tag_lightball.cpp | 53 +- src/d/kankyo/d_kankyo.cpp | 522 ++++++++++++++---- 11 files changed, 735 insertions(+), 160 deletions(-) diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index 65c064050f3..d86ade35cc0 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -541,7 +541,7 @@ private: extern const u16 j3dDefaultZModeID; inline u16 calcZModeID(u8 param_0, u8 param_1, u8 param_2) { - return param_0 * 0x10 + param_2 + param_1 * 2; + return ((param_1 * 2) & 0x1FE) + (param_0 * 0x10) + param_2; } struct J3DZModeInfo { @@ -631,6 +631,10 @@ struct J3DAlphaComp { mRef1 = param_1.field_0x4; u32 p1_mref1 = param_1.mRef1; field_0x0 = calcAlphaCmpID(param_1.field_0x0, param_1.mRef0, p1_mref1); + + // this matches for `dKy_bg_MAxx_proc` but causes `addWarpMaterial` to fail, + // while the above matches for `addWarpMaterial` but causes `dKy_bg_MAxx_proc` to fail? + // field_0x0 = calcAlphaCmpID(param_1.field_0x0, param_1.mRef0, param_1.mRef1); } /* 0x00 */ u16 field_0x0; diff --git a/include/d/a/d_a_player.h b/include/d/a/d_a_player.h index 33d9d27b72a..b26f8172f63 100644 --- a/include/d/a/d_a_player.h +++ b/include/d/a/d_a_player.h @@ -712,6 +712,7 @@ public: void onForceAutoJump() { i_onEndResetFlg0(ERFLG0_FORCE_AUTO_JUMP); } void onNotAutoJump() { i_onEndResetFlg0(ERFLG0_NOT_AUTO_JUMP); } void onNotHang() { i_onEndResetFlg0(ERFLG0_NOT_HANG); } + void onFogFade() { i_onNoResetFlg2(FLG2_UNK_4000); } void offGoronSideMove() { if (i_checkGoronSideMove()) { diff --git a/include/d/d_stage.h b/include/d/d_stage.h index ecd86856dc0..849ba352bec 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -88,7 +88,10 @@ struct stage_scls_info_dummy_class { struct stage_pure_lightvec_info_class { // LGT -}; + /* 0x00 */ u8 field_0x0[0x1E - 0x0]; + /* 0x1E */ u8 field_0x1e; + /* 0x1F */ u8 field_0x1f; +}; // Size: 0x20 // Col struct stage_pselect_info_class { diff --git a/include/d/kankyo/d_kankyo.h b/include/d/kankyo/d_kankyo.h index ab6d295cd3d..b124930d04d 100644 --- a/include/d/kankyo/d_kankyo.h +++ b/include/d/kankyo/d_kankyo.h @@ -50,6 +50,9 @@ static void dKy_calc_color_set(_GXColorS10* param_0, color_RGB_class* param_1, color_RGB_class* param_4, f32 param_5, f32 param_6, _GXColorS10 param_7, f32 param_8); static void dKy_twilight_camelight_set(); +u8 dKy_shadow_mode_check(u8 mode); +void dKy_shadow_mode_set(u8 mode); +void dKy_shadow_mode_reset(u8 mode); struct LIGHT_INFLUENCE { /* 800CFC7C */ ~LIGHT_INFLUENCE() {} @@ -101,6 +104,7 @@ struct SND_INFLUENCE { struct DALKMIST_INFLUENCE { /* 0x00 */ cXyz mPos; /* 0x0C */ f32 field_0xc; + /* 0x10 */ s8 mIndex; }; struct DUNGEON_LIGHT { diff --git a/include/d/kankyo/d_kankyo_wether.h b/include/d/kankyo/d_kankyo_wether.h index 46cb651a503..901df927a73 100644 --- a/include/d/kankyo/d_kankyo_wether.h +++ b/include/d/kankyo/d_kankyo_wether.h @@ -27,6 +27,7 @@ cXyz dKyw_get_wind_vecpow(); void dKyw_evt_wind_set(s16 angleX, s16 angleY); void dKyw_custom_windpower(f32 pow); void dKyw_evt_wind_set_go(); +void dKyw_wether_proc(); class dKankyo_sun_Packet : public J3DPacket { public: diff --git a/include/m_Do/m_Do_audio.h b/include/m_Do/m_Do_audio.h index 2d05cdb5bef..60f0c30d524 100644 --- a/include/m_Do/m_Do_audio.h +++ b/include/m_Do/m_Do_audio.h @@ -115,6 +115,14 @@ inline void mDoAud_heartGaugeOn() { Z2AudioMgr::getInterface()->mStatusMgr.heartGaugeOn(); } +inline void mDoAud_setFogWipeWidth(f32 i_width) { + g_mEnvSeMgr.setFogWipeWidth(i_width); +} + +inline void mDoAud_startFogWipeTrigger(const Vec* param_0) { + g_mEnvSeMgr.startFogWipeTrigger((Vec*)param_0); +} + inline void mDoAud_mEnvse_framework() { g_mEnvSeMgr.framework(); } diff --git a/include/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.h b/include/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.h index 47195eacb66..3e2fd206e87 100644 --- a/include/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.h +++ b/include/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.h @@ -6,10 +6,10 @@ class kytag08_class : public fopAc_ac_c { public: /* 0x568 */ J3DModel* mpModel; - /* 0x56C */ mDoExt_btkAnm field_0x56c; - /* 0x584 */ mDoExt_brkAnm field_0x584; - /* 0x59C */ JPABaseEmitter* field_0x59c; - /* 0x5A0 */ JPABaseEmitter* field_0x5a0; + /* 0x56C */ mDoExt_btkAnm mBtk; + /* 0x584 */ mDoExt_brkAnm mBrk; + /* 0x59C */ JPABaseEmitter* mpEmitter1; + /* 0x5A0 */ JPABaseEmitter* mpEmitter2; /* 0x5A4 */ request_of_phase_process_class mPhase; /* 0x5AC */ cXyz field_0x5ac; /* 0x5B8 */ cXyz field_0x5b8; diff --git a/include/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.h b/include/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.h index dd13513ebaa..c98581d0dfc 100644 --- a/include/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.h +++ b/include/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.h @@ -2,7 +2,6 @@ #define D_A_TAG_LIGHTBALL_H #include "d/kankyo/d_kankyo.h" -#include "dolphin/types.h" #include "f_op/f_op_actor_mng.h" class daTagLightBall_c : public fopAc_ac_c { @@ -19,11 +18,8 @@ public: u32 getType() { return fopAcM_GetParamBit(this, 8, 4); } /* 0x568 */ DALKMIST_INFLUENCE mInfluence; - /* 0x578 */ int field_0x578; /* 0x57C */ u8 field_0x57c; - /* 0x57D */ u8 field_0x57d; - /* 0x57E */ u8 field_0x57e; - /* 0x57F */ u8 field_0x57f; + /* 0x57D */ u8 mInfSet; }; #endif /* D_A_TAG_LIGHTBALL_H */ diff --git a/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.cpp b/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.cpp index eb3763c543c..cc024d026b4 100644 --- a/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.cpp +++ b/rel/d/a/kytag/d_a_kytag08/d_a_kytag08.cpp @@ -4,10 +4,11 @@ // #include "rel/d/a/kytag/d_a_kytag08/d_a_kytag08.h" -#include "dol2asm.h" #include "JSystem/JKernel/JKRHeap.h" +#include "d/a/d_a_player.h" #include "d/com/d_com_inf_game.h" #include "d/d_procname.h" +#include "dol2asm.h" // // Types: @@ -59,8 +60,8 @@ extern "C" void _restgpr_28(); /* 8085A578-8085A580 000078 0008+00 1/0 0/0 0/0 .text daKytag08_Draw__FP13kytag08_class */ -static bool daKytag08_Draw(kytag08_class* param_0) { - return true; +static int daKytag08_Draw(kytag08_class* i_this) { + return 1; } /* ############################################################################################## */ @@ -283,47 +284,240 @@ COMPILER_STRIP_GATE(0x8085B30C, &lit_4041); #pragma pop /* 8085A580-8085AEA0 000080 0920+00 1/0 0/0 0/0 .text daKytag08_Execute__FP13kytag08_class */ +// matches with literals +#ifdef NONMATCHING +static int daKytag08_Execute(kytag08_class* i_this) { + dScnKy_env_light_c* env_light = i_dKy_getEnvlight(); + daPy_py_c* player_p = daPy_getPlayerActorClass(); + JGeometry::TVec3 particle_scale; + + i_this->field_0x5d8 = 1; + if (i_this->field_0x5d8 == 0) { + i_this->current.pos.x = player_p->current.pos.x; + i_this->current.pos.y = 100.0f; + i_this->current.pos.z = player_p->current.pos.z; + } else if (env_light->field_0x0c18[0].field_0x26 == 1) { + i_this->current.pos.x = env_light->field_0x0c18[0].mPos.x; + i_this->current.pos.y = 100.0f; + i_this->current.pos.z = env_light->field_0x0c18[0].mPos.z; + } + + if (i_this->field_0x5b8.abs(i_this->current.pos) < 2000.0f && !i_dComIfGp_event_runCheck()) { + if (i_this->field_0x5d4 > 100) { + f32 var_f30; + f32 var_f31; + if (i_this->field_0x5d8 != 0) { + var_f30 = 20.0f; + var_f31 = 0.1f; + } else { + var_f30 = 10.0f; + var_f31 = 0.2f; + } + + cLib_addCalc(&i_this->field_0x5b8.x, i_this->field_0x5c4.x, var_f31, var_f30, 1.0E-5f); + cLib_addCalc(&i_this->field_0x5b8.z, i_this->field_0x5c4.z, var_f31, var_f30, 1.0E-5f); + } else { + f32 var_f30; + f32 var_f31; + if (i_this->field_0x5d8 != 0) { + var_f30 = 20.0f; + var_f31 = 0.1f; + } else { + var_f30 = 10.0f; + var_f31 = 0.2f; + } + + cLib_addCalc(&i_this->field_0x5b8.x, i_this->field_0x5c4.x, var_f31, var_f30, 1.0E-5f); + cLib_addCalc(&i_this->field_0x5b8.z, i_this->field_0x5c4.z, var_f31, var_f30, 1.0E-5f); + } + } else { + i_this->field_0x5b8.x = i_this->current.pos.x; + i_this->field_0x5b8.z = i_this->current.pos.z; + } + + if (!dKy_shadow_mode_check(2)) { + if (!i_dComIfGp_event_runCheck()) { + cLib_addCalc(&i_this->field_0x5d0, 0.0f, 0.2f, 0.005f, 0.001f); + } + } else if (i_this->field_0x5d4 != 0) { + cLib_addCalc(&i_this->field_0x5d0, 1.0f, 0.5f, 0.01f, 0.001f); + } else if (!i_dComIfGp_event_runCheck()) { + cLib_addCalc(&i_this->field_0x5d0, 0.25f, 0.01f, 0.002f, 0.001f); + } + + mDoAud_setFogWipeWidth(i_this->field_0x5d0); + + if (i_this->field_0x5d8 != 0) { + f32 tmp2 = 37.5f; + if (i_this->field_0x5b8.abs(i_this->current.pos) > + i_this->field_0x5d0 * tmp2 * i_this->field_0x5ac.x) + { + dComIfGs_BossLife_public_Set(2); + } + } + + if ((daPy_getPlayerActorClass()->checkKandelaarSwing(1) && i_this->field_0x5d4 < 100) || + dComIfGs_BossLife_public_Get() == 1) + { + dComIfGs_BossLife_public_Set(0); + i_this->field_0x5c4 = i_this->current.pos; + i_this->field_0x5d4 = 180; + mDoAud_startFogWipeTrigger(&i_this->current.pos); + } else { + f32 var_f30_3; + f32 var_f31_3; + if (i_this->field_0x5d8 != 0) { + var_f30_3 = 4000.0f; + var_f31_3 = 0.5f; + } else { + var_f30_3 = 4.0f; + var_f31_3 = 0.025f; + } + + cLib_addCalc(&i_this->field_0x5c4.x, i_this->current.pos.x, var_f31_3, var_f30_3, 0.01f); + cLib_addCalc(&i_this->field_0x5c4.z, i_this->current.pos.z, var_f31_3, var_f30_3, 0.01f); + } + + if (i_this->field_0x5d4 != 0) { + i_this->field_0x5d4--; + } + + if (i_this->mpEmitter1 != NULL) { + i_this->mpEmitter1->setGlobalTranslation(i_this->field_0x5b8.x, i_this->field_0x5b8.y, + i_this->field_0x5b8.z); + i_this->mpEmitter1->setVolumeSize(i_this->field_0x5ac.x * 50.0f * i_this->field_0x5d0); + + f32 temp_f0_7 = 1.0f - i_this->field_0x5d0; + particle_scale.x = 1.0f - (temp_f0_7 * temp_f0_7); + particle_scale.y = 1.0f - (temp_f0_7 * temp_f0_7); + particle_scale.z = 1.0f - (temp_f0_7 * temp_f0_7); + i_this->mpEmitter1->setGlobalParticleScale(particle_scale); + } + + if (i_this->field_0x5d0 <= 0.001f) { + i_this->field_0x5b8.x = i_this->current.pos.x; + i_this->field_0x5b8.z = i_this->current.pos.z; + + i_this->field_0x5c4 = i_this->field_0x5b8; + } + + f32 var_f30_4 = 20.0f; + if (dKy_darkworld_check()) { + var_f30_4 = 56.0f; + } + + f32 var_f0; + if (player_p->getSpinnerActor()) { + var_f0 = player_p->getSpinnerActor()->current.pos.y; + } else { + var_f0 = player_p->current.pos.y; + } + + if (var_f0 < var_f30_4) { + cXyz sp24(player_p->current.pos); + sp24.y = 100.0f; + + if (i_this->field_0x5b8.abs(sp24) > i_this->field_0x5ac.x * 45.0f * i_this->field_0x5d0 || + i_this->field_0x5d0 <= 0.01f) + { + player_p->onFogFade(); + } + } + + if (player_p != NULL && i_this->mpEmitter2 != NULL) { + i_this->mpEmitter2->setGlobalTranslation(player_p->current.pos.x, 100.0f, + player_p->current.pos.z); + + particle_scale.z = 0.0f; + particle_scale.y = 0.0f; + particle_scale.x = 0.0f; + + if (player_p->current.pos.y < 100.0f) { + cXyz sp18(player_p->current.pos); + sp18.y = 100.0f; + + if (i_this->field_0x5b8.abs(sp18) > i_this->field_0x5ac.x * 45.0f * i_this->field_0x5d0) + { + f32 scale_factor = (100.0f - player_p->current.pos.y) / 30.0f; + + if (scale_factor > 1.0f) { + scale_factor = 1.0f; + } + + particle_scale.z = scale_factor; + particle_scale.y = scale_factor; + particle_scale.x = scale_factor; + } + } + + i_this->mpEmitter2->setGlobalParticleScale(particle_scale); + } + + return 1; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void daKytag08_Execute(kytag08_class* param_0) { +static asm int daKytag08_Execute(kytag08_class* param_0) { nofralloc #include "asm/rel/d/a/kytag/d_a_kytag08/d_a_kytag08/daKytag08_Execute__FP13kytag08_class.s" } #pragma pop +#endif /* 8085AEA0-8085AEA8 0009A0 0008+00 1/0 0/0 0/0 .text daKytag08_IsDelete__FP13kytag08_class */ -static bool daKytag08_IsDelete(kytag08_class* param_0) { - return true; +static int daKytag08_IsDelete(kytag08_class* i_this) { + return 1; } -/* ############################################################################################## */ -/* 8085B310-8085B310 000084 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8085B310 = "Kytag08"; -#pragma pop - /* 8085AEA8-8085AF74 0009A8 00CC+00 1/0 0/0 0/0 .text daKytag08_Delete__FP13kytag08_class */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daKytag08_Delete(kytag08_class* param_0) { - nofralloc -#include "asm/rel/d/a/kytag/d_a_kytag08/d_a_kytag08/daKytag08_Delete__FP13kytag08_class.s" +static int daKytag08_Delete(kytag08_class* i_this) { + if (i_this->mpEmitter1 != NULL) { + i_this->mpEmitter1->deleteAllParticle(); + i_this->mpEmitter1->becomeInvalidEmitter(); + i_this->mpEmitter1->quitImmortalEmitter(); + i_this->mpEmitter1->setEmitterCallBackPtr(NULL); + i_this->mpEmitter1 = NULL; + } + + if (i_this->mpEmitter2 != NULL) { + i_this->mpEmitter2->deleteAllParticle(); + i_this->mpEmitter2->becomeInvalidEmitter(); + i_this->mpEmitter2->quitImmortalEmitter(); + i_this->mpEmitter2->setEmitterCallBackPtr(NULL); + i_this->mpEmitter2 = NULL; + } + + dComIfG_resDelete(&i_this->mPhase, "Kytag08"); + return 1; } -#pragma pop /* 8085AF74-8085AFEC 000A74 0078+00 1/1 0/0 0/0 .text useHeapInit__FP10fopAc_ac_c */ +// getting optimized when it shouldnt be? +#ifdef NONMATCHING +static int useHeapInit(fopAc_ac_c* i_this) { + kytag08_class* this_ = (kytag08_class*)i_this; + + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Kytag08", 3); + this_->mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11020202); + if (this_->mpModel == NULL) { + return 0; + } + + return 1; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void useHeapInit(fopAc_ac_c* param_0) { +static asm int useHeapInit(fopAc_ac_c* param_0) { nofralloc #include "asm/rel/d/a/kytag/d_a_kytag08/d_a_kytag08/useHeapInit__FP10fopAc_ac_c.s" } #pragma pop +#endif /* ############################################################################################## */ /* 8085B318-8085B338 -00001 0020+00 1/0 0/0 0/0 .data l_daKytag08_Method */ @@ -356,14 +550,57 @@ SECTION_DATA extern void* __vt__12J3DFrameCtrl[3] = { }; /* 8085AFEC-8085B23C 000AEC 0250+00 1/0 0/0 0/0 .text daKytag08_Create__FP10fopAc_ac_c */ +// regswap +#ifdef NONMATCHING +static int daKytag08_Create(fopAc_ac_c* i_this) { + cXyz sp(1.0f, 1.0f, 1.0f); + dScnKy_env_light_c* env_light = i_dKy_getEnvlight(); + + if (!fopAcM_CheckCondition(i_this, 8)) { + new (i_this) kytag08_class(); + fopAcM_OnCondition(i_this, 8); + } + + kytag08_class* this_ = (kytag08_class*)i_this; + + int phase = dComIfG_resLoad(&this_->mPhase, "Kytag08"); + if (phase == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(this_, useHeapInit, 0x550)) { + return cPhs_ERROR_e; + } + + this_->field_0x5ac.x = 20.0f; + this_->field_0x5ac.y = 20.0f; + this_->field_0x5ac.z = 20.0f; + this_->field_0x5d0 = 0.0f; + + this_->mpEmitter1 = dComIfGp_particle_set(0x84A0, &this_->current.pos, NULL, &sp); + + if (!dKy_darkworld_check()) { + this_->mpEmitter2 = dComIfGp_particle_set(0x84A1, &this_->current.pos, NULL, &sp); + } else { + this_->mpEmitter2 = dComIfGp_particle_set(0x84A2, &this_->current.pos, NULL, &sp); + } + + this_->field_0x5b8 = this_->current.pos; + this_->field_0x5b8.y = 100.0f; + this_->field_0x5c4 = this_->field_0x5b8; + + env_light->field_0x1060 = this_; + } + + return phase; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void daKytag08_Create(fopAc_ac_c* param_0) { +static asm int daKytag08_Create(fopAc_ac_c* param_0) { nofralloc #include "asm/rel/d/a/kytag/d_a_kytag08/d_a_kytag08/daKytag08_Create__FP10fopAc_ac_c.s" } #pragma pop +#endif /* 8085B23C-8085B284 000D3C 0048+00 1/0 0/0 0/0 .text __dt__12J3DFrameCtrlFv */ #pragma push diff --git a/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.cpp b/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.cpp index 0bfe0948763..8d51eb932c0 100644 --- a/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.cpp +++ b/rel/d/a/tag/d_a_tag_lightball/d_a_tag_lightball.cpp @@ -12,8 +12,8 @@ void daTagLightBall_c::initBaseMtx() { /* 80D5A818-80D5A870 000098 0058+00 1/1 0/0 0/0 .text setBaseMtx__16daTagLightBall_cFv */ void daTagLightBall_c::setBaseMtx() { - PSMTXTrans(mDoMtx_stack_c::now, current.pos.x, current.pos.y, current.pos.z); - mDoMtx_ZXYrotM(mDoMtx_stack_c::now, shape_angle.x, shape_angle.y, shape_angle.z); + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::ZXYrotM(shape_angle.x, shape_angle.y, shape_angle.z); } /* 80D5A870-80D5A9B8 0000F0 0148+00 1/1 0/0 0/0 .text Create__16daTagLightBall_cFv */ @@ -25,21 +25,24 @@ int daTagLightBall_c::Create() { i_fopAcM_offSwitch(this, swbit); } } + mInfluence.mPos = current.pos; mInfluence.field_0xc = mScale.x * 100.0f; + if (swbit != 0xFF) { if (getType() == 15) { if (i_fopAcM_isSwitch(this, swbit)) { dKy_dalkmist_inf_set(&mInfluence); - field_0x57d = 1; + mInfSet = true; } } else { if (!i_fopAcM_isSwitch(this, swbit)) { dKy_dalkmist_inf_set(&mInfluence); - field_0x57d = 1; + mInfSet = true; } } } + field_0x57c = i_fopAcM_isSwitch(this, swbit); return 1; } @@ -50,9 +53,11 @@ int daTagLightBall_c::create() { new (this) daTagLightBall_c; fopAcM_OnCondition(this, 8); } - if (Create() == 0) { + + if (!Create()) { return cPhs_ERROR_e; } + return cPhs_COMPLEATE_e; } @@ -61,21 +66,22 @@ int daTagLightBall_c::execute() { u8 swbit = getSwBit(); if (swbit != 0xFF) { if (getType() == 15) { - if (field_0x57c != 0 && !i_fopAcM_isSwitch(this, swbit)) { + if (field_0x57c && !i_fopAcM_isSwitch(this, swbit)) { dKy_dalkmist_inf_cut(&mInfluence); - field_0x57d = 0; - } else if (field_0x57c == 0 && i_fopAcM_isSwitch(this, swbit)) { + mInfSet = false; + } else if (!field_0x57c && i_fopAcM_isSwitch(this, swbit)) { dKy_dalkmist_inf_set(&mInfluence); - field_0x57d = 1; + mInfSet = true; } - } else if (field_0x57c == 0 && i_fopAcM_isSwitch(this, swbit)) { + } else if (!field_0x57c && i_fopAcM_isSwitch(this, swbit)) { dKy_dalkmist_inf_cut(&mInfluence); - field_0x57d = 0; - } else if (field_0x57c != 0 && !i_fopAcM_isSwitch(this, swbit)) { + mInfSet = false; + } else if (field_0x57c && !i_fopAcM_isSwitch(this, swbit)) { dKy_dalkmist_inf_set(&mInfluence); - field_0x57d = 1; + mInfSet = true; } } + mInfluence.mPos = current.pos; field_0x57c = i_fopAcM_isSwitch(this, swbit); return 1; @@ -88,33 +94,34 @@ int daTagLightBall_c::draw() { /* 80D5ABA8-80D5ABF0 000428 0048+00 1/1 0/0 0/0 .text _delete__16daTagLightBall_cFv */ int daTagLightBall_c::_delete() { - if (field_0x57d) { + if (mInfSet) { dKy_dalkmist_inf_cut(&mInfluence); - field_0x57d = 0; + mInfSet = false; } + return 1; } /* 80D5ABF0-80D5AC10 000470 0020+00 1/0 0/0 0/0 .text daTagLightBall_Draw__FP16daTagLightBall_c */ -static void daTagLightBall_Draw(daTagLightBall_c* i_this) { - ((daTagLightBall_c*)i_this)->draw(); +static int daTagLightBall_Draw(daTagLightBall_c* i_this) { + return i_this->draw(); } /* 80D5AC10-80D5AC30 000490 0020+00 1/0 0/0 0/0 .text daTagLightBall_Execute__FP16daTagLightBall_c */ -static void daTagLightBall_Execute(daTagLightBall_c* i_this) { - ((daTagLightBall_c*)i_this)->execute(); +static int daTagLightBall_Execute(daTagLightBall_c* i_this) { + return i_this->execute(); } /* 80D5AC30-80D5AC50 0004B0 0020+00 1/0 0/0 0/0 .text daTagLightBall_Delete__FP16daTagLightBall_c */ -static void daTagLightBall_Delete(daTagLightBall_c* i_this) { - ((daTagLightBall_c*)i_this)->_delete(); +static int daTagLightBall_Delete(daTagLightBall_c* i_this) { + return i_this->_delete(); } /* 80D5AC50-80D5AC70 0004D0 0020+00 1/0 0/0 0/0 .text daTagLightBall_Create__FP10fopAc_ac_c */ -static void daTagLightBall_Create(fopAc_ac_c* i_this) { - ((daTagLightBall_c*)i_this)->create(); +static int daTagLightBall_Create(fopAc_ac_c* i_this) { + return static_cast(i_this)->create(); } /* ############################################################################################## */ diff --git a/src/d/kankyo/d_kankyo.cpp b/src/d/kankyo/d_kankyo.cpp index caf8334ad8a..eac47ead7ed 100644 --- a/src/d/kankyo/d_kankyo.cpp +++ b/src/d/kankyo/d_kankyo.cpp @@ -9,6 +9,7 @@ #include "MSL_C/string.h" #include "SSystem/SComponent/c_counter.h" #include "SSystem/SComponent/c_math.h" +#include "d/a/d_a_player.h" #include "d/com/d_com_inf_game.h" #include "d/kankyo/d_kankyo_data.h" #include "d/kankyo/d_kankyo_rain.h" @@ -3395,6 +3396,129 @@ asm void dScnKy_env_light_c::SetBaseLight() { /* 801A5288-801A56DC 19FBC8 0454+00 1/1 0/0 0/0 .text exeKankyo__18dScnKy_env_light_cFv */ +// regalloc +#ifdef NONMATCHING +void dScnKy_env_light_c::exeKankyo() { + for (int i = 0; i < 6; i++) { + field_0x0c18[i].field_0x26 = 0; + + if (field_0x0d58[i].field_0x26 != 0) { + field_0x0d58[i].field_0x26 = 0; + dKy_BossLight_set(&field_0x0d58[i].mPos, &field_0x0d58[i].mColor, + field_0x0d58[i].field_0x10, 0); + } + } + + g_env_light.mColPatMode = g_env_light.mColPatModeGather; + + if (!i_dComIfGp_event_runCheck() && g_env_light.mColPatModeGather != 0) { + if (g_env_light.mColPatModeGather >= 3) { + g_env_light.mColPatModeGather = 0; + } else { + g_env_light.mColPatModeGather++; + } + } + + if (g_env_light.mColPatMode != 0) { + if (g_env_light.mColpatPrevGather != 0xFF) { + g_env_light.mColPatPrev = g_env_light.mColpatPrevGather; + + if (g_env_light.mColPatModeGather == 0) { + g_env_light.mColpatPrevGather = 0xFF; + } + } + + if (g_env_light.mColpatCurrGather != 0xFF) { + g_env_light.mColPatCurr = g_env_light.mColpatCurrGather; + + if (g_env_light.mColPatModeGather == 0) { + g_env_light.mColpatCurrGather = 0xFF; + } + } + + if (g_env_light.mColPatBlendGather >= 0.0f) { + g_env_light.mColPatBlend = g_env_light.mColPatBlendGather; + + if (g_env_light.mColPatModeGather == 0) { + g_env_light.mColPatBlendGather = -1.0f; + } + } + } else if (g_env_light.mColPatPrev == g_env_light.mColPatCurr) { + if (g_env_light.mColpatPrevGather != 0xFF) { + g_env_light.mColPatPrev = g_env_light.mColpatPrevGather; + g_env_light.mColpatPrevGather = 0xFF; + } + + if (g_env_light.mColpatCurrGather != 0xFF) { + g_env_light.mColPatCurr = g_env_light.mColpatCurrGather; + g_env_light.mColpatCurrGather = 0xFF; + g_env_light.mColpatWeather = g_env_light.mColpatCurrGather; + } + + if (g_env_light.mColPatBlendGather >= 0.0f) { + g_env_light.mColPatBlend = g_env_light.mColPatBlendGather; + g_env_light.mColPatBlendGather = -1.0f; + } + } + + g_env_light.field_0x1210 = g_env_light.field_0x122c; + + cLib_addCalc(&g_env_light.mColAllcolRatio, g_env_light.mAllcolRatio, 0.5f, 0.25f, 0.01f); + cLib_addCalc(&g_env_light.mColActColRatio, g_env_light.mActcolRatio, 0.5f, 0.25f, 0.01f); + cLib_addCalc(&g_env_light.mColBgColRatio, g_env_light.mBgcolRatio * g_env_light.field_0x1210, + 0.5f, 0.25f, 0.01f); + cLib_addCalc(&g_env_light.mColFogColRatio, g_env_light.mFogcolRatio * g_env_light.field_0x1210, + 0.5f, 0.25f, 0.01f); + cLib_addCalc(&g_env_light.mColVrboxSoraColRatio, + g_env_light.mVrboxSoracolRatio * g_env_light.field_0x1210, 0.5f, 0.25f, 0.01f); + cLib_addCalc(&g_env_light.mColVrboxKumocolRatio, + g_env_light.mVrboxKumocolRatio * g_env_light.field_0x1210, 0.5f, 0.25f, 0.01f); + + g_env_light.mAllcolRatio = 1.0f; + g_env_light.mActcolRatio = 1.0f; + g_env_light.mBgcolRatio = 1.0f; + g_env_light.mFogcolRatio = 1.0f; + g_env_light.mVrboxSoracolRatio = 1.0f; + g_env_light.mVrboxKumocolRatio = 1.0f; + g_env_light.field_0x122c = 1.0f; + g_env_light.field_0x126c = g_env_light.field_0x1268; + g_env_light.field_0x1268 = 999999.9f; + + for (int i = 50; i < 100; i++) { + g_env_light.mPointLight[i] = NULL; + } + + g_env_light.field_0x130b = 0; + + setDaytime(); + dKyw_wether_proc(); + CalcTevColor(); + Sndpos(); + Eflight_flush_proc(); + + daPy_py_c* player_p = (daPy_py_c*)dComIfGp_getPlayer(0); + if (player_p != NULL) { + cXyz* flame_pos_p = player_p->getKandelaarFlamePos(); + + if (flame_pos_p != NULL) { + g_env_light.field_0x10a0 = *flame_pos_p; + dKy_shadow_mode_set(2); + } else if (dKy_shadow_mode_check(2)) { + dKy_shadow_mode_reset(2); + } + } + + if (strcmp(dComIfGp_getStartStageName(), "R_SP127") == 0) { + if ((dCam_getBody()->mCurMode == 4 || dCam_getBody()->mCurMode == 7) && + i_dComIfGp_event_runCheck()) + { + cLib_addCalc(&g_env_light.mDemoAttentionPoint, 0.0f, 0.5f, 0.1f, 1E-05f); + } else { + cLib_addCalc(&g_env_light.mDemoAttentionPoint, 0.11f, 0.5f, 0.1f, 1E-05f); + } + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3403,6 +3527,7 @@ asm void dScnKy_env_light_c::exeKankyo() { #include "asm/d/kankyo/d_kankyo/exeKankyo__18dScnKy_env_light_cFv.s" } #pragma pop +#endif /* 801A56DC-801A572C 1A001C 0050+00 1/1 0/0 0/0 .text drawKankyo__18dScnKy_env_light_cFv */ @@ -3621,16 +3746,26 @@ static asm void dKy_GlobalLight_set() { #pragma pop #endif +inline u8 dLVI_getSWLight(stage_pure_lightvec_info_class* i_info) { + return i_info->field_0x1e & 0x80; +} + /* 801A61F4-801A6278 1A0B34 0084+00 3/3 0/0 0/0 .text * dKy_lightswitch_check__FP30stage_pure_lightvec_info_classc */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void dKy_lightswitch_check(stage_pure_lightvec_info_class* param_0, char param_1) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_lightswitch_check__FP30stage_pure_lightvec_info_classc.s" +static bool dKy_lightswitch_check(stage_pure_lightvec_info_class* param_0, char i_roomNo) { + bool var_r31 = 1; + if (param_0->field_0x1f != 0xFF) { + if (!dLVI_getSWLight(param_0)) { + if (dComIfGs_isSwitch(param_0->field_0x1f, i_roomNo)) { + var_r31 = 0; + } + } else if (!dComIfGs_isSwitch(param_0->field_0x1f, i_roomNo)) { + var_r31 = 0; + } + } + + return var_r31; } -#pragma pop /* 801A6278-801A6C20 1A0BB8 09A8+00 2/2 0/0 0/0 .text dKy_setLight_nowroom_common__Fcf */ #pragma push @@ -3693,14 +3828,38 @@ void dKy_setLight_again() { } /* 801A75E0-801A76D8 1A1F20 00F8+00 0/0 3/3 5/5 .text dKy_Global_amb_set__FP12dKy_tevstr_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_Global_amb_set(dKy_tevstr_c* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_Global_amb_set__FP12dKy_tevstr_c.s" +void dKy_Global_amb_set(dKy_tevstr_c* i_tevstr) { + GXColor color; + color.r = i_tevstr->mColorC0.r; + color.g = i_tevstr->mColorC0.g; + color.b = i_tevstr->mColorC0.b; + color.a = i_tevstr->mColorC0.a; + + if (i_tevstr->field_0x37a == 2 || i_tevstr->field_0x37a == 3) { + if (dKy_darkworld_check()) { + if (i_tevstr->field_0x37a == 2) { + color.r = 18; + color.g = 18; + color.b = 18; + color.a = 0; + } else { + color.r = 12; + color.g = 12; + color.b = 12; + color.a = 0; + } + } + } else if ((i_tevstr->field_0x37a >= 1 && i_tevstr->field_0x37a <= 7) || + (i_tevstr->field_0x37a == 9 && dKy_darkworld_check())) + { + color.r = 0; + color.g = 0; + color.b = 0; + color.a = 0; + } + + GXSetChanAmbColor(GX_COLOR0A0, color); } -#pragma pop /* 801A76D8-801A7714 1A2018 003C+00 1/1 0/0 0/0 .text dKy_light_influence_pos__Fi */ static cXyz dKy_light_influence_pos(int param_0) { @@ -3719,117 +3878,141 @@ cXyz dKy_plight_near_pos() { /* 801A7738-801A7790 1A2078 0058+00 0/0 0/0 1/1 .text * dKy_mock_light_every_set__FP15LIGHT_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_mock_light_every_set(LIGHT_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_mock_light_every_set__FP15LIGHT_INFLUENCE.s" +void dKy_mock_light_every_set(LIGHT_INFLUENCE* param_0) { + for (int i = 50; i < 100; i++) { + if (g_env_light.mPointLight[i] == NULL) { + g_env_light.mPointLight[i] = param_0; + g_env_light.mPointLight[i]->mIndex = i + 1; + break; + } + } } -#pragma pop /* 801A7790-801A7814 1A20D0 0084+00 1/1 1/1 18/18 .text dKy_plight_set__FP15LIGHT_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_plight_set(LIGHT_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_plight_set__FP15LIGHT_INFLUENCE.s" +void dKy_plight_set(LIGHT_INFLUENCE* param_0) { + for (int i = 0; i < 100; i++) { + if (g_env_light.mPointLight[i] == param_0) { + return; + } + } + + for (int i = 0; i < 50; i++) { + if (g_env_light.mPointLight[i] == NULL) { + g_env_light.mPointLight[i] = param_0; + g_env_light.mPointLight[i]->mIndex = i + 1; + break; + } + } } -#pragma pop /* 801A7814-801A7868 1A2154 0054+00 0/0 0/0 4/4 .text dKy_dalkmist_inf_set__FP18DALKMIST_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_dalkmist_inf_set(DALKMIST_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_dalkmist_inf_set__FP18DALKMIST_INFLUENCE.s" +void dKy_dalkmist_inf_set(DALKMIST_INFLUENCE* param_0) { + for (int i = 0; i < 10; i++) { + if (g_env_light.mDalkmistInf[i] == NULL) { + g_env_light.mDalkmistInf[i] = param_0; + g_env_light.mDalkmistInf[i]->mIndex = i; + break; + } + } } -#pragma pop /* 801A7868-801A789C 1A21A8 0034+00 0/0 0/0 4/4 .text dKy_dalkmist_inf_cut__FP18DALKMIST_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_dalkmist_inf_cut(DALKMIST_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_dalkmist_inf_cut__FP18DALKMIST_INFLUENCE.s" +void dKy_dalkmist_inf_cut(DALKMIST_INFLUENCE* param_0) { + if (param_0 != NULL) { + if (param_0->mIndex < 10) { + g_env_light.mDalkmistInf[param_0->mIndex] = NULL; + } + } } -#pragma pop - -/* ############################################################################################## */ -/* 80394C6C-80394C6C 0212CC 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80394E75 = "\nPOINTLIGHT COUNT OVER!!!\n"; -#pragma pop /* 801A789C-801A792C 1A21DC 0090+00 0/0 0/0 1/1 .text dKy_plight_priority_set__FP15LIGHT_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_plight_priority_set(LIGHT_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_plight_priority_set__FP15LIGHT_INFLUENCE.s" +void dKy_plight_priority_set(LIGHT_INFLUENCE* param_0) { + int i = 0; + + for (; i < 50; i++) { + if (g_env_light.mPointLight[i] == NULL) { + g_env_light.mPointLight[i] = param_0; + g_env_light.mPointLight[i]->mIndex = -(i + 1); + break; + } + } + + if (i >= 50) { + OSReport_Warning("\nPOINTLIGHT COUNT OVER!!!\n"); + } } -#pragma pop /* 801A792C-801A797C 1A226C 0050+00 0/0 1/1 32/32 .text dKy_plight_cut__FP15LIGHT_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_plight_cut(LIGHT_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_plight_cut__FP15LIGHT_INFLUENCE.s" +void dKy_plight_cut(LIGHT_INFLUENCE* param_0) { + if (param_0 != NULL) { + if (param_0->mIndex != 0) { + if (param_0->mIndex < 0) { + param_0->mIndex *= -1; + } + + int idx = (param_0->mIndex & 0xFFF) - 1; + if (idx < 50) { + g_env_light.mPointLight[idx] = NULL; + } + } + } } -#pragma pop /* 801A797C-801A7A00 1A22BC 0084+00 1/1 1/1 3/3 .text dKy_efplight_set__FP15LIGHT_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_efplight_set(LIGHT_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_efplight_set__FP15LIGHT_INFLUENCE.s" +void dKy_efplight_set(LIGHT_INFLUENCE* param_0) { + for (int i = 0; i < 5; i++) { + if (g_env_light.mEfPLight[i] == param_0) { + return; + } + } + + for (int i = 0; i < 5; i++) { + if (g_env_light.mEfPLight[i] == NULL) { + g_env_light.mEfPLight[i] = param_0; + g_env_light.mEfPLight[i]->mIndex = i + 1; + break; + } + } } -#pragma pop /* 801A7A00-801A7A40 1A2340 0040+00 1/1 1/1 3/3 .text dKy_efplight_cut__FP15LIGHT_INFLUENCE */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_efplight_cut(LIGHT_INFLUENCE* param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_efplight_cut__FP15LIGHT_INFLUENCE.s" +void dKy_efplight_cut(LIGHT_INFLUENCE* param_0) { + if (param_0 != NULL) { + if (param_0->mIndex != 0) { + int idx = param_0->mIndex - 1; + if (idx >= 0 && idx < 5) { + g_env_light.mEfPLight[idx] = NULL; + } + } + } } -#pragma pop /* 801A7A40-801A7AAC 1A2380 006C+00 1/1 0/0 0/0 .text * dKy_bgparts_activelight_set__FP15LIGHT_INFLUENCEi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void dKy_bgparts_activelight_set(LIGHT_INFLUENCE* param_0, int param_1) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_bgparts_activelight_set__FP15LIGHT_INFLUENCEi.s" +static void dKy_bgparts_activelight_set(LIGHT_INFLUENCE* influence_p, int param_1) { + if (influence_p != NULL) { + memcpy(&g_env_light.mBGpartsActiveLight[param_1], influence_p, sizeof(LIGHT_INFLUENCE)); + g_env_light.mBGpartsActiveLight[param_1].mIndex = param_1 + 1; + } } -#pragma pop /* 801A7AAC-801A7AC8 1A23EC 001C+00 1/1 0/0 0/0 .text dKy_bgparts_activelight_cut__Fi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void dKy_bgparts_activelight_cut(int param_0) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_bgparts_activelight_cut__Fi.s" +static void dKy_bgparts_activelight_cut(int param_0) { + g_env_light.mBGpartsActiveLight[param_0].mIndex = 0; } -#pragma pop /* 801A7AC8-801A7B68 1A2408 00A0+00 1/1 1/1 1/1 .text dKy_actor_addcol_amb_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +void dKy_actor_addcol_amb_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mActorAddColAmb.r = r * factor; + g_env_light.mActorAddColAmb.g = g * factor; + g_env_light.mActorAddColAmb.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3838,8 +4021,17 @@ asm void dKy_actor_addcol_amb_set(s16 param_0, s16 param_1, s16 param_2, f32 par #include "asm/d/kankyo/d_kankyo/dKy_actor_addcol_amb_set__Fsssf.s" } #pragma pop +#endif /* 801A7B68-801A7C08 1A24A8 00A0+00 1/1 1/1 1/1 .text dKy_bg_addcol_amb_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +void dKy_bg_addcol_amb_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mBgAddColAmb.r = r * factor; + g_env_light.mBgAddColAmb.g = g * factor; + g_env_light.mBgAddColAmb.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3848,8 +4040,17 @@ asm void dKy_bg_addcol_amb_set(s16 param_0, s16 param_1, s16 param_2, f32 param_ #include "asm/d/kankyo/d_kankyo/dKy_bg_addcol_amb_set__Fsssf.s" } #pragma pop +#endif /* 801A7C08-801A7CA8 1A2548 00A0+00 1/1 1/1 0/0 .text dKy_bg1_addcol_amb_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +void dKy_bg1_addcol_amb_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mBg1AddColAmb.r = r * factor; + g_env_light.mBg1AddColAmb.g = g * factor; + g_env_light.mBg1AddColAmb.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3858,8 +4059,17 @@ asm void dKy_bg1_addcol_amb_set(s16 param_0, s16 param_1, s16 param_2, f32 param #include "asm/d/kankyo/d_kankyo/dKy_bg1_addcol_amb_set__Fsssf.s" } #pragma pop +#endif /* 801A7CA8-801A7D48 1A25E8 00A0+00 1/1 0/0 0/0 .text dKy_bg2_addcol_amb_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +static void dKy_bg2_addcol_amb_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mBg2AddColAmb.r = r * factor; + g_env_light.mBg2AddColAmb.g = g * factor; + g_env_light.mBg2AddColAmb.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3868,8 +4078,17 @@ static asm void dKy_bg2_addcol_amb_set(s16 param_0, s16 param_1, s16 param_2, f3 #include "asm/d/kankyo/d_kankyo/dKy_bg2_addcol_amb_set__Fsssf.s" } #pragma pop +#endif /* 801A7D48-801A7DE8 1A2688 00A0+00 1/1 0/0 0/0 .text dKy_bg3_addcol_amb_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +static void dKy_bg3_addcol_amb_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mBg3AddColAmb.r = r * factor; + g_env_light.mBg3AddColAmb.g = g * factor; + g_env_light.mBg3AddColAmb.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3878,8 +4097,17 @@ static asm void dKy_bg3_addcol_amb_set(s16 param_0, s16 param_1, s16 param_2, f3 #include "asm/d/kankyo/d_kankyo/dKy_bg3_addcol_amb_set__Fsssf.s" } #pragma pop +#endif /* 801A7DE8-801A7E88 1A2728 00A0+00 1/1 1/1 0/0 .text dKy_addcol_fog_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +void dKy_addcol_fog_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mFogAddCol.r = r * factor; + g_env_light.mFogAddCol.g = g * factor; + g_env_light.mFogAddCol.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3888,18 +4116,26 @@ asm void dKy_addcol_fog_set(s16 param_0, s16 param_1, s16 param_2, f32 param_3) #include "asm/d/kankyo/d_kankyo/dKy_addcol_fog_set__Fsssf.s" } #pragma pop +#endif /* 801A7E88-801A7F20 1A27C8 0098+00 2/2 0/0 2/2 .text dKy_actor_addcol_set__Fsssf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dKy_actor_addcol_set(s16 param_0, s16 param_1, s16 param_2, f32 param_3) { - nofralloc -#include "asm/d/kankyo/d_kankyo/dKy_actor_addcol_set__Fsssf.s" +void dKy_actor_addcol_set(s16 r, s16 g, s16 b, f32 factor) { + dKy_actor_addcol_amb_set(r, g, b, factor); + dKy_bg_addcol_amb_set(r, g, b, factor); + dKy_bg1_addcol_amb_set(r, g, b, factor); + dKy_bg2_addcol_amb_set(r, g, b, factor); + dKy_bg3_addcol_amb_set(r, g, b, factor); } -#pragma pop /* 801A7F20-801A7FC0 1A2860 00A0+00 1/1 1/1 0/0 .text dKy_vrbox_addcol_sky0_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +void dKy_vrbox_addcol_sky0_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mVrboxAddcolSky0.r = r * factor; + g_env_light.mVrboxAddcolSky0.g = g * factor; + g_env_light.mVrboxAddcolSky0.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3908,9 +4144,18 @@ asm void dKy_vrbox_addcol_sky0_set(s16 param_0, s16 param_1, s16 param_2, f32 pa #include "asm/d/kankyo/d_kankyo/dKy_vrbox_addcol_sky0_set__Fsssf.s" } #pragma pop +#endif /* 801A7FC0-801A8060 1A2900 00A0+00 1/1 1/1 0/0 .text dKy_vrbox_addcol_kasumi_set__Fsssf */ +// matches with literals +#ifdef NONMATCHING +void dKy_vrbox_addcol_kasumi_set(s16 r, s16 g, s16 b, f32 factor) { + g_env_light.mVrboxAddcolKasumi.r = r * factor; + g_env_light.mVrboxAddcolKasumi.g = g * factor; + g_env_light.mVrboxAddcolKasumi.b = b * factor; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -3919,6 +4164,7 @@ asm void dKy_vrbox_addcol_kasumi_set(s16 param_0, s16 param_1, s16 param_2, f32 #include "asm/d/kankyo/d_kankyo/dKy_vrbox_addcol_kasumi_set__Fsssf.s" } #pragma pop +#endif /* 801A8060-801A80D0 1A29A0 0070+00 1/1 0/0 0/0 .text dKy_vrbox_addcol_set__Fsssf */ static void dKy_vrbox_addcol_set(s16 param_0, s16 param_1, s16 param_2, f32 param_3) { @@ -4978,6 +5224,75 @@ SECTION_SDATA2 static f32 lit_10485 = 1550.0f; SECTION_SDATA2 static f32 lit_10486 = 140.0f; /* 801AC918-801ACCDC 1A7258 03C4+00 1/1 0/0 0/0 .text dKy_murky_set__FP11J3DMaterial */ +#ifdef NONMATCHING +static void dKy_murky_set(J3DMaterial* material_p) { + dKankyo_sunlenz_Packet* sunlenzPkt_p = g_env_light.mpSunLenzPacket; + dKankyo_sun_Packet* sunPkt_p = g_env_light.mpSunPacket; + + camera_class* camera_p = dComIfGp_getCamera(0); + J3DGXColorS10 sp54; + J3DGXColor sp58; + + sp54.r = g_env_light.mTerrainAmbienceBG1.r; + sp54.g = g_env_light.mTerrainAmbienceBG1.g; + sp54.b = g_env_light.mTerrainAmbienceBG1.b; + sp54.a = g_env_light.mTerrainAmbienceBG2.a; + + sp58.a = g_env_light.mTerrainAmbienceBG1.a; + + if (g_env_light.field_0x1300 != -1) { + sp58.a = g_env_light.field_0x1300 * 1.0f; + } + + if (g_env_light.field_0x1302 != -1) { + sp54.a = (u8)(g_env_light.field_0x1302 * 1.0f); + } + + if (sunlenzPkt_p != NULL && sunPkt_p->field_0x5c > 1E-06f) { + sp54.a *= 1.0f - sunPkt_p->field_0x5c * + (1.0f - sunlenzPkt_p->field_0x98 * sunlenzPkt_p->field_0x98 * + sunlenzPkt_p->field_0x98); + } + + // Diababa room handling + if (strcmp(dComIfGp_getStartStageName(), "D_MN05A") == 0) { + f32 var_f31; + if (g_env_light.mpMudPacket != NULL) { + var_f31 = 1.0f - g_env_light.mpMudPacket->field_0x1c3c; + } + + sp54.r = 20; + sp54.g = 6; + sp54.b = 15; + + sp54.r = (var_f31 * -0.0f) + 20; + sp54.g = (var_f31 * 36.0f) + 6; + sp54.b = (var_f31 * 29.0f) + 15; + + f32 var_f0; + if (camera_p != NULL && camera_p->mLookat.mEye.z < 1800.0f) { + if (camera_p->mLookat.mEye.z < 1550.0f) { + var_f0 = 1.0f; + } else { + var_f0 = 1.0f - ((camera_p->mLookat.mEye.z - 1550.0f) / 250.0f); + } + sp54.a = 255.0f * var_f0; + } else { + sp54.a = 0; + } + + sp54.a += -sp54.a * var_f31; + sp58.a = (var_f31 * 140.0f) + 255; + } + + sp58.r = 0; + sp58.g = 0; + sp58.b = 0; + + material_p->setTevColor(1, &sp54); + material_p->setTevKColor(3, &sp58); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -4986,6 +5301,7 @@ static asm void dKy_murky_set(J3DMaterial* param_0) { #include "asm/d/kankyo/d_kankyo/dKy_murky_set__FP11J3DMaterial.s" } #pragma pop +#endif /* 801ACCDC-801ACCF4 1A761C 0018+00 2/2 1/1 0/0 .text dKy_shadow_mode_set__FUc */ void dKy_shadow_mode_set(u8 mode) { @@ -5034,15 +5350,13 @@ SECTION_SDATA static J3DZModeInfo l_zmodeUpEnable = {1, 3, 1}; SECTION_SDATA static J3DZModeInfo l_zmodeUpDisable = {1, 3, 0}; /* 80450710-80450718 000190 0008+00 1/1 0/0 0/0 .sdata l_alphaCompInfoOPA */ -SECTION_SDATA static J3DAlphaCompInfo l_alphaCompInfoOPA[2] = { - {0x07, 0x00, 0x01, 0x07}, - {0x00, 0x00, 0x00, 0x00}, +SECTION_SDATA static J3DAlphaCompInfo l_alphaCompInfoOPA = { + 0x07, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, }; /* 80450718-80450720 000198 0008+00 1/1 0/0 0/0 .sdata l_alphaCompInfo */ -SECTION_SDATA static J3DAlphaCompInfo l_alphaCompInfo[2] = { - {0x04, 0x80, 0x00, 0x03}, - {0xFF, 0x00, 0x00, 0x00}, +SECTION_SDATA static J3DAlphaCompInfo l_alphaCompInfo = { + 0x04, 0x80, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00, }; /* 80453E10-80453E14 002410 0004+00 1/1 0/0 0/0 .sdata2 @10916 */