2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
|
|
|
#include "vt.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
void Room_Draw0(PlayState* play, Room* room, u32 flags);
|
|
|
|
void Room_Draw2(PlayState* play, Room* room, u32 flags);
|
|
|
|
void Room_Draw1(PlayState* play, Room* room, u32 flags);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
Vec3f D_801270A0 = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
|
|
|
// unused
|
2020-03-22 21:19:43 +00:00
|
|
|
Gfx D_801270B0[] = {
|
2020-03-17 04:31:30 +00:00
|
|
|
gsDPPipeSync(),
|
|
|
|
gsSPClearGeometryMode(G_ZBUFFER | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD),
|
|
|
|
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
|
2020-04-05 19:41:49 +00:00
|
|
|
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
|
2020-03-22 21:19:43 +00:00
|
|
|
gsDPSetOtherMode(G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
|
|
|
|
G_TD_CLAMP | G_TP_PERSP | G_CYC_FILL | G_PM_NPRIMITIVE,
|
2020-03-17 04:31:30 +00:00
|
|
|
G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2),
|
|
|
|
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH),
|
2020-03-29 16:43:45 +00:00
|
|
|
gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
|
2020-03-17 04:31:30 +00:00
|
|
|
gsSPClipRatio(FRUSTRATIO_1),
|
|
|
|
gsSPEndDisplayList(),
|
|
|
|
};
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
void (*sRoomDrawHandlers[MESH_HEADER_TYPE_MAX])(PlayState* play, Room* room, u32 flags) = {
|
|
|
|
Room_Draw0,
|
|
|
|
Room_Draw1,
|
|
|
|
Room_Draw2,
|
2020-03-17 04:31:30 +00:00
|
|
|
};
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void func_80095AA0(PlayState* play, Room* room, Input* arg2, UNK_TYPE arg3) {
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
void Room_Draw0(PlayState* play, Room* room, u32 flags) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 i;
|
2022-06-09 19:02:18 +00:00
|
|
|
MeshHeader0* meshHeader0;
|
|
|
|
MeshHeader01Entry* meshHeader0Entry;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 193);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_OPA) {
|
2022-05-21 18:23:43 +00:00
|
|
|
func_800342EC(&D_801270A0, play);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
|
2022-05-21 18:23:43 +00:00
|
|
|
func_80093C80(play);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_XLU) {
|
2022-05-21 18:23:43 +00:00
|
|
|
func_8003435C(&D_801270A0, play);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
|
2022-06-03 22:25:48 +00:00
|
|
|
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
meshHeader0 = &room->meshHeader->meshHeader0;
|
|
|
|
meshHeader0Entry = SEGMENTED_TO_VIRTUAL(meshHeader0->entries);
|
|
|
|
for (i = 0; i < meshHeader0->numEntries; i++) {
|
|
|
|
if ((flags & ROOM_DRAW_OPA) && (meshHeader0Entry->opa != NULL)) {
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, meshHeader0Entry->opa);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
if ((flags & ROOM_DRAW_XLU) && (meshHeader0Entry->xlu != NULL)) {
|
|
|
|
gSPDisplayList(POLY_XLU_DISP++, meshHeader0Entry->xlu);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
meshHeader0Entry++;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 239);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SHAPE_SORT_MAX 64
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
typedef struct struct_80095D04 {
|
2022-06-09 19:02:18 +00:00
|
|
|
/* 0x00 */ MeshHeader2Entry* unk_00;
|
2020-03-22 21:19:43 +00:00
|
|
|
/* 0x04 */ f32 unk_04;
|
2020-03-17 04:31:30 +00:00
|
|
|
/* 0x08 */ struct struct_80095D04* unk_08;
|
|
|
|
/* 0x0C */ struct struct_80095D04* unk_0C;
|
|
|
|
} struct_80095D04; // size = 0x10
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
void Room_Draw2(PlayState* play, Room* room, u32 flags) {
|
|
|
|
MeshHeader2* meshHeader2;
|
|
|
|
MeshHeader2Entry* meshHeader2Entry;
|
2020-03-17 04:31:30 +00:00
|
|
|
struct_80095D04 spB8[SHAPE_SORT_MAX];
|
2020-12-19 03:09:38 +00:00
|
|
|
struct_80095D04* spB4 = NULL;
|
|
|
|
struct_80095D04* spB0 = NULL;
|
2022-02-27 21:32:05 +00:00
|
|
|
struct_80095D04* iter;
|
2021-09-20 19:37:47 +00:00
|
|
|
s32 pad;
|
2020-03-17 04:31:30 +00:00
|
|
|
struct_80095D04* spA4;
|
2022-02-27 21:32:05 +00:00
|
|
|
s32 j;
|
|
|
|
s32 i;
|
|
|
|
Vec3f pos;
|
|
|
|
Vec3f projectedPos;
|
|
|
|
f32 projectedW;
|
2021-09-20 19:37:47 +00:00
|
|
|
s32 pad2;
|
2022-06-09 19:02:18 +00:00
|
|
|
MeshHeader2Entry* meshHeader2Entries;
|
|
|
|
MeshHeader2Entry* meshHeader2EntryIter;
|
2020-03-17 04:31:30 +00:00
|
|
|
f32 temp_f2;
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287);
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_OPA) {
|
2022-05-21 18:23:43 +00:00
|
|
|
func_800342EC(&D_801270A0, play);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
|
2022-05-21 18:23:43 +00:00
|
|
|
func_80093C80(play);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
2020-12-19 03:09:38 +00:00
|
|
|
if (1) {}
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_XLU) {
|
2022-05-21 18:23:43 +00:00
|
|
|
func_8003435C(&D_801270A0, play);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
|
2022-06-03 22:25:48 +00:00
|
|
|
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
meshHeader2 = &room->meshHeader->meshHeader2;
|
|
|
|
meshHeader2Entry = SEGMENTED_TO_VIRTUAL(meshHeader2->entries);
|
2020-12-19 03:09:38 +00:00
|
|
|
spA4 = spB8;
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
ASSERT(meshHeader2->numEntries <= SHAPE_SORT_MAX, "polygon2->num <= SHAPE_SORT_MAX", "../z_room.c", 317);
|
|
|
|
meshHeader2Entries = meshHeader2Entry;
|
2022-02-27 21:32:05 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
for (i = 0; i < meshHeader2->numEntries; i++, meshHeader2Entry++) {
|
|
|
|
pos.x = meshHeader2Entry->pos.x;
|
|
|
|
pos.y = meshHeader2Entry->pos.y;
|
|
|
|
pos.z = meshHeader2Entry->pos.z;
|
2022-05-21 18:23:43 +00:00
|
|
|
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW);
|
2022-06-09 19:02:18 +00:00
|
|
|
if (-(f32)meshHeader2Entry->unk_06 < projectedPos.z) {
|
|
|
|
temp_f2 = projectedPos.z - meshHeader2Entry->unk_06;
|
2022-05-21 18:23:43 +00:00
|
|
|
if (temp_f2 < play->lightCtx.fogFar) {
|
2022-06-09 19:02:18 +00:00
|
|
|
spA4->unk_00 = meshHeader2Entry;
|
2020-03-17 04:31:30 +00:00
|
|
|
spA4->unk_04 = temp_f2;
|
2022-02-27 21:32:05 +00:00
|
|
|
iter = spB4;
|
|
|
|
if (iter == NULL) {
|
2020-12-19 03:09:38 +00:00
|
|
|
spB4 = spB0 = spA4;
|
|
|
|
spA4->unk_08 = spA4->unk_0C = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
|
|
|
do {
|
2022-02-27 21:32:05 +00:00
|
|
|
if (spA4->unk_04 < iter->unk_04) {
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2022-02-27 21:32:05 +00:00
|
|
|
iter = iter->unk_0C;
|
|
|
|
} while (iter != NULL);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (iter == NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
spA4->unk_08 = spB0;
|
|
|
|
spA4->unk_0C = NULL;
|
|
|
|
spB0->unk_0C = spA4;
|
|
|
|
spB0 = spA4;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2022-02-27 21:32:05 +00:00
|
|
|
spA4->unk_08 = iter->unk_08;
|
2020-12-19 03:09:38 +00:00
|
|
|
if (spA4->unk_08 == NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
spB4 = spA4;
|
2020-03-23 23:11:21 +00:00
|
|
|
} else {
|
2020-12-19 03:09:38 +00:00
|
|
|
spA4->unk_08->unk_0C = spA4;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2022-02-27 21:32:05 +00:00
|
|
|
iter->unk_08 = spA4;
|
|
|
|
spA4->unk_0C = iter;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-19 03:09:38 +00:00
|
|
|
spA4++;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
iREG(87) = meshHeader2->numEntries & 0xFFFF & 0xFFFF & 0xFFFF; // if this is real then I might not be
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
for (i = 1; spB4 != NULL; spB4 = spB4->unk_0C, i++) {
|
|
|
|
Gfx* displayList;
|
2020-12-19 03:09:38 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
meshHeader2Entry = spB4->unk_00;
|
2020-03-22 21:19:43 +00:00
|
|
|
if (iREG(86) != 0) {
|
2022-06-09 19:02:18 +00:00
|
|
|
meshHeader2EntryIter = meshHeader2Entries;
|
|
|
|
for (j = 0; j < meshHeader2->numEntries; j++, meshHeader2EntryIter++) {
|
|
|
|
if (meshHeader2Entry == meshHeader2EntryIter) {
|
2020-12-19 03:09:38 +00:00
|
|
|
break; // This loop does nothing?
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (((iREG(86) == 1) && (iREG(89) >= i)) || ((iREG(86) == 2) && (iREG(89) == i))) {
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_OPA) {
|
|
|
|
displayList = meshHeader2Entry->opa;
|
2022-02-27 21:32:05 +00:00
|
|
|
if (displayList != NULL) {
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, displayList);
|
2020-12-19 03:09:38 +00:00
|
|
|
}
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_XLU) {
|
|
|
|
displayList = meshHeader2Entry->xlu;
|
2022-02-27 21:32:05 +00:00
|
|
|
if (displayList != NULL) {
|
|
|
|
gSPDisplayList(POLY_XLU_DISP++, displayList);
|
2020-12-19 03:09:38 +00:00
|
|
|
}
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_OPA) {
|
|
|
|
displayList = meshHeader2Entry->opa;
|
2022-02-27 21:32:05 +00:00
|
|
|
if (displayList != NULL) {
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, displayList);
|
2020-12-19 03:09:38 +00:00
|
|
|
}
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_XLU) {
|
|
|
|
displayList = meshHeader2Entry->xlu;
|
2022-02-27 21:32:05 +00:00
|
|
|
if (displayList != NULL) {
|
|
|
|
gSPDisplayList(POLY_XLU_DISP++, displayList);
|
2020-12-19 03:09:38 +00:00
|
|
|
}
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
iREG(88) = i - 1;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 430);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define JPEG_MARKER 0xFFD8FFE0
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
s32 func_80096238(void* data) {
|
2020-03-17 04:31:30 +00:00
|
|
|
OSTime time;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (*(u32*)data == JPEG_MARKER) {
|
2021-09-04 13:33:19 +00:00
|
|
|
osSyncPrintf("JPEGデータを展開します\n"); // "Expanding jpeg data"
|
|
|
|
osSyncPrintf("JPEGデータアドレス %08x\n", data); // "Jpeg data address %08x"
|
|
|
|
// "Work buffer address (Z buffer) %08x"
|
2020-03-17 04:31:30 +00:00
|
|
|
osSyncPrintf("ワークバッファアドレス(Zバッファ)%08x\n", gZBuffer);
|
|
|
|
|
2020-04-08 16:36:15 +00:00
|
|
|
time = osGetTime();
|
2021-06-01 19:27:07 +00:00
|
|
|
if (!Jpeg_Decode(data, gZBuffer, gGfxSPTaskOutputBuffer, sizeof(gGfxSPTaskOutputBuffer))) {
|
2020-04-08 16:36:15 +00:00
|
|
|
time = osGetTime() - time;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-09-04 13:33:19 +00:00
|
|
|
// "Success... I think. time = %6.3f ms"
|
2020-10-13 16:32:19 +00:00
|
|
|
osSyncPrintf("成功…だと思う。 time = %6.3f ms \n", OS_CYCLES_TO_USEC(time) / 1000.0f);
|
2021-09-04 13:33:19 +00:00
|
|
|
// "Writing back to original address from work buffer."
|
2020-03-17 04:31:30 +00:00
|
|
|
osSyncPrintf("ワークバッファから元のアドレスに書き戻します。\n");
|
2021-09-04 13:33:19 +00:00
|
|
|
// "If the original buffer size isn't at least 150kb, it will be out of control."
|
2020-03-17 04:31:30 +00:00
|
|
|
osSyncPrintf("元のバッファのサイズが150キロバイト無いと暴走するでしょう。\n");
|
|
|
|
|
|
|
|
bcopy(gZBuffer, data, sizeof(gZBuffer));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2021-09-04 13:33:19 +00:00
|
|
|
osSyncPrintf("失敗!なんで〜\n"); // "Failure! Why is it 〜"
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-07 19:19:13 +00:00
|
|
|
void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 mode0,
|
2020-03-22 21:19:43 +00:00
|
|
|
u16 tlutCount, f32 frameX, f32 frameY) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Gfx* displayListHead;
|
|
|
|
uObjBg* bg;
|
|
|
|
|
|
|
|
displayListHead = *displayList;
|
|
|
|
func_80096238(SEGMENTED_TO_VIRTUAL(source));
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
bg = (uObjBg*)(displayListHead + 1);
|
2020-12-19 03:09:38 +00:00
|
|
|
gSPBranchList(displayListHead, (u8*)bg + sizeof(uObjBg));
|
2020-03-17 04:31:30 +00:00
|
|
|
bg->b.imageX = 0;
|
|
|
|
bg->b.imageW = width * 4;
|
|
|
|
bg->b.frameX = frameX * 4;
|
|
|
|
bg->b.imageY = 0;
|
|
|
|
bg->b.imageH = height * 4;
|
|
|
|
bg->b.frameY = frameY * 4;
|
2021-12-07 19:19:13 +00:00
|
|
|
bg->b.imagePtr = source;
|
2020-03-17 04:31:30 +00:00
|
|
|
bg->b.imageLoad = G_BGLT_LOADTILE;
|
|
|
|
bg->b.imageFmt = fmt;
|
|
|
|
bg->b.imageSiz = siz;
|
|
|
|
bg->b.imagePal = 0;
|
|
|
|
bg->b.imageFlip = 0;
|
|
|
|
|
2020-12-19 03:09:38 +00:00
|
|
|
displayListHead = (void*)(bg + 1);
|
2020-03-22 21:19:43 +00:00
|
|
|
if (fmt == G_IM_FMT_CI) {
|
2020-03-17 04:31:30 +00:00
|
|
|
gDPLoadTLUT(displayListHead++, tlutCount, 256, tlut);
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
gDPPipeSync(displayListHead++);
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if ((fmt == G_IM_FMT_RGBA) && (SREG(26) == 0)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
bg->b.frameW = width * 4;
|
|
|
|
bg->b.frameH = height * 4;
|
2020-05-25 21:18:14 +00:00
|
|
|
guS2DInitBg(bg);
|
2020-04-05 19:41:49 +00:00
|
|
|
gDPSetOtherMode(displayListHead++, mode0 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE,
|
2020-03-17 04:31:30 +00:00
|
|
|
G_AC_THRESHOLD | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2);
|
|
|
|
gSPBgRectCopy(displayListHead++, bg);
|
2020-12-19 03:09:38 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
bg->s.frameW = width * 4;
|
|
|
|
bg->s.frameH = height * 4;
|
|
|
|
bg->s.scaleW = 1024;
|
|
|
|
bg->s.scaleH = 1024;
|
|
|
|
bg->s.imageYorig = bg->b.imageY;
|
2020-12-19 03:09:38 +00:00
|
|
|
gDPSetOtherMode(displayListHead++,
|
|
|
|
mode0 | G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE |
|
|
|
|
G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
|
2020-03-22 21:19:43 +00:00
|
|
|
G_AC_THRESHOLD | G_ZS_PIXEL | AA_EN | CVG_DST_CLAMP | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL |
|
|
|
|
GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_BL, G_BL_1MA) |
|
|
|
|
GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_BL, G_BL_1MA));
|
|
|
|
gDPSetCombineLERP(displayListHead++, 0, 0, 0, TEXEL0, 0, 0, 0, 1, 0, 0, 0, TEXEL0, 0, 0, 0, 1);
|
2020-04-05 19:41:49 +00:00
|
|
|
gSPObjRenderMode(displayListHead++, G_OBJRM_ANTIALIAS | G_OBJRM_BILERP);
|
2020-03-17 04:31:30 +00:00
|
|
|
gSPBgRect1Cyc(displayListHead++, bg);
|
|
|
|
}
|
|
|
|
|
|
|
|
gDPPipeSync(displayListHead++);
|
|
|
|
*displayList = displayListHead;
|
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
void Room_Draw1Single(PlayState* play, Room* room, u32 flags) {
|
2022-05-12 18:35:31 +00:00
|
|
|
Camera* activeCam;
|
2020-03-17 04:31:30 +00:00
|
|
|
Gfx* spA8;
|
2022-06-09 19:02:18 +00:00
|
|
|
MeshHeader1Single* meshHeader1Single;
|
|
|
|
MeshHeader01Entry* meshHeader1Entry;
|
2022-02-27 21:32:05 +00:00
|
|
|
u32 isFixedCamera;
|
|
|
|
u32 drawBg;
|
|
|
|
u32 drawOpa;
|
|
|
|
u32 drawXlu;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 628);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
activeCam = GET_ACTIVE_CAM(play);
|
2022-05-12 18:35:31 +00:00
|
|
|
isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED);
|
2022-06-09 19:02:18 +00:00
|
|
|
meshHeader1Single = &room->meshHeader->meshHeader1Single;
|
|
|
|
meshHeader1Entry = SEGMENTED_TO_VIRTUAL(meshHeader1Single->base.entry);
|
|
|
|
drawBg = (flags & ROOM_DRAW_OPA) && isFixedCamera && meshHeader1Single->source && !(SREG(25) & 1);
|
|
|
|
drawOpa = (flags & ROOM_DRAW_OPA) && (meshHeader1Entry->opa != NULL) && !(SREG(25) & 2);
|
|
|
|
drawXlu = (flags & ROOM_DRAW_XLU) && (meshHeader1Entry->xlu != NULL) && !(SREG(25) & 4);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawOpa || drawBg) {
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawOpa) {
|
2022-06-03 22:25:48 +00:00
|
|
|
Gfx_SetupDL_25Opa(play->state.gfxCtx);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2022-06-09 19:02:18 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, meshHeader1Entry->opa);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawBg) {
|
2022-05-03 22:43:09 +00:00
|
|
|
gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2d_fifo);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
{
|
2020-03-17 04:31:30 +00:00
|
|
|
Vec3f sp60;
|
2020-10-29 21:31:09 +00:00
|
|
|
spA8 = POLY_OPA_DISP;
|
2022-05-12 18:35:31 +00:00
|
|
|
Camera_GetSkyboxOffset(&sp60, activeCam);
|
2022-06-09 19:02:18 +00:00
|
|
|
func_8009638C(&spA8, meshHeader1Single->source, meshHeader1Single->tlut, meshHeader1Single->width,
|
|
|
|
meshHeader1Single->height, meshHeader1Single->fmt, meshHeader1Single->siz,
|
|
|
|
meshHeader1Single->mode0, meshHeader1Single->tlutCount,
|
2020-03-22 21:19:43 +00:00
|
|
|
(sp60.x + sp60.z) * 1.2f + sp60.y * 0.6f, sp60.y * 2.4f + (sp60.x + sp60.z) * 0.3f);
|
2020-10-29 21:31:09 +00:00
|
|
|
POLY_OPA_DISP = spA8;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-03 22:43:09 +00:00
|
|
|
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawXlu) {
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
|
2022-06-03 22:25:48 +00:00
|
|
|
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2022-06-09 19:02:18 +00:00
|
|
|
gSPDisplayList(POLY_XLU_DISP++, meshHeader1Entry->xlu);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 691);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
BgImage* func_80096A74(MeshHeader1Multi* meshHeader1Multi, PlayState* play) {
|
2022-05-21 18:23:43 +00:00
|
|
|
Camera* activeCam = GET_ACTIVE_CAM(play);
|
2022-05-12 18:35:31 +00:00
|
|
|
s32 camDataIdx;
|
|
|
|
s16 camDataIdx2;
|
2020-03-17 04:31:30 +00:00
|
|
|
Player* player;
|
|
|
|
BgImage* bgImage;
|
|
|
|
s32 i;
|
|
|
|
|
2022-05-12 18:35:31 +00:00
|
|
|
camDataIdx = activeCam->camDataIdx;
|
decompile z_camera (#398)
* cleanup
* name camera action functions
* decompile a few small functions, name a few Camera struct members
* decompile camera data, decompile a few camera functions
* Split ASM for code_800BB0A0
* removing code_800BB0A0.s
* PR Requests, Camera WIP
* remove #define NON_MATCHING from db_camera
* rename code_8007BF90.c to z_olib.c, rename functions in z_olib.c
* camera wip
* rename some struct memebers, some decomp wip
* pr updates
* camera wip
* name some fields in Camera Struct, being making sense of Camera_Update
* Camera WIP
* wip
* wip
* add z64camera.h header, begin creating CameraSetting macros
* wip
* wip
* wip
* wip
* migrate camera bss to c
* match a couple functions in db_camera
* match some small db_camera functions
* wip
* migrate db_camera rodata, match a few functions
* remote db_camera.rodata.s
* match some of db_camera
* identify types of some unknown data pieces
* some small wip
* Match Camera_Init, some function changes, some struct name changes. Change unk_C0 and unk_CC to floats from Vec3fs
* add naming for a few more Camera struct members
* wip
* match func_80043F94
* Match Camera_Jump1
* document some of Camera_Jump1
* wip
* match Camera_Jump3
* Match Camera_Update, FeelsAmazing
* wip
* wip
* match Camera_SetParam
* minor cleanup
* wip
* wip
* match Camera_KeepOn0
* some documentation, modify some matching functions to match style of others.
* match Camera_Demo1
* match camera_demo9
* document Camera_Demo1 and Camera_Demo9
* wip
* Match camera_battle4
* match camera_unique2
* Match Camera_Unique3
* match camera_special6
* match Camera_Special5
* wip
* document camera_special6
* naming updates
* match camera_Unique1
* match Camera_Unique0
* wip
* Match Camera_CalcUpFromPitchYawRoll
* match func_80045508
* document Camera_Battle4
* document several camera functions, move camera data to separate file
* rename phi/theta to pitch/yaw
* wip
* uniq9 wip
* Camera_Unqiue9 OK
* document Camera_Unique9
* name unk_160 in camera struct
* wip
* wip
* minor updates
* fix conflicts
* wip
* wip
* Olib updates
* wip
* wip
* rename most Math3D functions, few matches, documentation
* wip
* document most of math3d
* wip
* wip
* wip
* pr updates
* Match Camera_Fixed4
* match func_80058E8C
* pr updates
* add missing comment block finalizer
* Merge math3dupdates
* match Camera_ChangeSetting
* Match Camera_ChangeMode
* match func_80058148
* Match Camera_Special9
* decompile the rest of camera data
* match Camera_Demo5
* name a few camera functions in z_play
* match func_80046CB4, some work on other fucntions
* wip
* impove some non matchings
* fix function rename
* match func_800588B4
* match Camera_Subj4
* wip
* Camera_Demo3 matching, Camera_Battle1 big progress
* Camera_Normal2 OK
* wip
* match Camera_Parallel1
* normalize some things across functions
* match Camera_Normal1
* Match Camera_Normal3
* some cleanup
* more cleanup
* more cleanup , match Camera_CalcDefaultPitch
* data formatting
* Match Camera_Jump2
* document Camera_Jump2
* Match Camera_KeepOn3
* document some of Camera_KeepOn3
* improve some non_matchings
* match func_80045C74 and func_800460A8
* code cleanup, documentation
* match Camera_KeepOn1
* Match Camera_Subj3
* Match Camera_Battle1
* remove non_matching from func_80044adc and func_80046e20
* name several members of Battle1
* more documentation on Battle1
* cleanup
* renaming Camera_Vec3fScaleXYZFactor to Camera_Vec3fTranslateByUnitVector
* reorganize update structs, remove final references to params, remove CameraParams union
* implement camera enums into player
* Renaming Camera_GetDir to Camera_GetInputDir, Camera_GetRealDir to Camera_GetCamDir, etc, implement camera enum's into player
* remove non-global camera variables from variables.h
* clean up some variable declarations
* finish pr comment updates
* fix some warnings
* data formatting
* finish commenting on data
* delete unused asm
* remove asm
Co-authored-by: fig <fig02srl@gmail.com>
2020-12-06 22:39:47 +00:00
|
|
|
// jfifid
|
2022-05-21 18:23:43 +00:00
|
|
|
camDataIdx2 = func_80041C10(&play->colCtx, camDataIdx, BGCHECK_SCENE)[2].y;
|
2022-05-12 18:35:31 +00:00
|
|
|
if (camDataIdx2 >= 0) {
|
|
|
|
camDataIdx = camDataIdx2;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
player = GET_PLAYER(play);
|
2022-05-12 18:35:31 +00:00
|
|
|
player->actor.params = (player->actor.params & 0xFF00) | camDataIdx;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
bgImage = SEGMENTED_TO_VIRTUAL(meshHeader1Multi->list);
|
|
|
|
for (i = 0; i < meshHeader1Multi->count; i++) {
|
2022-05-12 18:35:31 +00:00
|
|
|
if (bgImage->id == camDataIdx) {
|
2020-03-17 04:31:30 +00:00
|
|
|
return bgImage;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
bgImage++;
|
|
|
|
}
|
|
|
|
|
2021-09-04 13:33:19 +00:00
|
|
|
// "z_room.c: Data consistent with camera id does not exist camid=%d"
|
2022-05-12 18:35:31 +00:00
|
|
|
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, camDataIdx);
|
2020-03-17 04:31:30 +00:00
|
|
|
LogUtils_HungupThread("../z_room.c", 726);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
void Room_Draw1Multi(PlayState* play, Room* room, u32 flags) {
|
2022-05-12 18:35:31 +00:00
|
|
|
Camera* activeCam;
|
2022-02-27 21:32:05 +00:00
|
|
|
Gfx* gfx;
|
2022-06-09 19:02:18 +00:00
|
|
|
MeshHeader1Multi* meshHeader1Multi;
|
2020-08-23 21:50:30 +00:00
|
|
|
BgImage* bgImage;
|
2022-06-09 19:02:18 +00:00
|
|
|
MeshHeader01Entry* meshHeader1Entry;
|
2022-02-27 21:32:05 +00:00
|
|
|
u32 isFixedCamera;
|
|
|
|
u32 drawBg;
|
|
|
|
u32 drawOpa;
|
|
|
|
u32 drawXlu;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 752);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
activeCam = GET_ACTIVE_CAM(play);
|
2022-05-12 18:35:31 +00:00
|
|
|
isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED);
|
2022-06-09 19:02:18 +00:00
|
|
|
meshHeader1Multi = &room->meshHeader->meshHeader1Multi;
|
|
|
|
meshHeader1Entry = SEGMENTED_TO_VIRTUAL(meshHeader1Multi->base.entry);
|
|
|
|
bgImage = func_80096A74(meshHeader1Multi, play);
|
|
|
|
drawBg = (flags & ROOM_DRAW_OPA) && isFixedCamera && bgImage->source && !(SREG(25) & 1);
|
|
|
|
drawOpa = (flags & ROOM_DRAW_OPA) && (meshHeader1Entry->opa != NULL) && !(SREG(25) & 2);
|
|
|
|
drawXlu = (flags & ROOM_DRAW_XLU) && (meshHeader1Entry->xlu != NULL) && !(SREG(25) & 4);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawOpa || drawBg) {
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawOpa) {
|
2022-06-03 22:25:48 +00:00
|
|
|
Gfx_SetupDL_25Opa(play->state.gfxCtx);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2022-06-09 19:02:18 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, meshHeader1Entry->opa);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawBg) {
|
2022-05-03 22:43:09 +00:00
|
|
|
gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2d_fifo);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
{
|
2022-02-27 21:32:05 +00:00
|
|
|
Vec3f skyboxOffset;
|
|
|
|
|
|
|
|
gfx = POLY_OPA_DISP;
|
2022-05-12 18:35:31 +00:00
|
|
|
Camera_GetSkyboxOffset(&skyboxOffset, activeCam);
|
2022-02-27 21:32:05 +00:00
|
|
|
func_8009638C(&gfx, bgImage->source, bgImage->tlut, bgImage->width, bgImage->height, bgImage->fmt,
|
2020-03-22 21:19:43 +00:00
|
|
|
bgImage->siz, bgImage->mode0, bgImage->tlutCount,
|
2022-02-27 21:32:05 +00:00
|
|
|
(skyboxOffset.x + skyboxOffset.z) * 1.2f + skyboxOffset.y * 0.6f,
|
|
|
|
skyboxOffset.y * 2.4f + (skyboxOffset.x + skyboxOffset.z) * 0.3f);
|
|
|
|
POLY_OPA_DISP = gfx;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-03 22:43:09 +00:00
|
|
|
gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData());
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (drawXlu) {
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
|
2022-06-03 22:25:48 +00:00
|
|
|
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
|
2022-06-09 19:02:18 +00:00
|
|
|
gSPDisplayList(POLY_XLU_DISP++, meshHeader1Entry->xlu);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 819);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
void Room_Draw1(PlayState* play, Room* room, u32 flags) {
|
|
|
|
MeshHeader1Base* meshHeader1Base = &room->meshHeader->meshHeader1Base;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-06-09 19:02:18 +00:00
|
|
|
if (meshHeader1Base->format == MESH_HEADER1_FORMAT_SINGLE) {
|
|
|
|
Room_Draw1Single(play, room, flags);
|
|
|
|
} else if (meshHeader1Base->format == MESH_HEADER1_FORMAT_MULTI) {
|
|
|
|
Room_Draw1Multi(play, room, flags);
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
LogUtils_HungupThread("../z_room.c", 841);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void func_80096FD4(PlayState* play, Room* room) {
|
2020-03-17 04:31:30 +00:00
|
|
|
room->num = -1;
|
|
|
|
room->segment = NULL;
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) {
|
2020-07-15 15:23:57 +00:00
|
|
|
u32 maxRoomSize = 0;
|
2022-05-21 18:23:43 +00:00
|
|
|
RomFile* roomList = play->roomList;
|
2020-07-15 15:23:57 +00:00
|
|
|
u32 roomSize;
|
|
|
|
s32 i;
|
2021-09-20 19:37:47 +00:00
|
|
|
s32 j;
|
|
|
|
s32 frontRoom;
|
|
|
|
s32 backRoom;
|
|
|
|
u32 frontRoomSize;
|
|
|
|
u32 backRoomSize;
|
|
|
|
u32 cumulRoomSize;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
for (i = 0; i < play->numRooms; i++) {
|
2020-03-17 04:31:30 +00:00
|
|
|
roomSize = roomList[i].vromEnd - roomList[i].vromStart;
|
|
|
|
osSyncPrintf("ROOM%d size=%d\n", i, roomSize);
|
2020-03-23 23:11:21 +00:00
|
|
|
if (maxRoomSize < roomSize) {
|
2020-03-17 04:31:30 +00:00
|
|
|
maxRoomSize = roomSize;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
if (play->transiActorCtx.numActors != 0) {
|
|
|
|
RomFile* roomList = play->roomList;
|
|
|
|
TransitionActorEntry* transitionActor = &play->transiActorCtx.list[0];
|
2020-07-15 15:23:57 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
LOG_NUM("game_play->room_rom_address.num", play->numRooms, "../z_room.c", 912);
|
2020-04-04 17:28:53 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
for (j = 0; j < play->transiActorCtx.numActors; j++) {
|
2021-09-20 19:37:47 +00:00
|
|
|
frontRoom = transitionActor->sides[0].room;
|
|
|
|
backRoom = transitionActor->sides[1].room;
|
|
|
|
frontRoomSize = (frontRoom < 0) ? 0 : roomList[frontRoom].vromEnd - roomList[frontRoom].vromStart;
|
|
|
|
backRoomSize = (backRoom < 0) ? 0 : roomList[backRoom].vromEnd - roomList[backRoom].vromStart;
|
|
|
|
cumulRoomSize = (frontRoom != backRoom) ? frontRoomSize + backRoomSize : frontRoomSize;
|
2020-07-15 15:23:57 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
osSyncPrintf("DOOR%d=<%d> ROOM1=<%d, %d> ROOM2=<%d, %d>\n", j, cumulRoomSize, frontRoom, frontRoomSize,
|
|
|
|
backRoom, backRoomSize);
|
2020-03-23 23:11:21 +00:00
|
|
|
if (maxRoomSize < cumulRoomSize) {
|
2020-03-17 04:31:30 +00:00
|
|
|
maxRoomSize = cumulRoomSize;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
transitionActor++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
osSyncPrintf(VT_FGCOL(YELLOW));
|
2021-09-04 13:33:19 +00:00
|
|
|
// "Room buffer size=%08x(%5.1fK)"
|
2021-03-31 16:18:31 +00:00
|
|
|
osSyncPrintf("部屋バッファサイズ=%08x(%5.1fK)\n", maxRoomSize, maxRoomSize / 1024.0f);
|
2022-05-21 18:23:43 +00:00
|
|
|
roomCtx->bufPtrs[0] = GameState_Alloc(&play->state, maxRoomSize, "../z_room.c", 946);
|
2021-09-04 13:33:19 +00:00
|
|
|
// "Room buffer initial pointer=%08x"
|
2020-03-17 04:31:30 +00:00
|
|
|
osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]);
|
|
|
|
roomCtx->bufPtrs[1] = (void*)((s32)roomCtx->bufPtrs[0] + maxRoomSize);
|
2021-09-04 13:33:19 +00:00
|
|
|
// "Room buffer end pointer=%08x"
|
2020-03-17 04:31:30 +00:00
|
|
|
osSyncPrintf("部屋バッファ終了ポインタ=%08x\n", roomCtx->bufPtrs[1]);
|
|
|
|
osSyncPrintf(VT_RST);
|
|
|
|
roomCtx->unk_30 = 0;
|
|
|
|
roomCtx->status = 0;
|
|
|
|
|
2021-09-20 19:37:47 +00:00
|
|
|
frontRoom = gSaveContext.respawnFlag > 0 ? ((void)0, gSaveContext.respawn[gSaveContext.respawnFlag - 1].roomIndex)
|
2022-05-21 18:23:43 +00:00
|
|
|
: play->setupEntranceList[play->curSpawn].room;
|
|
|
|
func_8009728C(play, roomCtx, frontRoom);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
return maxRoomSize;
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) {
|
2020-03-17 04:31:30 +00:00
|
|
|
u32 size;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (roomCtx->status == 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
roomCtx->prevRoom = roomCtx->curRoom;
|
|
|
|
roomCtx->curRoom.num = roomNum;
|
|
|
|
roomCtx->curRoom.segment = NULL;
|
|
|
|
roomCtx->status = 1;
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
ASSERT(roomNum < play->numRooms, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart;
|
EnWf OK and documented (#967)
* a ton of progress, 14 functions remain
* cleanup
* a few more functions done, 11 remain
* finally all updated
* another function matched
* another action finished
* damage table
* death action done
* started very large action func
* more progress on long action funcs
* large action func matched
* 5 functions remain
* another large action finished
* start another action, doesn't match yet
* a few new functions, neither match
* done working on this for now
* Correct one nonmatching, fix compiler warnings
* Two functions left
* one left
* remove remaining gotos
* OK
* Delete outdated comment
* namefixer
* Flag macros
* audio, dmgeff, some colour
* Import symbols from object, reloc, name a few things
* Rest of object done
* Named a few more things, add action enum
* Name body parts and another couple of actions
* Last few names
* Delete asm
* Format
* undefined_syms, mods where possible
* Correct parent to EnEncount1
* Review
* Last newline
* louis and Dragorn's reviews
* Format
* More review
* Put back to isInvisible and or, as in EnGeldB
* Remove if (0)s in func_8009728C and change pointer arithmetic cast
* More review
* Unname headRot, make "fallthrough" case clearer, other review
* Format
* Even more review
* Rephrase
Co-authored-by: Zelllll <56516451+Zelllll@users.noreply.github.com>
2021-09-24 22:35:42 +00:00
|
|
|
roomCtx->unk_34 = (void*)ALIGN16((u32)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7));
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1);
|
2022-05-21 18:23:43 +00:00
|
|
|
DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0,
|
2020-03-22 21:19:43 +00:00
|
|
|
&roomCtx->loadQueue, NULL, "../z_room.c", 1036);
|
2020-03-17 04:31:30 +00:00
|
|
|
roomCtx->unk_30 ^= 1;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
s32 func_800973FC(PlayState* play, RoomContext* roomCtx) {
|
2020-03-22 21:19:43 +00:00
|
|
|
if (roomCtx->status == 1) {
|
2022-04-09 00:20:23 +00:00
|
|
|
if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
roomCtx->status = 0;
|
|
|
|
roomCtx->curRoom.segment = roomCtx->unk_34;
|
2020-09-01 01:06:44 +00:00
|
|
|
gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
Scene_ExecuteCommands(play, roomCtx->curRoom.segment);
|
|
|
|
Player_SetBootData(play, GET_PLAYER(play));
|
|
|
|
Actor_SpawnTransitionActors(play, &play->actorCtx);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void Room_Draw(PlayState* play, Room* room, u32 flags) {
|
2020-03-22 21:19:43 +00:00
|
|
|
if (room->segment != NULL) {
|
2020-09-01 01:06:44 +00:00
|
|
|
gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment);
|
2022-05-21 12:54:51 +00:00
|
|
|
ASSERT(room->meshHeader->base.type < ARRAY_COUNTU(sRoomDrawHandlers),
|
2021-04-29 18:39:46 +00:00
|
|
|
"this->ground_shape->polygon.type < number(Room_Draw_Proc)", "../z_room.c", 1125);
|
2022-05-21 18:23:43 +00:00
|
|
|
sRoomDrawHandlers[room->meshHeader->base.type](play, room, flags);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void func_80097534(PlayState* play, RoomContext* roomCtx) {
|
2020-03-17 04:31:30 +00:00
|
|
|
roomCtx->prevRoom.num = -1;
|
|
|
|
roomCtx->prevRoom.segment = NULL;
|
2022-05-21 18:23:43 +00:00
|
|
|
func_80031B14(play, &play->actorCtx);
|
|
|
|
Actor_SpawnTransitionActors(play, &play->actorCtx);
|
|
|
|
Map_InitRoomData(play, roomCtx->curRoom.num);
|
|
|
|
if (!((play->sceneNum >= SCENE_SPOT00) && (play->sceneNum <= SCENE_SPOT20))) {
|
|
|
|
Map_SavePlayerInitialInfo(play);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2022-05-21 18:23:43 +00:00
|
|
|
Audio_SetEnvReverb(play->roomCtx.curRoom.echo);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|