summaryrefslogtreecommitdiff
path: root/src/d/d_kyeff.cpp
blob: 7b781b40d3e2a12c99ea73e59460b9a3c9906c02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//
// Generated by dtk
// Translation Unit: d_kyeff.cpp
//

#include "d/dolzel.h" // IWYU pragma: keep
#include "d/d_kyeff.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_stage.h"
#include "m_Do/m_Do_audio.h"
#include "dolphin/os/OS.h"

/* 80197FE4-80198008       .text dKyeff_Draw__FP8dKyeff_c */
static BOOL dKyeff_Draw(dKyeff_c* i_this) {
    dKyw_wether_draw();
    return TRUE;
}

/* 80198008-8019803C       .text get_parcent__Ffff */
static f32 get_parcent(f32 param_0, f32 param_1, f32 param_2) {
    f32 temp_f1;
    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 */
static 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() {
    f32 blendPalAB, curTime;
    stage_vrbox_info_class* vrbox;
    stage_vrbox_info_class* vrbox0;
    stage_vrbox_info_class* vrbox1;

    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;
    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;
    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);
        }
    }

    vrbox = dKyd_dmvrbox_getp();
    g_env_light.mpVrboxInfo = vrbox;

    vrbox0 = &vrbox[palIdx0];
    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 */
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 */
static BOOL dKyeff_Execute(dKyeff_c* i_this) {
    return i_this->execute();
}

/* 801984EC-801984F4       .text dKyeff_IsDelete__FP8dKyeff_c */
static BOOL dKyeff_IsDelete(dKyeff_c* i_this) {
    return TRUE;
}

/* 801984F4-80198518       .text dKyeff_Delete__FP8dKyeff_c */
static BOOL dKyeff_Delete(dKyeff_c* i_this) {
    dKyw_wether_delete();
    return TRUE;
}

/* 80198518-80198758       .text dKyeff_Create__FP12kankyo_class */
static cPhs_State 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 == dStageType_OUTDOORS_e || stType == dStageType_SEA_e) {
            dKyw_rain_set(250);
            g_env_light.mThunderEff.mMode = 1;
        } else if (stType == dStageType_MISC_e) {
            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;
}

static kankyo_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,
};

kankyo_process_profile_definition g_profile_KYEFF = {
    /* Layer ID      */ fpcLy_CURRENT_e,
    /* List ID       */ 0x000C,
    /* List Prio     */ fpcPi_CURRENT_e,
    /* Proc Name     */ fpcNm_KYEFF_e,
    /* Proc SubMtd   */ &g_fpcLf_Method.base,
    /* Size          */ sizeof(dKyeff_c),
    /* Size Other    */ 0,
    /* Parameters    */ 0,
    /* Leaf SubMtd   */ &g_fopKy_Method,
    /* Draw Prio     */ fpcDwPi_KYEFF_e,
    /* Kankyo SubMtd */ &l_dKyeff_Method,
};