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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
//
// Generated by dtk
// Translation Unit: d_a_bwdg.cpp
//
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_bwdg.h"
#include "res/Object/Bwdg.h"
#include "d/d_bg_w_hf.h"
#include "d/d_com_inf_game.h"
#include "d/actor/d_a_bwd.h"
#include "f_op/f_op_actor_mng.h"
#include "dolphin/gf/GF.h"
static bwd_class* boss;
#include "assets/l_B_sand2TEX.h"
const u16 l_B_sand2TEX__width = 512;
const u16 l_B_sand2TEX__height = 256;
#include "assets/l_texCoord.h"
#include "assets/l_Hsand1DL.h"
#include "assets/l_matDL__d_a_bwdg.h"
l_matDL__d_a_bwdg(l_B_sand2TEX);
// Fakematch: For some reason daBwdg_packet_c::draw needs to have .data pooling disabled, but the in-function statics cause .data pooling to be used.
// Disabling data pooling for the entire TU breaks wave_cont, which uses ...rodata pooling, so instead disable it for just this one function.
#pragma push
#pragma pool_data off
/* 00000078-000001C4 .text draw__15daBwdg_packet_cFv */
void daBwdg_packet_c::draw() {
static GXVtxDescList l_vtxDescList[] = {
{GX_VA_POS, GX_INDEX16},
{GX_VA_NRM, GX_INDEX16},
{GX_VA_TEX0, GX_INDEX16},
{GX_VA_NULL, GX_NONE},
};
static GXVtxAttrFmtList l_vtxAttrFmtList[] = {
{GX_VA_POS, GX_POS_XYZ, GX_F32, 0x00},
{GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0x00},
{GX_VA_TEX0, GX_TEX_ST, GX_F32, 0x00},
{GX_VA_NULL, GX_POS_XYZ, GX_F32, 0x00},
};
j3dSys.reinitGX();
dKy_GxFog_tevstr_set(mpTevStr);
dKy_setLight_mine(mpTevStr);
GFSetVtxDescv(l_vtxDescList);
GFSetVtxAttrFmtv(GX_VTXFMT0, l_vtxAttrFmtList);
GFSetArray(GX_VA_POS, &mPos[m00010 * 0x1081], sizeof(cXyz));
GFSetArray(GX_VA_NRM, &mNrm[m00010 * 0x1081], sizeof(cXyz));
GFSetArray(GX_VA_TEX0, l_texCoord, sizeof(cXy));
GFSetTevColorS10(GX_TEVREG0, mpTevStr->mColorC0);
GFSetTevColor(GX_TEVREG1, mpTevStr->mColorK0);
GXCallDisplayList(l_matDL, 0xA0);
GFLoadPosMtxImm(getMtx(), GX_PNMTX0);
Mtx sp14;
cMtx_inverseTranspose(mMtx, sp14);
GFLoadNrmMtxImm(sp14, 0);
GXCallDisplayList(l_Hsand1DL, sizeof(l_Hsand1DL));
m00010 ^= 0x01;
}
#pragma pop
/* 000001C4-00000260 .text daBwdg_Draw__FP10bwdg_class */
static BOOL daBwdg_Draw(bwdg_class* i_this) {
g_env_light.settingTevStruct(TEV_TYPE_BG0_FULL, &i_this->current.pos, &i_this->tevStr);
f32 f1 = 0.0f;
MtxTrans(0.0f, 10.0f + f1, 0.0f, 0);
cMtx_concat(j3dSys.getViewMtx(), *calc_mtx, i_this->mBwdgPacket.getMtx());
i_this->mBwdgPacket.setTevStr(&i_this->tevStr);
j3dSys.getDrawBuffer(0)->entryImm(&i_this->mBwdgPacket, 0);
return TRUE;
}
/* 00000260-00000308 .text base_xz_set__FP10bwdg_class */
static void base_xz_set(bwdg_class* i_this) {
cXyz* posVtx = i_this->mBwdgPacket.getPos();
for (int i = 0; i < 0x41; i++) {
for (int j = 0; j < 0x41; posVtx++, j++) {
posVtx->x = j * 130.0f - 4160.0f;
posVtx->z = i * 130.0f - 4160.0f;
}
}
}
/* 00000308-000006F8 .text wave_cont__FP10bwdg_classUc */
static void wave_cont(bwdg_class* i_this, u8 r4) {
cXyz* posVtx = i_this->mBwdgPacket.getPos();
cXyz sp30;
f32 f31, f30, f29, f28, f27;
if (r4 != 0) {
f30 = 1.0f;
f31 = 2000.0f;
sp30.setall(0.0f);
f28 = -0.75f;
f29 = 1.0f;
f27 = 600.0f;
} else {
f30 = 0.5f;
f31 = 0.0f;
i_this->m002B8 += boss->m17D8;
sp30 = boss->m17C8;
f28 = boss->m17D4;
f29 = boss->m17DC;
f27 = boss->m17E0;
}
for (int i = 0; i < 0x1081; posVtx++, i++) {
cXyz sp24;
sp24.x = posVtx->x - sp30.x;
sp24.z = posVtx->z - sp30.z;
f32 f0 = std::sqrtf(sp24.x*sp24.x + sp24.z*sp24.z);
f32 f1 = 3000.0f - f0;
f32 f3;
f32 f4 = f1;
if (f4 < 0.0f) {
f4 = 0.0f;
}
f4 *= 0.01f;
if (f1 < 0.0f) {
f1 = 0.0f;
}
f3 = 10.0f + f1 * 0.00667f;
if (f3 > 30.0f) {
f3 = 30.0f;
}
f32 f2 = cM_ssin(i_this->m002B8 + (s32)(f0*200.0f));
cLib_addCalc2(&i_this->m002C0[i], f28*(f4*f4) + f3*f2, f30, f29*((0.3f*f3)+f31));
posVtx->y = i_this->m002C0[i] + f27;
}
cXyz* nrmVtx = i_this->mBwdgPacket.getNrm();
posVtx = i_this->mBwdgPacket.getPos();
cXyz sp18(0.0f, 0.0f, 1.0f);
#if VERSION == VERSION_DEMO
cMtx_XrotM(*calc_mtx, -0x4A38);
#else
cMtx_XrotS(*calc_mtx, -0x4A38);
#endif
cXyz sp0C;
MtxPosition(&sp18, &sp0C);
for (int i = 0; i < 0x1081; i++, posVtx++, nrmVtx++) {
if (i >= 0x1040) {
continue;
}
cMtx_XrotS(*calc_mtx, cM_atan2s(posVtx->y - f27, 400.0f));
MtxPosition(&sp0C, nrmVtx);
}
}
/* 00000734-00000780 .text boss_a_d_sub__FPvPv */
static void* boss_a_d_sub(void* param_1, void* param_2) {
UNUSED(param_2);
if (fopAcM_IsActor(param_1) && fopAcM_GetName(param_1) == fpcNm_BWD_e) {
return param_1;
}
return NULL;
}
/* 00000780-0000084C .text daBwdg_Execute__FP10bwdg_class */
static BOOL daBwdg_Execute(bwdg_class* i_this) {
cXyz* posVtx = i_this->mBwdgPacket.getPos();
if (boss == NULL) {
boss = (bwd_class*)fpcM_Search(boss_a_d_sub, i_this);
if (boss == NULL) {
return TRUE;
}
}
i_this->m002B4++;
i_this->mpBgW->CopyBackVtx();
wave_cont(i_this, 0);
i_this->mpBgW->SetVtx(posVtx);
i_this->mpBgW->MoveHf();
return TRUE;
}
/* 0000084C-00000854 .text daBwdg_IsDelete__FP10bwdg_class */
static BOOL daBwdg_IsDelete(bwdg_class* i_this) {
return TRUE;
}
/* 00000854-000008B0 .text daBwdg_Delete__FP10bwdg_class */
static BOOL daBwdg_Delete(bwdg_class* i_this) {
dComIfG_resDeleteDemo(&i_this->mPhase, "Bwdg");
#if VERSION > VERSION_DEMO
if (i_this->heap)
#endif
{
dComIfG_Bgsp()->Release(i_this->mpBgW);
}
return TRUE;
}
/* 000008B0-000009A0 .text useHeapInit__FP10fopAc_ac_c */
static BOOL useHeapInit(fopAc_ac_c* i_actor) {
bwdg_class* i_this = (bwdg_class*)i_actor;
i_this->mpBgW = new dBgWHf();
if (i_this->mpBgW == NULL) {
return FALSE;
}
if (!i_this->mpBgW->Set(
(cBgD_t*)dComIfG_getObjectRes("Bwdg", dRes_INDEX_BWDG_DZB_HSAND1_e),
(u16*)dComIfG_getObjectRes("Bwdg", dRes_INDEX_BWDG_DAT_GRIDIDX_e),
130.0f, 0x40, 0x40, 0
)) {
return TRUE;
} else {
return FALSE;
}
}
/* 000009A0-00000B5C .text daBwdg_Create__FP10fopAc_ac_c */
static cPhs_State daBwdg_Create(fopAc_ac_c* i_actor) {
bwdg_class* i_this = (bwdg_class*)i_actor;
fopAcM_ct(i_this, bwdg_class);
cPhs_State phase_state = dComIfG_resLoad(&i_this->mPhase, "Bwdg");
if (phase_state == cPhs_COMPLEATE_e) {
boss = NULL;
i_this->current.pos.setall(0.0f);
if (!fopAcM_entrySolidHeap(i_this, useHeapInit, 0x96000)) {
return cPhs_ERROR_e;
}
dComIfG_Bgsp()->Regist(i_this->mpBgW, i_this);
base_xz_set(i_this);
i_this->mBwdgPacket.m00010 ^= 0x01;
base_xz_set(i_this);
wave_cont(i_this, 1);
cXyz* posVtx = i_this->mBwdgPacket.getPos();
i_this->mpBgW->SetVtx(posVtx);
i_this->mpBgW->CopyBackVtx();
i_this->mpBgW->Move();
}
return phase_state;
}
static actor_method_class l_daBwdg_Method = {
(process_method_func)daBwdg_Create,
(process_method_func)daBwdg_Delete,
(process_method_func)daBwdg_Execute,
(process_method_func)daBwdg_IsDelete,
(process_method_func)daBwdg_Draw,
};
actor_process_profile_definition g_profile_BWDG = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 0x0007,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_BWDG_e,
/* Proc SubMtd */ &g_fpcLf_Method.base,
/* Size */ sizeof(bwdg_class),
/* Size Other */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Draw Prio */ fpcDwPi_BWDG_e,
/* Actor SubMtd */ &l_daBwdg_Method,
/* Status */ fopAcStts_UNK40000_e,
/* Group */ fopAc_ENEMY_e,
/* Cull Type */ fopAc_CULLBOX_0_e,
};
|