1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-22 21:35:27 +00:00
oot/src/code/z_room.c

629 lines
22 KiB
C
Raw Normal View History

#include "global.h"
#include "vt.h"
2020-03-17 04:31:30 +00:00
void func_80095AB4(GlobalContext* globalCtx, Room* room, u32 flags);
void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags);
void func_80096F6C(GlobalContext* globalCtx, Room* room, u32 flags);
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),
gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
2020-03-17 04:31:30 +00:00
gsSPClipRatio(FRUSTRATIO_1),
gsSPEndDisplayList(),
};
2020-03-22 21:19:43 +00:00
void (*sRoomDrawHandlers[])(GlobalContext* globalCtx, Room* room, u32 flags) = {
2020-03-17 04:31:30 +00:00
func_80095AB4,
func_80096F6C,
func_80095D04,
};
void func_80095AA0(GlobalContext* globalCtx, Room* room, Input* arg2, UNK_TYPE arg3) {
2020-03-17 04:31:30 +00:00
}
// Room Draw Polygon Type 0
2020-03-22 21:19:43 +00:00
void func_80095AB4(GlobalContext* globalCtx, Room* room, u32 flags) {
2020-03-17 04:31:30 +00:00
s32 i;
PolygonType0* polygon0;
PolygonDlist* polygonDlist;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 193);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (flags & 1) {
2020-03-17 04:31:30 +00:00
func_800342EC(&D_801270A0, globalCtx);
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
func_80093C80(globalCtx);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
if (flags & 2) {
2020-03-17 04:31:30 +00:00
func_8003435C(&D_801270A0, globalCtx);
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
2020-03-17 04:31:30 +00:00
}
polygon0 = &room->mesh->polygon0;
polygonDlist = SEGMENTED_TO_VIRTUAL(polygon0->start);
2020-03-22 21:19:43 +00:00
for (i = 0; i < polygon0->num; i++) {
if ((flags & 1) && (polygonDlist->opa != NULL)) {
gSPDisplayList(POLY_OPA_DISP++, polygonDlist->opa);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if ((flags & 2) && (polygonDlist->xlu != NULL)) {
gSPDisplayList(POLY_XLU_DISP++, polygonDlist->xlu);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
polygonDlist++;
}
CLOSE_DISPS(globalCtx->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 {
2020-03-17 04:31:30 +00:00
/* 0x00 */ PolygonDlist2* 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
// Room Draw Polygon Type 2
#ifdef NON_MATCHING
// Saved register problems and ordering issues, but definitely equivalent.
2020-03-22 21:19:43 +00:00
void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) {
2020-03-17 04:31:30 +00:00
PolygonType2* polygon2;
PolygonDlist2* polygonDlist;
struct_80095D04 spB8[SHAPE_SORT_MAX];
struct_80095D04* spB4 = NULL;
struct_80095D04* spB0 = NULL;
2020-03-17 04:31:30 +00:00
struct_80095D04* phi_v0;
struct_80095D04* phi_a0;
struct_80095D04* spA4;
s32 phi_v1;
s32 sp9C;
Vec3f sp90;
Vec3f sp84;
f32 sp80;
PolygonDlist2* phi_s0;
PolygonDlist2* sp78;
PolygonDlist2* temp;
2020-03-17 04:31:30 +00:00
f32 temp_f2;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 287);
2020-03-22 21:19:43 +00:00
if (flags & 1) {
2020-03-17 04:31:30 +00:00
func_800342EC(&D_801270A0, globalCtx);
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
func_80093C80(globalCtx);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
2020-03-17 04:31:30 +00:00
}
if (1) {}
if (1) {}
2020-03-22 21:19:43 +00:00
if (flags & 2) {
2020-03-17 04:31:30 +00:00
func_8003435C(&D_801270A0, globalCtx);
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
2020-03-17 04:31:30 +00:00
}
polygon2 = &room->mesh->polygon2;
polygonDlist = SEGMENTED_TO_VIRTUAL(polygon2->start);
spA4 = spB8;
2020-03-23 23:11:21 +00:00
if (polygon2->num > SHAPE_SORT_MAX) {
2020-03-17 04:31:30 +00:00
__assert("polygon2->num <= SHAPE_SORT_MAX", "../z_room.c", 317);
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
sp78 = polygonDlist;
for (sp9C = 0; sp9C < polygon2->num; sp9C++, polygonDlist++) {
2020-03-17 04:31:30 +00:00
sp90.x = polygonDlist->pos.x;
sp90.y = polygonDlist->pos.y;
sp90.z = polygonDlist->pos.z;
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->mf_11D60, &sp90, &sp84, &sp80);
if (-(f32)polygonDlist->unk_06 < sp84.z) {
temp_f2 = sp84.z - polygonDlist->unk_06;
2020-03-22 21:19:43 +00:00
if (temp_f2 < globalCtx->lightCtx.unk_0C) {
phi_v0 = spB4;
2020-03-17 04:31:30 +00:00
spA4->unk_00 = polygonDlist;
spA4->unk_04 = temp_f2;
if (phi_v0 == NULL) {
spB4 = spB0 = spA4;
spA4->unk_08 = spA4->unk_0C = NULL;
2020-03-22 21:19:43 +00:00
} else {
do {
2020-03-23 23:11:21 +00:00
if (spA4->unk_04 < phi_v0->unk_04) {
2020-03-17 04:31:30 +00:00
break;
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
phi_v0 = phi_v0->unk_0C;
} while (phi_v0 != NULL);
2020-03-22 21:19:43 +00:00
if (phi_v0 == 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 {
spA4->unk_08 = phi_v0->unk_08;
if (spA4->unk_08 == NULL) {
2020-03-17 04:31:30 +00:00
spB4 = spA4;
2020-03-23 23:11:21 +00:00
} else {
spA4->unk_08->unk_0C = spA4;
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
phi_v0->unk_08 = spA4;
spA4->unk_0C = phi_v0;
2020-03-17 04:31:30 +00:00
}
}
spA4++;
2020-03-17 04:31:30 +00:00
}
}
}
iREG(87) = polygon2->num;
for (sp9C = 1; spB4 != NULL; spB4 = spB4->unk_0C, sp9C++) {
Gfx* temp2;
2020-03-17 04:31:30 +00:00
phi_s0 = spB4->unk_00;
2020-03-22 21:19:43 +00:00
if (iREG(86) != 0) {
temp = sp78;
for (phi_v1 = 0; phi_v1 < polygon2->num; phi_v1++, temp++) {
if (phi_s0 == temp) {
break; // This loop does nothing?
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
}
if (((iREG(86) == 1) && (iREG(89) >= sp9C)) || ((iREG(86) == 2) && (iREG(89) == sp9C))) {
if (flags & 1) {
temp2 = phi_s0->opa;
if (temp2 != NULL) {
gSPDisplayList(POLY_OPA_DISP++, temp2);
}
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
if (flags & 2) {
temp2 = phi_s0->xlu;
if (temp2 != NULL) {
gSPDisplayList(POLY_XLU_DISP++, temp2);
}
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 {
if (flags & 1) {
temp2 = phi_s0->opa;
if (temp2 != NULL) {
gSPDisplayList(POLY_OPA_DISP++, temp2);
}
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
if (flags & 2) {
temp2 = phi_s0->xlu;
if (temp2 != NULL) {
gSPDisplayList(POLY_XLU_DISP++, temp2);
}
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
}
}
iREG(88) = sp9C - 1;
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 430);
2020-03-17 04:31:30 +00:00
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_80095D04.s")
#endif
#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) {
2020-03-17 04:31:30 +00:00
// Translates to: "EXPANDING JPEG DATA"
osSyncPrintf("JPEGデータを展開します\n");
// Translates to: "JPEG DATA ADDRESS %08x"
osSyncPrintf("JPEGデータアドレス %08x\n", data);
// Translates to: "WORK BUFFER ADDRESS (Z BUFFER) %08x"
osSyncPrintf("ワークバッファアドレス(Zバッファ)%08x\n", gZBuffer);
time = osGetTime();
if (!Jpeg_Decode(data, (u16*)gZBuffer, (JpegWork*)gGfxSPTaskOutputBuffer, sizeof(gGfxSPTaskOutputBuffer))) {
time = osGetTime() - time;
2020-03-17 04:31:30 +00:00
// Translates to: "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);
2020-03-17 04:31:30 +00:00
// Translates to: "WRITING BACK TO ORIGINAL ADDRESS FROM WORK BUFFER."
osSyncPrintf("ワークバッファから元のアドレスに書き戻します。\n");
// Translates to: "IF THE ORIGINAL BUFFER SIZE ISN'T AT LEAST 150KB, IT WILL BE OUT OF CONTROL."
osSyncPrintf("元のバッファのサイズが150キロバイト無いと暴走するでしょう。\n");
bcopy(gZBuffer, data, sizeof(gZBuffer));
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
// Translates to: "FAILURE! WHY IS IT 〜"
osSyncPrintf("失敗!なんで〜\n");
}
}
return 0;
}
2020-03-22 21:19:43 +00:00
void func_8009638C(Gfx** displayList, u32 source, u32 tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 mode0,
u16 tlutCount, f32 frameX, f32 frameY) {
2020-03-17 04:31:30 +00:00
Gfx* displayListHead;
uObjBg* bg;
s32 temp;
2020-03-17 04:31:30 +00:00
displayListHead = *displayList;
func_80096238(SEGMENTED_TO_VIRTUAL(source));
bg = (uObjBg*)(displayListHead + 1);
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;
bg->b.imagePtr = (void*)source;
bg->b.imageLoad = G_BGLT_LOADTILE;
bg->b.imageFmt = fmt;
bg->b.imageSiz = siz;
bg->b.imagePal = 0;
bg->b.imageFlip = 0;
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;
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-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;
if (1) {}
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;
}
// Room Draw Polygon Type 1 - Single Format
2020-03-22 21:19:43 +00:00
void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) {
2020-03-17 04:31:30 +00:00
Camera* camera;
Gfx* spA8;
PolygonType1* polygon1;
PolygonDlist* polygonDlist;
u32 sp9C;
u32 sp98;
u32 sp94;
u32 sp90;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 628);
2020-03-17 04:31:30 +00:00
camera = ACTIVE_CAM;
sp9C = (camera->setting == CAM_SET_PREREND0);
2020-03-17 04:31:30 +00:00
polygon1 = &room->mesh->polygon1;
polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist);
sp98 = (flags & 1) && sp9C && polygon1->single.source && !(SREG(25) & 1);
sp94 = (flags & 1) && polygonDlist->opa && !(SREG(25) & 2);
sp90 = (flags & 2) && polygonDlist->xlu && !(SREG(25) & 4);
2020-03-22 21:19:43 +00:00
if (sp94 || sp98) {
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (sp94) {
2020-03-17 04:31:30 +00:00
func_80093D18(globalCtx->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, polygonDlist->opa);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
if (sp98) {
// gSPLoadUcodeL(POLY_OPA_DISP++, rspS2DEX)?
gSPLoadUcodeEx(POLY_OPA_DISP++, OS_K0_TO_PHYSICAL(D_80113070), OS_K0_TO_PHYSICAL(D_801579A0), 0x800);
2020-03-17 04:31:30 +00:00
{
2020-03-17 04:31:30 +00:00
Vec3f sp60;
spA8 = POLY_OPA_DISP;
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
Camera_GetSkyboxOffset(&sp60, camera);
2020-03-22 21:19:43 +00:00
func_8009638C(&spA8, polygon1->single.source, polygon1->single.tlut, polygon1->single.width,
polygon1->single.height, polygon1->single.fmt, polygon1->single.siz,
2020-03-17 04:31:30 +00:00
polygon1->single.mode0, polygon1->single.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);
POLY_OPA_DISP = spA8;
2020-03-17 04:31:30 +00:00
}
// gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData())?
gSPLoadUcodeEx(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData(), 0x800);
2020-03-17 04:31:30 +00:00
}
}
2020-03-22 21:19:43 +00:00
if (sp90) {
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, polygonDlist->xlu);
2020-03-17 04:31:30 +00:00
}
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 691);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) {
2020-03-17 04:31:30 +00:00
Camera* camera;
s32 camId;
s16 camId2;
Player* player;
BgImage* bgImage;
s32 i;
camera = ACTIVE_CAM;
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
camId = camera->camDataIdx;
// jfifid
z_bgcheck.c, 800430A0.c, 80043480.c (#256) * beginning of migrating changes * got matching * changed order a bit * clean up bgcheck * fix conflict * fix conflict again * first stab at identifying types, some oks * Clean up most bad structs/pointer math, move relevant structs to z64bgcheck.h, get some OKs * more OKs, z_bgcheck.bss migration, update some sys_math3d.c args * couple more OKs * pushing some OKs * fix compilation issues * code_800430A0.c OK, more files decomp'd * 8003A3E0 big OK :) * Decomp most of func_8003C614, decomp helper funcs * Decomp SurfaceType, CamData, and WaterBox property related functions * more OKs, big OK in 8003C078 * more OKs, more progress, move a function definition in z_collision_check to functions.h * more clean-ups, more OKs, dyn_vtx is now defined as u8* * 8003A5B8, 8003A7D8, 8003C614, 8003DD6C OK, document function args better * data migrated, more OKs * 80041240 OK, func_8003B3C8 and func_8003BB18 disassembled * func_80040284, 800409A8 non_matching, add IS_ZERO macro * All asm files have C representations, some big OKs, lots of minor tweaks * More OKs, non-matching code cleanup * 8003FBF4 and 80040BE4 OK, improve codegen for most functions * format z_bgcheck.c * fix warnings, compile errors on NON_MATCHING * func_8003EE80 is now NON_MATCHING * begin documenting some functions * formatting * more documentation, func_8003A95C OK * fix PHYSICAL_TO_VIRTUAL changes * fix var rename * More documentation, functions 80040E40, 80041648 OK, change types to not be compatible with ZAP * func_8004239C ok, more NON_MATCHING improvements, more documentation * Implement most suggested changes * Convert comments to slower comments * /** * Implement ZAP2 changes * my anti-virus ate my format.sh results * Rename a couple hundred functions, fix minor stuff * rename var so that clang formats correctly * run format.sh * implement Petrie's matches/suggestions * format * matches * and the asm * slight error * Add SSList * two more matches * stuff * implement code changes * clean up Petrie's matchings Co-authored-by: Arthur <arthurtilly413@gmail.com> Co-authored-by: fig02 <fig02srl@gmail.com> Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
2021-01-08 11:12:58 +00:00
camId2 = func_80041C10(&globalCtx->colCtx, camId, BGCHECK_SCENE)[2].y;
2020-03-22 21:19:43 +00:00
if (camId2 >= 0) {
2020-03-17 04:31:30 +00:00
camId = camId2;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
player = PLAYER;
player->actor.params = (player->actor.params & 0xFF00) | camId;
bgImage = SEGMENTED_TO_VIRTUAL(polygon1->multi.list);
2020-03-22 21:19:43 +00:00
for (i = 0; i < polygon1->multi.count; i++) {
if (bgImage->id == camId) {
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++;
}
// Translates to: "z_room.c: DATA CONSISTENT WITH CAMERA ID DOES NOT EXIST camid=%d"
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, camId);
LogUtils_HungupThread("../z_room.c", 726);
return NULL;
}
// Room Draw Polygon Type 1 - Multi Format
2020-03-22 21:19:43 +00:00
void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) {
2020-03-17 04:31:30 +00:00
Camera* camera;
Gfx* spA8;
PolygonType1* polygon1;
BgImage* bgImage;
2020-03-17 04:31:30 +00:00
PolygonDlist* polygonDlist;
u32 sp98;
u32 sp94;
u32 sp90;
u32 sp8C;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 752);
2020-03-17 04:31:30 +00:00
camera = ACTIVE_CAM;
sp98 = (camera->setting == CAM_SET_PREREND0);
2020-03-17 04:31:30 +00:00
polygon1 = &room->mesh->polygon1;
polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist);
bgImage = func_80096A74(polygon1, globalCtx);
sp94 = (flags & 1) && sp98 && bgImage->source && !(SREG(25) & 1);
sp90 = (flags & 1) && polygonDlist->opa && !(SREG(25) & 2);
sp8C = (flags & 2) && polygonDlist->xlu && !(SREG(25) & 4);
2020-03-22 21:19:43 +00:00
if (sp90 || sp94) {
gSPSegment(POLY_OPA_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (sp90) {
2020-03-17 04:31:30 +00:00
func_80093D18(globalCtx->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, polygonDlist->opa);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
if (sp94) {
// gSPLoadUcodeL(POLY_OPA_DISP++, rspS2DEX)?
gSPLoadUcodeEx(POLY_OPA_DISP++, OS_K0_TO_PHYSICAL(D_80113070), OS_K0_TO_PHYSICAL(D_801579A0), 0x800);
2020-03-17 04:31:30 +00:00
{
2020-03-17 04:31:30 +00:00
Vec3f sp5C;
spA8 = POLY_OPA_DISP;
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
Camera_GetSkyboxOffset(&sp5C, camera);
2020-03-22 21:19:43 +00:00
func_8009638C(&spA8, bgImage->source, bgImage->tlut, bgImage->width, bgImage->height, bgImage->fmt,
bgImage->siz, bgImage->mode0, bgImage->tlutCount,
(sp5C.x + sp5C.z) * 1.2f + sp5C.y * 0.6f, sp5C.y * 2.4f + (sp5C.x + sp5C.z) * 0.3f);
POLY_OPA_DISP = spA8;
2020-03-17 04:31:30 +00:00
}
// gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData())?
gSPLoadUcodeEx(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData(), 0x800);
2020-03-17 04:31:30 +00:00
}
}
2020-03-22 21:19:43 +00:00
if (sp8C) {
gSPSegment(POLY_XLU_DISP++, 0x03, room->segment);
2020-03-17 04:31:30 +00:00
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, polygonDlist->xlu);
2020-03-17 04:31:30 +00:00
}
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 819);
2020-03-17 04:31:30 +00:00
}
// Room Draw Polygon Type 1
2020-03-22 21:19:43 +00:00
void func_80096F6C(GlobalContext* globalCtx, Room* room, u32 flags) {
2020-03-17 04:31:30 +00:00
PolygonType1* polygon1 = &room->mesh->polygon1;
2020-03-22 21:19:43 +00:00
if (polygon1->format == 1) {
2020-03-17 04:31:30 +00:00
func_80096680(globalCtx, room, flags);
2020-03-22 21:19:43 +00:00
} else if (polygon1->format == 2) {
2020-03-17 04:31:30 +00:00
func_80096B6C(globalCtx, 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
}
2020-03-22 21:19:43 +00:00
void func_80096FD4(GlobalContext* globalCtx, Room* room) {
2020-03-17 04:31:30 +00:00
room->num = -1;
room->segment = NULL;
}
#ifdef NON_MATCHING
// regalloc differences near the end
2020-03-22 21:19:43 +00:00
u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) {
2020-03-17 04:31:30 +00:00
u8 nextRoomNum;
u32 maxRoomSize = 0;
RomFile* roomList = globalCtx->roomList;
u32 roomSize;
s32 i;
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
for (i = 0; i < globalCtx->nbRooms; 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
}
2020-03-22 21:19:43 +00:00
if (globalCtx->nbTransitionActors != 0) {
s32 j;
RomFile* roomList = globalCtx->roomList;
TransitionActorEntry* transitionActor = &globalCtx->transitionActorList[0];
LOG_NUM("game_play->room_rom_address.num", globalCtx->nbRooms, "../z_room.c", 912);
2020-03-22 21:19:43 +00:00
for (j = 0; j < globalCtx->nbTransitionActors; j++) {
s8 frontRoom = transitionActor->sides[0].room;
s8 backRoom = transitionActor->sides[1].room;
u32 frontRoomSize = (frontRoom < 0) ? 0 : roomList[frontRoom].vromEnd - roomList[frontRoom].vromStart;
u32 backRoomSize = (backRoom < 0) ? 0 : roomList[backRoom].vromEnd - roomList[backRoom].vromStart;
u32 cumulRoomSize = (frontRoom != backRoom) ? frontRoomSize + backRoomSize : frontRoomSize;
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));
// Translates to: "ROOM BUFFER SIZE=%08x(%5.1fK)"
osSyncPrintf("部屋バッファサイズ=%08x(%5.1fK)\n", maxRoomSize, maxRoomSize / 1024.0f);
roomCtx->bufPtrs[0] = GameState_Alloc(&globalCtx->state, maxRoomSize, "../z_room.c", 946);
2020-03-17 04:31:30 +00:00
// Translates to: "ROOM BUFFER INITIAL POINTER=%08x"
osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]);
roomCtx->bufPtrs[1] = (void*)((s32)roomCtx->bufPtrs[0] + maxRoomSize);
// Translates to: "ROOM BUFFER END POINTER=%08x"
osSyncPrintf("部屋バッファ終了ポインタ=%08x\n", roomCtx->bufPtrs[1]);
osSyncPrintf(VT_RST);
roomCtx->unk_30 = 0;
roomCtx->status = 0;
nextRoomNum = (gSaveContext.respawnFlag - 1 >= 0) ? gSaveContext.respawn[gSaveContext.respawnFlag - 1].roomIndex
: globalCtx->setupEntranceList[globalCtx->curSpawn].room;
2020-03-17 04:31:30 +00:00
func_8009728C(globalCtx, roomCtx, nextRoomNum);
return maxRoomSize;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_80096FE8.s")
#endif
2020-03-22 21:19:43 +00:00
s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) {
2020-03-17 04:31:30 +00:00
u32 size;
2020-03-22 21:19:43 +00:00
if (0) {} // Necessary to match
2020-03-17 04:31:30 +00:00
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;
2020-03-22 21:19:43 +00:00
if (roomNum >= globalCtx->nbRooms) {
2020-03-17 04:31:30 +00:00
__assert("read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
size = globalCtx->roomList[roomNum].vromEnd - globalCtx->roomList[roomNum].vromStart;
roomCtx->unk_34 = (void*)ALIGN16((s32)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7));
2020-03-22 21:19:43 +00:00
if (0) {} // Also necessary to match
2020-03-17 04:31:30 +00:00
osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1);
2020-03-22 21:19:43 +00:00
DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, globalCtx->roomList[roomNum].vromStart, size, 0,
&roomCtx->loadQueue, NULL, "../z_room.c", 1036);
2020-03-17 04:31:30 +00:00
roomCtx->unk_30 ^= 1;
return 1;
}
return 0;
}
2020-03-22 21:19:43 +00:00
s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) {
if (roomCtx->status == 1) {
if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) {
2020-03-17 04:31:30 +00:00
roomCtx->status = 0;
roomCtx->curRoom.segment = roomCtx->unk_34;
gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34);
2020-03-17 04:31:30 +00:00
Scene_ExecuteCommands(globalCtx, roomCtx->curRoom.segment);
Player_SetBootData(globalCtx, PLAYER);
2020-03-17 04:31:30 +00:00
Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx);
return 1;
}
return 0;
}
return 1;
}
2020-03-22 21:19:43 +00:00
void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) {
if (room->segment != NULL) {
gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment);
2020-03-22 21:19:43 +00:00
if (room->mesh->polygon.type >= ARRAY_COUNTU(sRoomDrawHandlers)) {
2020-03-17 04:31:30 +00:00
__assert("this->ground_shape->polygon.type < number(Room_Draw_Proc)", "../z_room.c", 1125);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
sRoomDrawHandlers[room->mesh->polygon.type](globalCtx, room, flags);
}
}
2020-03-22 21:19:43 +00:00
void func_80097534(GlobalContext* globalCtx, RoomContext* roomCtx) {
2020-03-17 04:31:30 +00:00
roomCtx->prevRoom.num = -1;
roomCtx->prevRoom.segment = NULL;
func_80031B14(globalCtx, &globalCtx->actorCtx);
Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx);
Map_InitRoomData(globalCtx, roomCtx->curRoom.num);
2020-03-22 21:19:43 +00:00
if (!((globalCtx->sceneNum >= SCENE_SPOT00) && (globalCtx->sceneNum <= SCENE_SPOT20))) {
Map_SavePlayerInitialInfo(globalCtx);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
func_800F66C0(globalCtx->roomCtx.curRoom.echo);
}