summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_obj_gaship2.cpp
blob: 30b30ed798f0939ea1d7ad963bf7f9453d4b85cb (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
/**
 * d_a_obj_gaship2.cpp
 * Object - Ganon Room (destroyed) (Forsaken Fortress 3)
 */

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_obj_gaship2.h"
#include "res/Object/YakeRom.h"
#include "SSystem/SComponent/c_bg_w.h"
#include "d/d_com_inf_game.h"
#include "d/d_bg_s_movebg_actor.h"
#include "m_Do/m_Do_mtx.h"

const char daObjGaship2::Act_c::M_arcname[] = "YakeRom";

/* 00000078-0000009C       .text solidHeapCB__Q212daObjGaship25Act_cFP10fopAc_ac_c */
BOOL daObjGaship2::Act_c::solidHeapCB(fopAc_ac_c *i_this) {
    return ((Act_c *) i_this)->create_heap();
}

/* 0000009C-00000220       .text create_heap__Q212daObjGaship25Act_cFv */
bool daObjGaship2::Act_c::create_heap() {
    J3DModelData *mdl_data;
    cBgD_t *bgw_data;

    mdl_data = (J3DModelData *) (dComIfG_getObjectRes(M_arcname, dRes_INDEX_YAKEROM_BDL_YAKEROM_e));
    JUT_ASSERT(90, mdl_data != NULL);

    mpModel = mDoExt_J3DModel__create(mdl_data, 0, 0x11000002);
    set_mtx();
    bgw_data = (cBgD_t *) (dComIfG_getObjectRes(M_arcname, dRes_INDEX_YAKEROM_DZB_YAKEROM_e));
    JUT_ASSERT(103, bgw_data != NULL);
#if VERSION > VERSION_DEMO
    if (bgw_data != NULL)
#endif
    {
        mpBgW = new dBgW();
        if (mpBgW != NULL && (mpBgW->Set(bgw_data, cBgW::MOVE_BG_e, &mMtx) == true)) {
#if VERSION > VERSION_DEMO
            return false;
#endif
        }
    }

#if VERSION == VERSION_DEMO
    return mdl_data != NULL && bgw_data != NULL && mpBgW != NULL;
#else
    return mdl_data != NULL && mpModel != NULL && bgw_data != NULL && mpBgW != NULL;
#endif
}

/* 00000220-000002F8       .text _create__Q212daObjGaship25Act_cFv */
cPhs_State daObjGaship2::Act_c::_create() {
    fopAcM_ct(this, Act_c);
    cPhs_State phase_state = dComIfG_resLoad(&mphs, M_arcname);
    if (phase_state == cPhs_COMPLEATE_e) {
        if (fopAcM_entrySolidHeap(this, solidHeapCB, 0x0)) {
            fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
            dComIfG_Bgsp()->Regist(mpBgW, this);
            mpBgW->SetCrrFunc(dBgS_MoveBGProc_Typical);
        } else {
            phase_state = cPhs_ERROR_e;
        }
    }
    return phase_state;
}

/* 000002F8-00000384       .text _delete__Q212daObjGaship25Act_cFv */
bool daObjGaship2::Act_c::_delete() {
#if VERSION > VERSION_DEMO
    if (heap != NULL && mpBgW != NULL)
#endif
    {
        if (mpBgW->ChkUsed()) {
            dComIfG_Bgsp()->Release(mpBgW);
        }
    }

    dComIfG_resDelete(&mphs, M_arcname);
    return true;
}

/* 00000384-00000430       .text set_mtx__Q212daObjGaship25Act_cFv */
void daObjGaship2::Act_c::set_mtx() {
    mpModel->setBaseScale(scale);
    mDoMtx_stack_c::transS(current.pos);
    mDoMtx_stack_c::ZXYrotM(shape_angle);

    mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
    MTXCopy(mDoMtx_stack_c::get(), mMtx);
    mpModel->calc();
}

/* 00000430-00000468       .text _execute__Q212daObjGaship25Act_cFv */
bool daObjGaship2::Act_c::_execute() {
    set_mtx();
    mpBgW->Move();
    return TRUE;
}

/* 00000468-00000508       .text _draw__Q212daObjGaship25Act_cFv */
bool daObjGaship2::Act_c::_draw() {
    dKy_getEnvlight().settingTevStruct(TEV_TYPE_BG0, &current.pos, &tevStr);
    dComIfGd_setListBG();
    dKy_getEnvlight().setLightTevColorType(mpModel, &tevStr);
    mDoExt_modelUpdateDL(mpModel);
    dComIfGd_setList();
    return TRUE;
};

namespace daObjGaship2 {
    namespace {
        cPhs_State Mthd_Create(void *i_this) {
            return ((daObjGaship2::Act_c *) i_this)->_create();
        }

        BOOL Mthd_Delete(void *i_this) {
            return ((daObjGaship2::Act_c *) i_this)->_delete();
        }

        BOOL Mthd_Execute(void *i_this) {
            return ((daObjGaship2::Act_c *) i_this)->_execute();
        }

        BOOL Mthd_Draw(void *i_this) {
            return ((daObjGaship2::Act_c *) i_this)->_draw();
        }

        BOOL Mthd_IsDelete(void *i_this) {
            return TRUE;
        }

        static actor_method_class Mthd_Table = {
            (process_method_func) Mthd_Create,
            (process_method_func) Mthd_Delete,
            (process_method_func) Mthd_Execute,
            (process_method_func) Mthd_IsDelete,
            (process_method_func) Mthd_Draw,
        };
    }
}

actor_process_profile_definition g_profile_Obj_Gaship2 = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0003,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_Obj_Gaship2_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(daObjGaship2::Act_c),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_Obj_Gaship2_e,
    /* Actor SubMtd */ &daObjGaship2::Mthd_Table,
    /* Status       */ fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_0_e,
};