diff options
| author | Prakxo <87568477+Prakxo@users.noreply.github.com> | 2024-09-24 21:05:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-24 12:05:32 -0700 |
| commit | 35eba20abdd3f810a2f878edea37890858ffccc2 (patch) | |
| tree | 5a1706325f2724bff070661aceec9c169af7ce68 /src | |
| parent | 946ee8e9c28a04c7b0a485c9b49543677112d5ec (diff) | |
ef_room_sunshine OK (#214)
* ef_room_sunshine OK
* format
* jenkins
* fourth time's the charm
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.c | 175 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.h | 2 |
2 files changed, 159 insertions, 18 deletions
diff --git a/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.c b/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.c index 9087a57..4b69eb3 100644 --- a/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.c +++ b/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.c @@ -3,12 +3,21 @@ #include "m_actor_dlftbls.h" #include "m_object.h" #include "overlays/gamestates/ovl_play/m_play.h" +#include "m_time.h" -void Ef_Room_Sunshine_actor_ct(Actor* thisx, Game_Play* game_play); -void Ef_Room_SunshineR_actor_move(Actor* thisx, Game_Play* game_play); -void Ef_Room_SunshineR_actor_draw(Actor* thisx, Game_Play* game_play); +void Ef_Room_Sunshine_actor_ct(Actor* actor, Game_Play* game_play); +void Ef_Room_SunshineR_actor_move(Actor* actor, Game_Play* game_play); +void Ef_Room_SunshineR_actor_draw(Actor* actor, Game_Play* play); +void Ef_Room_SunshineL_actor_move(Actor* actor, Game_Play* game_play); +void Ef_Room_SunshineL_actor_draw(Actor* actor, Game_Play* play); + +extern Gfx light_floor01_mode[]; +extern Vtx light_floorL01_vtx[]; +extern Vtx light_floorR01_vtx[]; +extern Gfx light_shine01_mode[]; +extern Vtx light_shineL01_vtx[]; +extern Vtx light_shineR01_vtx[]; -#if 0 ActorProfile Room_Sunshine_Profile = { /* */ ACTOR_ROOM_SUNSHINE, /* */ ACTOR_PART_6, @@ -22,24 +31,156 @@ ActorProfile Room_Sunshine_Profile = { /* */ Ef_Room_SunshineR_actor_draw, /* */ NULL, }; -#endif -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/Ef_Room_Sunshine_actor_ct.s") +void Ef_Room_Sunshine_actor_ct(Actor* actor, UNUSED Game_Play* play) { + Room_Sunshine* sunshine = (Room_Sunshine*)actor; + + sunshine->unk_174 = 0; + + if (actor->params == 0) { + actor->update = Ef_Room_SunshineL_actor_move; + actor->draw = Ef_Room_SunshineL_actor_draw; + } else { + actor->world.pos.x -= 1.0f; + } + + actor->world.pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos(actor->world.pos, 0.0f); + + actor->scale.x = 1.0f; + actor->scale.y = 1.0f; + actor->scale.z = 1.0f; + + switch (actor->params) { + case 2: + actor->update = Ef_Room_SunshineL_actor_move; + actor->draw = Ef_Room_SunshineL_actor_draw; + actor->world.pos.x += 5.0f; + actor->world.pos.y = 1.0f + mCoBG_GetBgY_OnlyCenter_FromWpos(actor->world.pos, 0.0f); + actor->world.pos.x -= 6.0f; + break; + case 3: + actor->world.pos.x -= 5.0f; + actor->world.pos.y = 1.0f + mCoBG_GetBgY_OnlyCenter_FromWpos(actor->world.pos, 0.0f); + actor->world.pos.x += 6.0f; + break; + } +} + +f32 calc_scale_Ef_Room_Sunshine(s32 flag, s32 sec) { + + if (flag == 0) { + return 1.5f * sin_s((sec << 14) / (f32)mTM_TIME_TO_SEC(8, 0, 0)); + } else { + return 1.5f * sin_s((sec << 14) / (f32)mTM_TIME_TO_SEC(4, 0, 0)); + } +} + +u8 calc_alpha_Ef_Room_Sunshine(void) { + f32 ret; + s32 sec; + + if (common_data.time.nowSec < mTM_TIME_TO_SEC(4, 0, 0)) { + ret = 120.0f * ((mTM_TIME_TO_SEC(4, 0, 0) - common_data.time.nowSec) / (f32)mTM_TIME_TO_SEC(4, 0, 0)); + + } else if (common_data.time.nowSec < mTM_TIME_TO_SEC(20, 0, 0)) { + sec = (common_data.time.nowSec - mTM_TIME_TO_SEC(12, 0, 0)) >= 0 + ? (common_data.time.nowSec - mTM_TIME_TO_SEC(12, 0, 0)) + : -(common_data.time.nowSec - mTM_TIME_TO_SEC(12, 0, 0)); + + ret = 255.0f * ((mTM_TIME_TO_SEC(8, 0, 0) - sec) / (f32)mTM_TIME_TO_SEC(8, 0, 0)); + } else { + ret = 120.0f * ((mTM_TIME_TO_SEC(4, 0, 0) - (mTM_TIME_TO_SEC(24, 0, 0) - common_data.time.nowSec)) / + (f32)mTM_TIME_TO_SEC(4, 0, 0)); + } + + if ((common_data.weather == SUMMER) || (common_data.weather == FALL)) { + ret *= 0.6f; + } + + return (s32)ret; +} + +void Ef_Room_SunshineL_actor_move(Actor* actor, UNUSED Game_Play* play) { + if (common_data.time.nowSec < mTM_TIME_TO_SEC(4, 0, 0)) { + actor->scale.x = calc_scale_Ef_Room_Sunshine(1, common_data.time.nowSec); + } else if (common_data.time.nowSec >= mTM_TIME_TO_SEC(12, 0, 0) && + common_data.time.nowSec < mTM_TIME_TO_SEC(20, 0, 0)) { + actor->scale.x = calc_scale_Ef_Room_Sunshine(0, common_data.time.nowSec - mTM_TIME_TO_SEC(12, 0, 0)); + } else { + actor->scale.x = 0.0f; + } +} + +void Ef_Room_SunshineR_actor_move(Actor* actor, UNUSED Game_Play* play) { + if (common_data.time.nowSec >= mTM_TIME_TO_SEC(4, 0, 0) && common_data.time.nowSec < mTM_TIME_TO_SEC(12, 0, 0)) { + actor->scale.x = calc_scale_Ef_Room_Sunshine(0, mTM_TIME_TO_SEC(12, 0, 0) - common_data.time.nowSec); + } else if (common_data.time.nowSec >= mTM_TIME_TO_SEC(20, 0, 0)) { + actor->scale.x = calc_scale_Ef_Room_Sunshine(1, mTM_TIME_TO_SEC(24, 0, 0) - common_data.time.nowSec); + } else { + actor->scale.x = 0.0f; + } +} + +void setup_mode_Ef_Room_Sunshine(Actor* actor, Game_Play* play) { + OPEN_DISPS(play->state.gfxCtx); + Matrix_translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, 0); + Matrix_scale(actor->scale.x, actor->scale.y, actor->scale.z, 1); + + gDPPipeSync(POLY_XLU_DISP++); + + gSPMatrix(POLY_XLU_DISP++, _Matrix_to_Mtx_new(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + { + u8* color; + s32 alpha; + + if (common_data.time.nowSec >= mTM_TIME_TO_SEC(4, 0, 0) && + common_data.time.nowSec < mTM_TIME_TO_SEC(20, 0, 0)) { + color = play->kankyo.baseLight.sunColorWindow; + } else { + color = play->kankyo.baseLight.moonColorWindow; + } + + alpha = calc_alpha_Ef_Room_Sunshine() * mKK_windowlight_alpha_get(); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color[0], color[1], color[2], (u8)alpha); + } + CLOSE_DISPS(play->state.gfxCtx); +} + +void Ef_Room_SunshineL_actor_draw(Actor* actor, Game_Play* play) { + GraphicsContext* graph; + + if ((mKK_windowlight_alpha_get() < 0.0001f) || (actor->scale.x == 0.0f)) { + return; + } + graph = play->state.gfxCtx; + setup_mode_Ef_Room_Sunshine(actor, play); + + OPEN_DISPS(graph); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/func_80965E38_jp.s") + gSPDisplayList(POLY_XLU_DISP++, light_floor01_mode); + gSPDisplayList(POLY_XLU_DISP++, light_floorL01_vtx); + gSPDisplayList(POLY_XLU_DISP++, light_shine01_mode); + gSPDisplayList(POLY_XLU_DISP++, light_shineL01_vtx); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/func_80965EE0_jp.s") + CLOSE_DISPS(graph); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/func_80965FF0_jp.s") +void Ef_Room_SunshineR_actor_draw(Actor* actor, Game_Play* play) { + GraphicsContext* graph; -// clang-format off -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/Ef_Room_SunshineR_actor_move.s") -// clang-format on + if ((mKK_windowlight_alpha_get() < 0.0001f) || (actor->scale.x == 0.0f)) { + return; + } + graph = play->state.gfxCtx; + setup_mode_Ef_Room_Sunshine(actor, play); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/func_80966120_jp.s") + OPEN_DISPS(graph); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/func_8096628C_jp.s") + gSPDisplayList(POLY_XLU_DISP++, light_floor01_mode); + gSPDisplayList(POLY_XLU_DISP++, light_floorR01_vtx); + gSPDisplayList(POLY_XLU_DISP++, light_shine01_mode); + gSPDisplayList(POLY_XLU_DISP++, light_shineR01_vtx); -// clang-format off -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine/Ef_Room_SunshineR_actor_draw.s") -// clang-format on + CLOSE_DISPS(graph); +} diff --git a/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.h b/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.h index d6c21b0..79b3074 100644 --- a/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.h +++ b/src/overlays/actors/ovl_Room_Sunshine/ef_room_sunshine.h @@ -12,7 +12,7 @@ typedef void (*Room_SunshineActionFunc)(struct Room_Sunshine*, struct Game_Play* typedef struct Room_Sunshine { /* 0x000 */ Actor actor; - /* 0x174 */ UNK_TYPE1 unk_174[0x4]; + /* 0x174 */ u8 unk_174; } Room_Sunshine; // size = 0x178 #endif |
