summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_obj_mirror_sand.cpp
blob: 964584cc357234d1c9ff0f48684d25a968ff274e (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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/**
 * d_a_obj_mirror_sand.cpp
 * Mirror Chamber Sand Floor
 */

#include "d/actor/d_a_obj_mirror_sand.h"
#include "d/d_procname.h"

/* 80C989F0-80C989F4 -00001 0004+00 3/3 0/0 0/0 .data            l_arcName */
static char* l_arcName = "MR-Sand";

int daObjMirrorSand_c::createHeap() {
    J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(l_arcName, 8);
    mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
    if (mpModel == NULL) {
        return 0;
    }

    J3DAnmTransform* bck = (J3DAnmTransform*)dComIfG_getObjectRes(l_arcName, 5);
    mpBck = new mDoExt_bckAnm();

    f32 speed;
    if (isSwitch()) {
        speed = 1.0f;
    } else {
        speed = 0.0f;
    }

    if (mpBck == NULL || !mpBck->init(bck, FALSE, J3DFrameCtrl::LOOP_ONCE_e, speed, 0, -1, false)) {
        return 0;
    }

    if (isSwitch()) {
        mpBck->setFrame(bck->getFrameMax());
    }

    int i = 0;  // probably fake match, needed to avoid saving mBgMtx to a register
    cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes(l_arcName, 11);
    if (mBgw[0].Set(dzb, dBgW::MOVE_BG_e, (Mtx*)&mBgMtx[i])) {
        return 0;
    }

    cBgD_t* dzb2 = (cBgD_t*)dComIfG_getObjectRes(l_arcName, 12);
    if (mBgw[1].Set(dzb2, dBgW::MOVE_BG_e, &mBgMtx)) {
        return 0;
    }

    return 1;
}

/* 80C981D8-80C984C0 000078 02E8+00 1/1 0/0 0/0 .text            createSolidHeap__FP10fopAc_ac_c */
static int createSolidHeap(fopAc_ac_c* i_this) {
    return static_cast<daObjMirrorSand_c*>(i_this)->createHeap();
}

/* 80C98508-80C98534 0003A8 002C+00 1/1 0/0 0/0 .text            initBaseMtx__17daObjMirrorSand_cFv
 */
void daObjMirrorSand_c::initBaseMtx() {
    fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
    setBaseMtx();
}

/* 80C98534-80C98598 0003D4 0064+00 1/1 0/0 0/0 .text            setBaseMtx__17daObjMirrorSand_cFv
 */
void daObjMirrorSand_c::setBaseMtx() {
    mDoMtx_stack_c::transS(current.pos);
    mDoMtx_stack_c::ZXYrotM(shape_angle);

    mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
    cMtx_copy(mDoMtx_stack_c::get(), mBgMtx);
    mpCurrentBgw->Move();
}

int daObjMirrorSand_c::draw() {
    g_env_light.settingTevStruct(0x10, &current.pos, &tevStr);
    g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr);

    mpBck->entry(mpModel->getModelData());

    dComIfGd_setListBG();
    mDoExt_modelUpdateDL(mpModel);
    dComIfGd_setList();

    mpBck->remove(mpModel->getModelData());
    return 1;
}

/* 80C98598-80C98668 000438 00D0+00 1/0 0/0 0/0 .text daObjMirrorSand_Draw__FP17daObjMirrorSand_c
 */
static int daObjMirrorSand_Draw(daObjMirrorSand_c* i_this) {
    return i_this->draw();
}

int daObjMirrorSand_c::execute() {
    mpBck->play();

    if (mpCurrentBgw == &mBgw[0] && mpBck->getPlaySpeed() > 0.0f) {
        dComIfG_Bgsp().Release(&mBgw[0]);
        dComIfG_Bgsp().Regist(&mBgw[1], this);
        mpCurrentBgw = &mBgw[1];
        mpCurrentBgw->Move();
    }

    return 1;
}

