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
270
271
272
273
|
//
// Generated by dtk
// Translation Unit: c_bg_s.cpp
//
#include "SSystem/SComponent/c_bg_s.h"
#include "SSystem/SComponent/c_bg_s_gnd_chk.h"
#include "SSystem/SComponent/c_bg_s_lin_chk.h"
#include "SSystem/SComponent/c_bg_w.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "dolphin/types.h"
static s32 l_SetCounter = 0;
/* 80246440-8024645C .text Init__11cBgS_ChkElmFv */
void cBgS_ChkElm::Init() {
m_bgw_base_ptr = NULL;
m_flags = 0;
m_actor_ptr = NULL;
m_actor_id = fpcM_ERROR_PROCESS_ID_e;
}
/* 8024645C-80246478 .text Regist2__11cBgS_ChkElmFP4cBgWUiPv */
void cBgS_ChkElm::Regist2(cBgW* bgw, fpc_ProcID pid, void* actor) {
m_flags |= 1;
m_bgw_base_ptr = bgw;
m_actor_id = pid;
m_actor_ptr = (fopAc_ac_c*)actor;
}
/* 80246478-8024649C .text Release__11cBgS_ChkElmFv */
void cBgS_ChkElm::Release() {
m_flags &= ~1;
m_bgw_base_ptr = NULL;
m_actor_id = fpcM_ERROR_PROCESS_ID_e;
m_actor_ptr = NULL;
}
/* 8024649C-80246600 .text Regist__4cBgSFP4cBgWUiPv */
bool cBgS::Regist(cBgW* bgw, fpc_ProcID pid, void* actor) {
if (bgw == NULL)
return true;
if (bgw->ChkUsed())
return true;
if (bgw->ChkMemoryError())
return true;
s32 i = l_SetCounter;
JUT_ASSERT(0x97, 0 <= i && i < 256);
while (true) {
if (!m_chk_element[i].ChkUsed()) {
m_chk_element[i].Regist2(bgw, pid, actor);
bgw->SetId(i);
l_SetCounter = i + 1;
if (l_SetCounter >= 256)
l_SetCounter = 0;
return false;
}
i++;
if (i >= 256)
i = 0;
if (l_SetCounter == i)
break;
}
bgw->SetId(256);
return true;
}
static void dummy() {
OSReport("c_bg_s_poly_info.h");
}
/* 80246600-8024669C .text Release__4cBgSFP4cBgW */
bool cBgS::Release(cBgW* bgw) {
if (bgw == NULL)
return true;
if (bgw->ChkUsed() && bgw->GetId() >= 0 && bgw->GetId() < 0x100 && m_chk_element[bgw->GetId()].ChkUsed()) {
m_chk_element[bgw->GetId()].Release();
bgw->SetId(256);
} else {
return true;
}
return false;
}
/* 8024669C-802466F0 .text Ct__4cBgSFv */
void cBgS::Ct() {
l_SetCounter = 0;
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
m_chk_element[i].Init();
}
/* 802466F0-8024676C .text Dt__4cBgSFv */
void cBgS::Dt() {
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
if (m_chk_element[i].ChkUsed())
m_chk_element[i].Release();
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
m_chk_element[i].Init();
}
/* 8024676C-802468E4 .text LineCross__4cBgSFP11cBgS_LinChk */
bool cBgS::LineCross(cBgS_LinChk* chk) {
bool ret = false;
chk->ClearPi();
chk->ClrHit();
for (s32 bg_index = 0; bg_index < (s32)ARRAY_SIZE(m_chk_element); bg_index++) {
cBgS_ChkElm* elm = &m_chk_element[bg_index];
if (elm->ChkUsed() && elm->m_bgw_base_ptr->GetVtxTbl() != NULL && !chk->ChkSameActorPid(elm->m_actor_id)) {
chk->PreCalc();
if (elm->m_bgw_base_ptr->LineCheck(chk)) {
chk->SetActorInfo(bg_index, elm->m_bgw_base_ptr, elm->m_actor_id);
ret = true;
}
}
}
if (ret)
chk->SetHit();
return ret;
}
/* 802468E4-80246A14 .text GroundCross__4cBgSFP11cBgS_GndChk */
f32 cBgS::GroundCross(cBgS_GndChk* chk) {
chk->SetNowY(-G_CM3D_F_INF);
chk->ClearPi();
chk->mWallPrecheck = (chk->mFlag & 0x02);
chk->mGndPrecheck = (chk->mFlag & 0x01);
cBgS_ChkElm* elm = m_chk_element;
for (s32 bg_index = 0; bg_index < (s32)ARRAY_SIZE(m_chk_element); bg_index++, elm++) {
if (elm->ChkUsed() && elm->m_bgw_base_ptr->GetVtxTbl() != NULL && !chk->ChkSameActorPid(elm->m_actor_id)) {
if (elm->m_bgw_base_ptr->GroundCross(chk)) {
chk->SetActorInfo(bg_index, elm->m_bgw_base_ptr, elm->m_actor_id);
}
}
}
return chk->GetNowY();
}
/* 80246A14-80246C98 .text ConvDzb__4cBgSFPv */
void* cBgS::ConvDzb(void* work) {
cBgD_t * pbgd = (cBgD_t *)work;
if (((pbgd->flag & 0x80000000) == 0)) {
pbgd->flag |= 0x80000000;
} else {
return pbgd;
}
JUT_ASSERT(0x214, ((int)pbgd->m_v_tbl % 4) == 0);
JUT_ASSERT(0x215, ((int)pbgd->m_t_tbl % 2) == 0);
JUT_ASSERT(0x216, ((int)pbgd->m_b_tbl % 2) == 0);
JUT_ASSERT(0x217, ((int)pbgd->m_tree_tbl % 2) == 0);
JUT_ASSERT(0x218, ((int)pbgd->m_g_tbl % 4) == 0);
JUT_ASSERT(0x219, ((int)pbgd->m_ti_tbl % 4) == 0);
if (pbgd->m_v_tbl != NULL)
pbgd->m_v_tbl = (cBgD_Vtx_t*)((u32)pbgd->m_v_tbl + (u32)pbgd);
pbgd->m_t_tbl = (cBgD_Tri_t*)((u32)pbgd->m_t_tbl + (u32)pbgd);
pbgd->m_b_tbl = (cBgD_Blk_t*)((u32)pbgd->m_b_tbl + (u32)pbgd);
pbgd->m_tree_tbl = (cBgD_Tree_t*)((u32)pbgd->m_tree_tbl + (u32)pbgd);
pbgd->m_g_tbl = (cBgD_Grp_t*)((u32)pbgd->m_g_tbl + (u32)pbgd);
pbgd->m_ti_tbl = (cBgD_Ti_t*)((u32)pbgd->m_ti_tbl + (u32)pbgd);
for (s32 i = 0; i < pbgd->m_g_num; i++) {
pbgd->m_g_tbl[i].m_name = (char*)((u32)pbgd + (u32)pbgd->m_g_tbl[i].m_name);
}
return pbgd;
}
/* 80246C98-80246D24 .text GetActorPointer__4cBgSCFi */
fopAc_ac_c* cBgS::GetActorPointer(int actor_index) const {
JUT_ASSERT(0x237, 0 <= actor_index && actor_index < 256);
return m_chk_element[actor_index].m_actor_ptr;
}
/* 80246D24-80246D5C .text GetBgWPointer__4cBgSCFR13cBgS_PolyInfo */
cBgW* cBgS::GetBgWPointer(cBgS_PolyInfo& poly) const {
s32 id = poly.GetBgIndex();
if (!(0 <= id && id < 256) || !m_chk_element[id].ChkUsed())
return NULL;
return m_chk_element[id].m_bgw_base_ptr;
}
/* 80246D5C-80246DF8 .text ChkPolySafe__4cBgSFR13cBgS_PolyInfo */
bool cBgS::ChkPolySafe(cBgS_PolyInfo& poly) {
if (!poly.ChkSetInfo())
return false;
int id = poly.GetBgIndex();
if (!(0 <= id && id < 256))
return false;
if (!m_chk_element[id].ChkUsed())
return false;
return poly.ChkSafe(m_chk_element[id].m_bgw_base_ptr, m_chk_element[id].m_actor_id);
}
/* 80246DF8-80246F10 .text GetTriGrp__4cBgSCFii */
s32 cBgS::GetTriGrp(int bg_index, int poly_index) const {
JUT_ASSERT(0x278, 0 <= bg_index && bg_index < 256);
if (!m_chk_element[bg_index].ChkUsed())
return -1;
return m_chk_element[bg_index].m_bgw_base_ptr->GetTriGrp(poly_index);
}
/* 80246F10-80246FE4 .text GetGrpToRoomId__4cBgSCFii */
s32 cBgS::GetGrpToRoomId(int bg_index, int grp_id) const {
JUT_ASSERT(0x289, 0 <= bg_index && bg_index < 256);
if (!m_chk_element[bg_index].ChkUsed())
return 0xFFFF;
if (grp_id == 0xFFFF)
return 0xFFFF;
return m_chk_element[bg_index].m_bgw_base_ptr->GetGrpToRoomIndex(grp_id);
}
/* 80246FE4-802470B8 .text GetTriPla__4cBgSCFii */
cM3dGPla* cBgS::GetTriPla(int bg_index, int poly_index) const {
if (!(0 <= bg_index && bg_index < 256))
return NULL;
if (!m_chk_element[bg_index].ChkUsed())
return NULL;
return m_chk_element[bg_index].m_bgw_base_ptr->GetTriPla(poly_index);
}
static void dummy2() {
// from c_bg_s_poly_info.h
OSReport("0 <= grp_index && grp_index < pm_bgd->m_g_num");
}
/* 802470B8-80247178 .text GetTriPnt__4cBgSCFR13cBgS_PolyInfoP4cXyzP4cXyzP4cXyz */
void cBgS::GetTriPnt(cBgS_PolyInfo& poly, cXyz* p0, cXyz* p1, cXyz* p2) const {
s32 id = poly.GetBgIndex();
JUT_ASSERT(0x2f6, 0 <= id && id < 256);
if (m_chk_element[id].ChkUsed())
m_chk_element[id].m_bgw_base_ptr->GetTriPnt(poly.GetPolyIndex(), p0, p1, p2);
}
/* 80247178-8024717C .text Move__4cBgSFv */
void cBgS::Move() {
}
/* 8024717C-802471E8 .text ShdwDraw__4cBgSFP13cBgS_ShdwDraw */
void cBgS::ShdwDraw(cBgS_ShdwDraw* shdw) {
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
if (m_chk_element[i].ChkUsed())
m_chk_element[i].m_bgw_base_ptr->ShdwDraw(shdw);
}
/* 802471E8-80247304 .text GetGrpInf__4cBgSCFR13cBgS_PolyInfoi */
s32 cBgS::GetGrpInf(cBgS_PolyInfo& poly, int grp_id) const {
s32 bg_index = poly.GetBgIndex();
JUT_ASSERT(0x37d, 0 <= bg_index && bg_index < 256);
if (!m_chk_element[bg_index].ChkUsed())
return -1;
return m_chk_element[bg_index].m_bgw_base_ptr->GetGrpInf(grp_id);
}
|