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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
//
// Generated by dtk
// Translation Unit: d_s_room.cpp
//
#include "d/dolzel.h" // IWYU pragma: keep
#include "d/d_s_room.h"
#include "f_op/f_op_scene.h"
#include "f_op/f_op_scene_mng.h"
#include "f_op/f_op_actor_mng.h"
#include "f_pc/f_pc_layer_iter.h"
#include "d/d_com_inf_game.h"
#include "d/d_com_lib_game.h"
#include "d/d_item_data.h"
#include "d/d_map.h"
#include "d/d_stage.h"
#include "d/actor/d_a_salvage.h"
#include "d/actor/d_a_npc_md.h"
#include "m_Do/m_Do_dvd_thread.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JKernel/JKRExpHeap.h"
#include "stdio.h"
// Fake inline: An inline like this seems necessary for setMapImage to match, but it isn't in the debug maps.
// TODO: Try to find a way to match setMapImage with real inlines.
inline f32 getActorPositionY(fopAc_ac_c* actor) {
return actor->current.pos.y;
}
/* 80236938-80236998 .text setMapImage__FP19room_of_scene_class */
void setMapImage(room_of_scene_class* i_this) {
if (i_this->mbSetMap)
return;
if (dComIfGp_roomControl_getStayNo() >= 0) {
dComIfGp_map_setImage(fopScnM_GetParam(i_this), dComIfGp_roomControl_getStayNo(), getActorPositionY(dComIfGp_getPlayer(0)));
i_this->mbSetMap = true;
}
}
/* 80236998-802369C8 .text deleteMapImage__FP19room_of_scene_class */
void deleteMapImage(room_of_scene_class* i_this) {
if (!i_this->mbSetMap)
return;
dComIfGp_map_deleteImage(fopScnM_GetParam(i_this));
}
/* 802369C8-80236A0C .text setArcName__FP19room_of_scene_class */
char* setArcName(room_of_scene_class* i_this) {
static char arcName[32];
sprintf(arcName, "Room%d", fopScnM_GetParam(i_this));
return arcName;
}
/* 80236A0C-80236A14 .text dScnRoom_Draw__FP19room_of_scene_class */
static BOOL dScnRoom_Draw(room_of_scene_class* i_this) {
return TRUE;
}
/* 80236A14-80236A38 .text deleteJugge__FPvPv */
void* deleteJugge(void* i_this, void*) {
fpcM_Delete(i_this);
return NULL;
}
/* 80236A38-80236B1C .text objectSetCheck__FP19room_of_scene_class */
void objectSetCheck(room_of_scene_class* i_this) {
s32 roomNo = fopScnM_GetParam(i_this);
s32 hiddenFlag = dComIfGp_roomControl_checkStatusFlag(roomNo, 0x08);
if (!i_this->mbReLoaded) {
if (!hiddenFlag) {
fopAcM_create(fpcNm_BG_e, roomNo);
dStage_dt_c_roomReLoader(i_this->mpRoomData, i_this->mpRoomDt, roomNo);
i_this->mbReLoaded = true;
}
} else {
s32 roomNo = fopScnM_GetParam(i_this);
if (hiddenFlag) {
fpcLyIt_Judge(fpcM_Layer(i_this), deleteJugge, NULL);
dComIfGs_clearRoomSwitch(dComIfGp_roomControl_getZoneNo(roomNo));
i_this->mbReLoaded = false;
}
}
}
/* 80236B1C-80236BAC .text dScnRoom_Execute__FP19room_of_scene_class */
static BOOL dScnRoom_Execute(room_of_scene_class* i_this) {
u32 roomNo = fopScnM_GetParam(i_this);
setMapImage(i_this);
if (dComIfGp_roomControl_checkStatusFlag(roomNo, 0x04)) {
fopScnM_DeleteReq(i_this);
return TRUE;
} else {
if (dComIfGp_roomControl_checkStatusFlag(roomNo, 0x02)) {
dComIfGp_roomControl_offStatusFlag(roomNo, 0x02);
dComIfGp_roomControl_onStatusFlag(roomNo, 0x01);
} else {
objectSetCheck(i_this);
}
}
return TRUE;
}
/* 80236BAC-80236BB4 .text dScnRoom_IsDelete__FP19room_of_scene_class */
static BOOL dScnRoom_IsDelete(room_of_scene_class* i_this) {
return TRUE;
}
/* 80236BB4-80236D24 .text dScnRoom_Delete__FP19room_of_scene_class */
static BOOL dScnRoom_Delete(room_of_scene_class* i_this) {
int roomNo = fopScnM_GetParam(i_this);
deleteMapImage(i_this);
const char * arcName = setArcName(i_this);
dComIfG_deleteStageRes(arcName);
dStage_roomControl_c::mStatus[roomNo].mFlags = 0;
dComIfGp_roomControl_getStatusRoomDt(roomNo)->init();
if (i_this->mbHasRoomParticle)
dComIfGp_particle_removeRoomScene();
if (!dComIfGp_isEnableNextStage()) {
if (i_this->field_0x1dc == 1) {
dComIfGs_onEventBit(dSv_event_flag_c::UNK_1A80);
}
if (strcmp(dComIfGp_getStartStageName(), "sea") == 0)
dComIfGs_offTmpBit(dSv_event_tmp_flag_c::UNK_0320);
}
if (i_this->field_0x1dc == 2)
dComIfGs_onEventBit(dSv_event_flag_c::UNK_1C40);
if (strcmp(dComIfGp_getStartStageName(), "sea") == 0)
daNpc_Md_c::offSeaTalk();
daSalvage_c::init_room(roomNo);
JKRHeap * pHeap = dStage_roomControl_c::getMemoryBlock(roomNo);
if (pHeap != NULL)
pHeap->freeAll();
return TRUE;
}
/* 80236D24-80236D58 .text phase_0__FP19room_of_scene_class */
cPhs_State phase_0(room_of_scene_class* i_this) {
s32 roomNo = fopScnM_GetParam(i_this);
dStage_roomControl_c::setStatusProcID(roomNo, fopScnM_GetID(i_this));
return cPhs_NEXT_e;
}
/* 80236D58-80236DE8 .text phase_1__FP19room_of_scene_class */
cPhs_State phase_1(room_of_scene_class* i_this) {
s32 roomNo = fopScnM_GetParam(i_this);
JKRExpHeap * pHeap = dStage_roomControl_c::getMemoryBlock(roomNo);
if (pHeap != NULL && pHeap->getTotalUsedSize() != 0)
return cPhs_INIT_e;
const char * arcName = setArcName(i_this);
BOOL rt = dComIfG_setStageRes(arcName, pHeap);
#if VERSION == VERSION_DEMO
JUT_ASSERT(380, rt == TRUE);
#else
if (!rt) {
dStage_escapeRestart();
return cPhs_ERROR_e;
}
#endif
return cPhs_NEXT_e;
}
/* 80236DE8-802370A0 .text phase_2__FP19room_of_scene_class */
cPhs_State phase_2(room_of_scene_class* i_this) {
const char * arcName = setArcName(i_this);
s32 rt = dComIfG_syncStageRes(arcName);
#if VERSION > VERSION_DEMO
if (rt < 0) {
dStage_escapeRestart();
return cPhs_ERROR_e;
}
#endif
JUT_ASSERT(DEMO_SELECT(394, 448), rt >= 0);
if (rt != 0)
return cPhs_INIT_e;
int roomNo = fopScnM_GetParam(i_this);
s32 zoneNo = dComIfGp_roomControl_getZoneNo(roomNo);
if (zoneNo < 0) {
zoneNo = dComIfGs_createZone(roomNo);
dComIfGp_roomControl_setZoneNo(roomNo, zoneNo);
}
i_this->mpRoomDt = dComIfGp_roomControl_getStatusRoomDt(roomNo);
i_this->mpRoomDt->setRoomNo(roomNo);
i_this->mpRoomData = dComIfG_getStageRes(arcName, "room.dzr");
if (i_this->mpRoomData != NULL) {
dStage_dt_c_roomLoader(i_this->mpRoomData, i_this->mpRoomDt);
if (dStage_roomControl_c::mDemoArcName[0] == '\0') {
dStage_Lbnk_c * lbnk = dComIfGp_roomControl_getStatusRoomDt(roomNo)->getLbnk();
if (lbnk != NULL) {
u8* banks = lbnk->m_entries;
if (banks != NULL) {
u32 layerNo = dComIfG_play_c::getLayerNo(roomNo);
s32 bank = banks[layerNo];
if (bank != 0xFF) {
JUT_ASSERT(DEMO_SELECT(421, 475), 0 <= bank && bank < 100);
sprintf(dStage_roomControl_c::mDemoArcName, "Demo%02d", bank);
if (!dComIfG_setObjectRes(dStage_roomControl_c::mDemoArcName, JKRArchive::DEFAULT_MOUNT_DIRECTION, NULL))
dStage_roomControl_c::mDemoArcName[0] = '\0';
}
}
}
}
dStage_FileList_dt_c * fileList = dComIfGp_roomControl_getStatusRoomDt(roomNo)->getFileListInfo();
JUT_ASSERT(DEMO_SELECT(445, 499), fileList != NULL);
u8 particleNo = dStage_FileList_dt_GetParticleNo(fileList);
i_this->mbHasRoomParticle = dComIfGp_particle_readScene(particleNo, &i_this->sceneCommand);
}
return cPhs_NEXT_e;
}
/* 802370B8-802371D0 .text phase_3__FP19room_of_scene_class */
cPhs_State phase_3(room_of_scene_class* i_this) {
if (dStage_roomControl_c::getDemoArcName()[0] != '\0') {
s32 rt = dComIfG_syncObjectRes(dStage_roomControl_c::getDemoArcName());
if (rt < 0) {
#if VERSION > VERSION_DEMO
dStage_escapeRestart();
#endif
return cPhs_ERROR_e;
} else if (rt > 0) {
return cPhs_INIT_e;
}
}
if (i_this->sceneCommand != NULL) {
if (i_this->sceneCommand->sync() == 0)
return cPhs_INIT_e;
JUT_ASSERT(DEMO_SELECT(477, 533), i_this->sceneCommand->getMemAddress() != NULL);
dComIfGp_particle_createRoomScene(i_this->sceneCommand->getMemAddress());
delete i_this->sceneCommand;
}
objectSetCheck(i_this);
return cPhs_NEXT_e;
}
/* 802371D0-802372C4 .text phase_4__FP19room_of_scene_class */
cPhs_State phase_4(room_of_scene_class* i_this) {
if (dComIfGp_getPlayer(0) == NULL)
return cPhs_INIT_e;
s32 roomNo = fopScnM_GetParam(i_this);
setMapImage(i_this);
if (dComIfGs_checkGetItem(dItemNo_PEARL_DIN_e))
i_this->field_0x1dc = 1;
if (strcmp(dComIfGp_getStartStageName(), "Omori") == 0 && dComIfGs_checkGetItem(dItemNo_PEARL_FARORE_e))
i_this->field_0x1dc = 2;
// Bug? The game seems to set these flags for DRI even when you're not on the sea stage.
// TODO: Look into this more.
if (roomNo == dIsleRoom_DragonRoostIsland_e) {
dComIfGs_setEventReg(dSv_event_flag_c::UNK_B8FF, 0);
if (dComIfGs_isEventBit(dSv_event_flag_c::UNK_3F02))
dComIfGs_onEventBit(dSv_event_flag_c::UNK_1580);
}
return cPhs_COMPLEATE_e;
}
/* 802372C4-802372F4 .text dScnRoom_Create__FP11scene_class */
static cPhs_State dScnRoom_Create(scene_class* i_scn) {
static cPhs__Handler l_method[] = {
(cPhs__Handler)phase_0,
(cPhs__Handler)phase_1,
(cPhs__Handler)phase_2,
(cPhs__Handler)phase_3,
(cPhs__Handler)phase_4,
};
room_of_scene_class* i_this = (room_of_scene_class*)i_scn;
return dComLbG_PhaseHandler(&i_this->mPhs, l_method, i_this);
}
static scene_method_class l_dScnRoom_Method = {
(process_method_func)dScnRoom_Create,
(process_method_func)dScnRoom_Delete,
(process_method_func)dScnRoom_Execute,
(process_method_func)dScnRoom_IsDelete,
(process_method_func)dScnRoom_Draw,
};
scene_process_profile_definition g_profile_ROOM_SCENE = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 0,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_ROOM_SCENE_e,
/* Proc SubMtd */ &g_fpcNd_Method.base,
/* Size */ sizeof(room_of_scene_class),
/* Size Other */ 0,
/* Parameters */ 0,
/* Node SubMtd */ &g_fopScn_Method.base,
/* Scene SubMtd */ &l_dScnRoom_Method,
};
|