/* 80C98668-80C98700 000508 0098+00 1/0 0/0 0/0 .text
 * daObjMirrorSand_Execute__FP17daObjMirrorSand_c               */
static int daObjMirrorSand_Execute(daObjMirrorSand_c* i_this) {
    return i_this->execute();
}

/* 80C98700-80C98708 0005A0 0008+00 1/0 0/0 0/0 .text
 * daObjMirrorSand_IsDelete__FP17daObjMirrorSand_c              */
static int daObjMirrorSand_IsDelete(daObjMirrorSand_c* i_this) {
    return 1;
}

daObjMirrorSand_c::~daObjMirrorSand_c() {
    if (mBgw[0].ChkUsed()) {
        dComIfG_Bgsp().Release(&mBgw[0]);
    }

    if (mBgw[1].ChkUsed()) {
        dComIfG_Bgsp().Release(&mBgw[1]);
    }

    dComIfG_resDelete(&mPhase, l_arcName);
}

/* 80C98708-80C987B8 0005A8 00B0+00 1/0 0/0 0/0 .text
 * daObjMirrorSand_Delete__FP17daObjMirrorSand_c                */
static int daObjMirrorSand_Delete(daObjMirrorSand_c* i_this) {
    i_this->~daObjMirrorSand_c();
    return 1;
}

void daObjMirrorSand_c::create_init() {
    fopAcM_setCullSizeBox2(this, mpModel->getModelData());
    mpBck->setPlaySpeed(0.0f);

    mBgw[0].SetCrrFunc(NULL);
    mBgw[0].SetRoomId(fopAcM_GetRoomNo(this));
    mBgw[1].SetCrrFunc(NULL);
    mBgw[1].SetRoomId(fopAcM_GetRoomNo(this));

    dBgW* current_bgw;
    if (isSwitch()) {
        current_bgw = &mBgw[1];
    } else {
        current_bgw = &mBgw[0];
    }

    mpCurrentBgw = current_bgw;
    dComIfG_Bgsp().Regist(mpCurrentBgw, this);
    initBaseMtx();
}

int daObjMirrorSand_c::create() {
    fopAcM_SetupActor(this, daObjMirrorSand_c);

    int phase = dComIfG_resLoad(&mPhase, l_arcName);
    if (phase == cPhs_COMPLEATE_e) {
        if (!fopAcM_entrySolidHeap(this, createSolidHeap, 0x1AD0)) {
            return cPhs_ERROR_e;
        }

        create_init();
    }

    return phase;
}

/* 80C98818-80C989D0 0006B8 01B8+00 1/0 0/0 0/0 .text daObjMirrorSand_Create__FP10fopAc_ac_c */
static int daObjMirrorSand_Create(fopAc_ac_c* i_this) {
    return static_cast<daObjMirrorSand_c*>(i_this)->create();
}

/* 80C989F4-80C98A14 -00001 0020+00 1/0 0/0 0/0 .data            l_daObjMirrorSand_Method */
static actor_method_class l_daObjMirrorSand_Method = {
    (process_method_func)daObjMirrorSand_Create,  (process_method_func)daObjMirrorSand_Delete,
    (process_method_func)daObjMirrorSand_Execute, (process_method_func)daObjMirrorSand_IsDelete,
    (process_method_func)daObjMirrorSand_Draw,
};

/* 80C98A14-80C98A44 -00001 0030+00 0/0 0/0 1/0 .data            g_profile_Obj_MirrorSand */
extern actor_process_profile_definition g_profile_Obj_MirrorSand = {
    fpcLy_CURRENT_e,
    3,
    fpcPi_CURRENT_e,
    PROC_Obj_MirrorSand,
    &g_fpcLf_Method.base,
    sizeof(daObjMirrorSand_c),
    0,
    0,
    &g_fopAc_Method.base,
    679,
    &l_daObjMirrorSand_Method,
    0x40000,
    fopAc_ACTOR_e,
    fopAc_CULLBOX_CUSTOM_e,
};