From 092ac00cc0db0d56e8d004bf4cc0938b232d6899 Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Mon, 11 Mar 2024 09:19:09 -0400 Subject: [PATCH] Implement & link ef_tent_lamp --- config/rel_slices.yml | 4 +++ src/ef_tent_lamp.c | 84 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 74 insertions(+), 14 deletions(-) diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 426dc846..d2e1e656 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -903,6 +903,10 @@ ef_make_hem.c: .text: [0x806162B0, 0x8061710C] .rodata: [0x8064C818, 0x8064C860] .data: [0x806D3160, 0x806D31B8] +ef_tent_lamp.c: + .text: [0x80622304, 0x8062260C] + .rodata: [0x8064CF10, 0x8064CF38] + .data: [0x806D3910, 0x806D3928] m_select.c: .text: [0x80627F88, 0x80629CA8] .rodata: [0x8064D1B0, 0x8064D1B8] diff --git a/src/ef_tent_lamp.c b/src/ef_tent_lamp.c index cf2ec3ed..f497a8a1 100644 --- a/src/ef_tent_lamp.c +++ b/src/ef_tent_lamp.c @@ -1,20 +1,13 @@ #include "ef_effect_control.h" -static void eTL_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { - // TODO -} +#include "m_common_data.h" +#include "sys_matrix.h" +#include "m_rcp.h" -static void eTL_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { - // TODO -} - -static void eTL_mv(eEC_Effect_c* effect, GAME* game) { - // TODO -} - -static void eTL_dw(eEC_Effect_c* effect, GAME* game) { - // TODO -} +static void eTL_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1); +static void eTL_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg); +static void eTL_mv(eEC_Effect_c* effect, GAME* game); +static void eTL_dw(eEC_Effect_c* effect, GAME* game); eEC_PROFILE_c iam_ef_tent_lamp = { // clang-format off @@ -27,3 +20,66 @@ eEC_PROFILE_c iam_ef_tent_lamp = { eEC_IGNORE_DEATH_DIST, // clang-format on }; + +static void eTL_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { + (*eEC_CLIP->make_effect_proc)(eEC_EFFECT_TENT_LAMP, pos, NULL, game, NULL, item_name, prio, arg0, arg1); +} + +static s16 eTL_GetNiceSwitchStat() { + if (Common_Get(time.now_sec) >= (5 * mTM_SECONDS_IN_HOUR) && + Common_Get(time.now_sec) < (18 * mTM_SECONDS_IN_HOUR)) { + return FALSE; + } + + return TRUE; +} + +static void eTL_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { + GAME_PLAY* play = (GAME_PLAY*)game; + + effect->timer = 100; + if (eTL_GetNiceSwitchStat() == TRUE) { + mEnv_RequestChangeLightON(play, mRmTp_LIGHT_SWITCH_HOUSE0_BASEMENT, FALSE); + effect->offset.x = 1.0f; + } else { + mEnv_RequestChangeLightOFF(play, mRmTp_LIGHT_SWITCH_HOUSE0_BASEMENT, 0.5f); + effect->offset.x = 0.0f; + } +} + +static void eTL_mv(eEC_Effect_c* effect, GAME* game) { + GAME_PLAY* play = (GAME_PLAY*)game; + f32 target; + int nice_switch_state = eTL_GetNiceSwitchStat(); + + (*eEC_CLIP->set_continious_env_proc)(effect, 100, 100); + + if (nice_switch_state == TRUE) { + mEnv_RequestChangeLightON(play, mRmTp_LIGHT_SWITCH_HOUSE0_BASEMENT, FALSE); + target = 1.0f; + } else { + mEnv_RequestChangeLightOFF(play, mRmTp_LIGHT_SWITCH_HOUSE0_BASEMENT, 0.01f); + target = 0.0f; + } + + add_calc(&effect->offset.x, target, 0.015f, 0.1f, 0.001f); +} + +extern Gfx obj_tent_lamp_model[]; + +static void eTL_dw(eEC_Effect_c* effect, GAME* game) { + int l = (int)(255.0f + effect->offset.x * -255.0f); + + _texture_z_light_fog_prim(game->graph); + + OPEN_DISP(game->graph); + + Matrix_translate(0.0f, 0.0f, 0.0f, 0); + Matrix_scale(0.05f, 0.05f, 0.05f, 1); + + gDPSetPrimColor(NEXT_POLY_OPA_DISP, 0, l, 255, 255, 255, 255); + gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(NEXT_POLY_OPA_DISP, obj_tent_lamp_model); + + CLOSE_DISP(game->graph); +}