2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2022-11-01 23:17:11 +00:00
|
|
|
#include "terminal.h"
|
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-08-31 23:28:51 +00:00
|
|
|
void Room_DrawNormal(PlayState* play, Room* room, u32 flags);
|
|
|
|
void Room_DrawImage(PlayState* play, Room* room, u32 flags);
|
|
|
|
void Room_DrawCullable(PlayState* play, Room* room, u32 flags);
|
|
|
|
|
|
|
|
void (*sRoomDrawHandlers[ROOM_SHAPE_TYPE_MAX])(PlayState* play, Room* room, u32 flags) = {
|
|
|
|
Room_DrawNormal, // ROOM_SHAPE_TYPE_NORMAL
|
|
|
|
Room_DrawImage, // ROOM_SHAPE_TYPE_IMAGE
|
|
|
|
Room_DrawCullable, // ROOM_SHAPE_TYPE_CULLABLE
|
2020-03-17 04:31:30 +00:00
|
|
|
};
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
void func_80095AA0(PlayState* play, Room* room, Input* input, s32 arg3) {
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
void Room_DrawNormal(PlayState* play, Room* room, u32 flags) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 i;
|
2022-08-31 23:28:51 +00:00
|
|
|
RoomShapeNormal* roomShape;
|
|
|
|
RoomShapeDListsEntry* entry;
|
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-08-31 23:28:51 +00:00
|
|
|
roomShape = &room->roomShape->normal;
|
|
|
|
entry = SEGMENTED_TO_VIRTUAL(roomShape->entries);
|
|
|
|
for (i = 0; i < roomShape->numEntries; i++) {
|
|
|
|
if ((flags & ROOM_DRAW_OPA) && (entry->opa != NULL)) {
|
|
|
|
gSPDisplayList(POLY_OPA_DISP++, entry->opa);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
if ((flags & ROOM_DRAW_XLU) && (entry->xlu != NULL)) {
|
|
|
|
gSPDisplayList(POLY_XLU_DISP++, entry->xlu);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
entry++;
|
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
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
typedef enum {
|
|
|
|
/* 0 */ ROOM_CULL_DEBUG_MODE_OFF,
|
|
|
|
/* 1 */ ROOM_CULL_DEBUG_MODE_UP_TO_TARGET,
|
|
|
|
/* 2 */ ROOM_CULL_DEBUG_MODE_ONLY_TARGET
|
|
|
|
} RoomCullableDebugMode;
|
|
|
|
|
|
|
|
typedef struct RoomShapeCullableEntryLinked {
|
|
|
|
/* 0x00 */ RoomShapeCullableEntry* entry;
|
|
|
|
/* 0x04 */ f32 boundsNearZ;
|
|
|
|
/* 0x08 */ struct RoomShapeCullableEntryLinked* prev;
|
|
|
|
/* 0x0C */ struct RoomShapeCullableEntryLinked* next;
|
|
|
|
} RoomShapeCullableEntryLinked; // size = 0x10
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle room drawing for the "cullable" type of room shape.
|
|
|
|
*
|
|
|
|
* Each entry referenced by the room shape struct is attached to display lists, and a position and radius indicating the
|
|
|
|
* bounding sphere for the geometry drawn.
|
|
|
|
* The first step Z-sorts the entries, and excludes the entries with a bounding sphere that is entirely before or
|
|
|
|
* beyond the rendered depth range.
|
|
|
|
* The second step draws the entries that remain, from nearest to furthest.
|
|
|
|
*/
|
|
|
|
void Room_DrawCullable(PlayState* play, Room* room, u32 flags) {
|
|
|
|
RoomShapeCullable* roomShape;
|
|
|
|
RoomShapeCullableEntry* roomShapeCullableEntry;
|
|
|
|
RoomShapeCullableEntryLinked linkedEntriesBuffer[ROOM_SHAPE_CULLABLE_MAX_ENTRIES];
|
|
|
|
RoomShapeCullableEntryLinked* head = NULL;
|
|
|
|
RoomShapeCullableEntryLinked* tail = NULL;
|
|
|
|
RoomShapeCullableEntryLinked* iter;
|
2021-09-20 19:37:47 +00:00
|
|
|
s32 pad;
|
2022-08-31 23:28:51 +00:00
|
|
|
RoomShapeCullableEntryLinked* insert;
|
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-08-31 23:28:51 +00:00
|
|
|
RoomShapeCullableEntry* roomShapeCullableEntries;
|
|
|
|
RoomShapeCullableEntry* roomShapeCullableEntryIter;
|
|
|
|
f32 entryBoundsNearZ;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287);
|
2022-08-31 23:28:51 +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-08-31 23:28:51 +00:00
|
|
|
|
2020-12-19 03:09:38 +00:00
|
|
|
if (1) {}
|
2022-08-31 23:28:51 +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-08-31 23:28:51 +00:00
|
|
|
roomShape = &room->roomShape->cullable;
|
|
|
|
roomShapeCullableEntry = SEGMENTED_TO_VIRTUAL(roomShape->entries);
|
|
|
|
insert = linkedEntriesBuffer;
|
|
|
|
|
|
|
|
ASSERT(roomShape->numEntries <= ROOM_SHAPE_CULLABLE_MAX_ENTRIES, "polygon2->num <= SHAPE_SORT_MAX", "../z_room.c",
|
|
|
|
317);
|
|
|
|
|
|
|
|
roomShapeCullableEntries = roomShapeCullableEntry;
|
2020-12-19 03:09:38 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
// Pick and sort entries by depth
|
|
|
|
for (i = 0; i < roomShape->numEntries; i++, roomShapeCullableEntry++) {
|
2022-02-27 21:32:05 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
// Project the entry position, to get the depth it is at.
|
|
|
|
pos.x = roomShapeCullableEntry->boundsSphereCenter.x;
|
|
|
|
pos.y = roomShapeCullableEntry->boundsSphereCenter.y;
|
|
|
|
pos.z = roomShapeCullableEntry->boundsSphereCenter.z;
|
2022-05-21 18:23:43 +00:00
|
|
|
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW);
|
2022-08-31 23:28:51 +00:00
|
|
|
|
|
|
|
// If the entry bounding sphere isn't fully before the rendered depth range
|
|
|
|
if (-(f32)roomShapeCullableEntry->boundsSphereRadius < projectedPos.z) {
|
|
|
|
|
|
|
|
// Compute the depth of the nearest point in the entry's bounding sphere
|
|
|
|
entryBoundsNearZ = projectedPos.z - roomShapeCullableEntry->boundsSphereRadius;
|
|
|
|
|
|
|
|
// If the entry bounding sphere isn't fully beyond the rendered depth range
|
2022-11-01 23:00:38 +00:00
|
|
|
if (entryBoundsNearZ < play->lightCtx.zFar) {
|
2022-08-31 23:28:51 +00:00
|
|
|
|
|
|
|
// This entry will be rendered
|
|
|
|
insert->entry = roomShapeCullableEntry;
|
|
|
|
insert->boundsNearZ = entryBoundsNearZ;
|
|
|
|
|
|
|
|
// Insert into the linked list, ordered by ascending depth of the nearest point in the bounding sphere
|
|
|
|
iter = head;
|
2022-02-27 21:32:05 +00:00
|
|
|
if (iter == NULL) {
|
2022-08-31 23:28:51 +00:00
|
|
|
head = tail = insert;
|
|
|
|
insert->prev = insert->next = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
|
|
|
do {
|
2022-08-31 23:28:51 +00:00
|
|
|
if (insert->boundsNearZ < iter->boundsNearZ) {
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2022-08-31 23:28:51 +00:00
|
|
|
iter = iter->next;
|
2022-02-27 21:32:05 +00:00
|
|
|
} while (iter != NULL);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-02-27 21:32:05 +00:00
|
|
|
if (iter == NULL) {
|
2022-08-31 23:28:51 +00:00
|
|
|
insert->prev = tail;
|
|
|
|
insert->next = NULL;
|
|
|
|
tail->next = insert;
|
|
|
|
tail = insert;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2022-08-31 23:28:51 +00:00
|
|
|
insert->prev = iter->prev;
|
|
|
|
if (insert->prev == NULL) {
|
|
|
|
head = insert;
|
2020-03-23 23:11:21 +00:00
|
|
|
} else {
|
2022-08-31 23:28:51 +00:00
|
|
|
insert->prev->next = insert;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2022-08-31 23:28:51 +00:00
|
|
|
iter->prev = insert;
|
|
|
|
insert->next = iter;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-31 23:28:51 +00:00
|
|
|
|
|
|
|
insert++;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
// if this is real then I might not be
|
|
|
|
R_ROOM_CULL_NUM_ENTRIES = roomShape->numEntries & 0xFFFF & 0xFFFF & 0xFFFF;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
// Draw entries, from nearest to furthest
|
|
|
|
for (i = 1; head != NULL; head = head->next, i++) {
|
2022-02-27 21:32:05 +00:00
|
|
|
Gfx* displayList;
|
2020-12-19 03:09:38 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
roomShapeCullableEntry = head->entry;
|
|
|
|
|
|
|
|
if (R_ROOM_CULL_DEBUG_MODE != ROOM_CULL_DEBUG_MODE_OFF) {
|
|
|
|
// Debug mode drawing
|
|
|
|
|
|
|
|
// This loop does nothing
|
|
|
|
roomShapeCullableEntryIter = roomShapeCullableEntries;
|
|
|
|
for (j = 0; j < roomShape->numEntries; j++, roomShapeCullableEntryIter++) {
|
|
|
|
if (roomShapeCullableEntry == roomShapeCullableEntryIter) {
|
|
|
|
break;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
if (((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_UP_TO_TARGET) && (i <= R_ROOM_CULL_DEBUG_TARGET)) ||
|
|
|
|
((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_ONLY_TARGET) && (i == R_ROOM_CULL_DEBUG_TARGET))) {
|
2022-06-09 19:02:18 +00:00
|
|
|
if (flags & ROOM_DRAW_OPA) {
|
2022-08-31 23:28:51 +00:00
|
|
|
displayList = roomShapeCullableEntry->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) {
|
2022-08-31 23:28:51 +00:00
|
|
|
displayList = roomShapeCullableEntry->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) {
|
2022-08-31 23:28:51 +00:00
|
|
|
displayList = roomShapeCullableEntry->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) {
|
2022-08-31 23:28:51 +00:00
|
|
|
displayList = roomShapeCullableEntry->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-08-31 23:28:51 +00:00
|
|
|
R_ROOM_CULL_USED_ENTRIES = 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
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
/**
|
|
|
|
* If the data is JPEG, decode it and overwrite the initial data with the result.
|
|
|
|
* Uses the depth frame buffer as temporary storage.
|
|
|
|
*/
|
|
|
|
s32 Room_DecodeJpeg(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");
|
2022-08-31 23:28:51 +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");
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
bcopy(gZBuffer, data, sizeof(u16[SCREEN_HEIGHT][SCREEN_WIDTH]));
|
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;
|
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tlutMode,
|
|
|
|
u16 tlutCount, f32 offsetX, f32 offsetY) {
|
|
|
|
Gfx* gfx = *gfxP;
|
2020-03-17 04:31:30 +00:00
|
|
|
uObjBg* bg;
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
Room_DecodeJpeg(SEGMENTED_TO_VIRTUAL(tex));
|
|
|
|
|
|
|
|
bg = (uObjBg*)(gfx + 1);
|
|
|
|
gSPBranchList(gfx, (u32)bg + sizeof(uObjBg));
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
bg->b.imageX = 0;
|
2022-08-31 23:28:51 +00:00
|
|
|
bg->b.imageW = width * (1 << 2);
|
|
|
|
bg->b.frameX = offsetX * (1 << 2);
|
2020-03-17 04:31:30 +00:00
|
|
|
bg->b.imageY = 0;
|
2022-08-31 23:28:51 +00:00
|
|
|
bg->b.imageH = height * (1 << 2);
|
|
|
|
bg->b.frameY = offsetY * (1 << 2);
|
|
|
|
bg->b.imagePtr = tex;
|
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;
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
gfx = (Gfx*)((u32)bg + sizeof(uObjBg));
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (fmt == G_IM_FMT_CI) {
|
2022-08-31 23:28:51 +00:00
|
|
|
gDPLoadTLUT(gfx++, tlutCount, 256, tlut);
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2022-08-31 23:28:51 +00:00
|
|
|
gDPPipeSync(gfx++);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
if ((fmt == G_IM_FMT_RGBA) && !R_ROOM_BG2D_FORCE_SCALEBG) {
|
|
|
|
bg->b.frameW = width * (1 << 2);
|
|
|
|
bg->b.frameH = height * (1 << 2);
|
2020-05-25 21:18:14 +00:00
|
|
|
guS2DInitBg(bg);
|
2022-08-31 23:28:51 +00:00
|
|
|
gDPSetOtherMode(gfx++, tlutMode | 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);
|
2022-08-31 23:28:51 +00:00
|
|
|
gSPBgRectCopy(gfx++, bg);
|
2020-12-19 03:09:38 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2022-08-31 23:28:51 +00:00
|
|
|
bg->s.frameW = width * (1 << 2);
|
|
|
|
bg->s.frameH = height * (1 << 2);
|
|
|
|
bg->s.scaleW = 1 << 10;
|
|
|
|
bg->s.scaleH = 1 << 10;
|
2020-03-17 04:31:30 +00:00
|
|
|
bg->s.imageYorig = bg->b.imageY;
|
2022-08-31 23:28:51 +00:00
|
|
|
gDPSetOtherMode(gfx++,
|
|
|
|
tlutMode | G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | 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));
|
2022-08-31 23:28:51 +00:00
|
|
|
gDPSetCombineLERP(gfx++, 0, 0, 0, TEXEL0, 0, 0, 0, 1, 0, 0, 0, TEXEL0, 0, 0, 0, 1);
|
|
|
|
gSPObjRenderMode(gfx++, G_OBJRM_ANTIALIAS | G_OBJRM_BILERP);
|
|
|
|
gSPBgRect1Cyc(gfx++, bg);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
gDPPipeSync(gfx++);
|
|
|
|
|
|
|
|
*gfxP = gfx;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
#define ROOM_IMAGE_NODRAW_BACKGROUND (1 << 0)
|
|
|
|
#define ROOM_IMAGE_NODRAW_OPA (1 << 1)
|
|
|
|
#define ROOM_IMAGE_NODRAW_XLU (1 << 2)
|
|
|
|
|
|
|
|
void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) {
|
2022-05-12 18:35:31 +00:00
|
|
|
Camera* activeCam;
|
2022-08-31 23:28:51 +00:00
|
|
|
Gfx* gfx;
|
|
|
|
RoomShapeImageSingle* roomShape;
|
|
|
|
RoomShapeDListsEntry* entry;
|
2022-02-27 21:32:05 +00:00
|
|
|
u32 isFixedCamera;
|
2022-08-31 23:28:51 +00:00
|
|
|
u32 drawBackground;
|
2022-02-27 21:32:05 +00:00
|
|
|
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-08-31 23:28:51 +00:00
|
|
|
roomShape = &room->roomShape->image.single;
|
|
|
|
entry = SEGMENTED_TO_VIRTUAL(roomShape->base.entry);
|
|
|
|
drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (roomShape->source != NULL) &&
|
|
|
|
!(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND);
|
|
|
|
drawOpa = (flags & ROOM_DRAW_OPA) && (entry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA);
|
|
|
|
drawXlu = (flags & ROOM_DRAW_XLU) && (entry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU);
|
|
|
|
|
|
|
|
if (drawOpa || drawBackground) {
|
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-08-31 23:28:51 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, entry->opa);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
if (drawBackground) {
|
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-08-31 23:28:51 +00:00
|
|
|
Vec3f quakeOffset;
|
|
|
|
|
|
|
|
gfx = POLY_OPA_DISP;
|
2022-10-15 06:16:37 +00:00
|
|
|
Camera_GetQuakeOffset(&quakeOffset, activeCam);
|
2022-08-31 23:28:51 +00:00
|
|
|
Room_DrawBackground2D(&gfx, roomShape->source, roomShape->tlut, roomShape->width, roomShape->height,
|
|
|
|
roomShape->fmt, roomShape->siz, roomShape->tlutMode, roomShape->tlutCount,
|
|
|
|
(quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f,
|
|
|
|
quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.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-08-31 23:28:51 +00:00
|
|
|
gSPDisplayList(POLY_XLU_DISP++, entry->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-08-31 23:28:51 +00:00
|
|
|
RoomShapeImageMultiBgEntry* Room_GetImageMultiBgEntry(RoomShapeImageMulti* roomShapeImageMulti, PlayState* play) {
|
2022-05-21 18:23:43 +00:00
|
|
|
Camera* activeCam = GET_ACTIVE_CAM(play);
|
2022-06-17 18:25:42 +00:00
|
|
|
s32 bgCamIndex = activeCam->bgCamIndex;
|
2022-08-31 23:28:51 +00:00
|
|
|
s16 overrideBgCamIndex;
|
2020-03-17 04:31:30 +00:00
|
|
|
Player* player;
|
2022-08-31 23:28:51 +00:00
|
|
|
RoomShapeImageMultiBgEntry* bgEntry;
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 i;
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
// In mq debug vanilla scenes, overrideBgCamIndex is always -1 or the same as bgCamIndex
|
|
|
|
overrideBgCamIndex = ((BgCamFuncData*)BgCheck_GetBgCamFuncDataImpl(&play->colCtx, bgCamIndex, BGCHECK_SCENE))
|
|
|
|
->roomImageOverrideBgCamIndex;
|
|
|
|
if (overrideBgCamIndex >= 0) {
|
|
|
|
bgCamIndex = overrideBgCamIndex;
|
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-06-17 18:25:42 +00:00
|
|
|
player->actor.params = (player->actor.params & 0xFF00) | bgCamIndex;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
bgEntry = SEGMENTED_TO_VIRTUAL(roomShapeImageMulti->backgrounds);
|
|
|
|
for (i = 0; i < roomShapeImageMulti->numBackgrounds; i++) {
|
|
|
|
if (bgEntry->bgCamIndex == bgCamIndex) {
|
|
|
|
return bgEntry;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2022-08-31 23:28:51 +00:00
|
|
|
bgEntry++;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 13:33:19 +00:00
|
|
|
// "z_room.c: Data consistent with camera id does not exist camid=%d"
|
2022-06-17 18:25:42 +00:00
|
|
|
osSyncPrintf(VT_COL(RED, WHITE) "z_room.c:カメラIDに一致するデータが存在しません camid=%d\n" VT_RST, bgCamIndex);
|
2020-03-17 04:31:30 +00:00
|
|
|
LogUtils_HungupThread("../z_room.c", 726);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
void Room_DrawImageMulti(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-08-31 23:28:51 +00:00
|
|
|
RoomShapeImageMulti* roomShape;
|
|
|
|
RoomShapeImageMultiBgEntry* bgEntry;
|
|
|
|
RoomShapeDListsEntry* dListsEntry;
|
2022-02-27 21:32:05 +00:00
|
|
|
u32 isFixedCamera;
|
2022-08-31 23:28:51 +00:00
|
|
|
u32 drawBackground;
|
2022-02-27 21:32:05 +00:00
|
|
|
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-08-31 23:28:51 +00:00
|
|
|
roomShape = &room->roomShape->image.multi;
|
|
|
|
dListsEntry = SEGMENTED_TO_VIRTUAL(roomShape->base.entry);
|
|
|
|
|
|
|
|
bgEntry = Room_GetImageMultiBgEntry(roomShape, play);
|
|
|
|
|
|
|
|
drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (bgEntry->source != NULL) &&
|
|
|
|
!(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND);
|
|
|
|
drawOpa =
|
|
|
|
(flags & ROOM_DRAW_OPA) && (dListsEntry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA);
|
|
|
|
drawXlu =
|
|
|
|
(flags & ROOM_DRAW_XLU) && (dListsEntry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU);
|
|
|
|
|
|
|
|
if (drawOpa || drawBackground) {
|
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-08-31 23:28:51 +00:00
|
|
|
gSPDisplayList(POLY_OPA_DISP++, dListsEntry->opa);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
if (drawBackground) {
|
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-08-31 23:28:51 +00:00
|
|
|
Vec3f quakeOffset;
|
2022-02-27 21:32:05 +00:00
|
|
|
|
|
|
|
gfx = POLY_OPA_DISP;
|
2022-10-15 06:16:37 +00:00
|
|
|
Camera_GetQuakeOffset(&quakeOffset, activeCam);
|
2022-08-31 23:28:51 +00:00
|
|
|
Room_DrawBackground2D(&gfx, bgEntry->source, bgEntry->tlut, bgEntry->width, bgEntry->height,
|
|
|
|
bgEntry->fmt, bgEntry->siz, bgEntry->tlutMode, bgEntry->tlutCount,
|
|
|
|
(quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f,
|
|
|
|
quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.z) * 0.3f);
|
2022-02-27 21:32:05 +00:00
|
|
|
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-08-31 23:28:51 +00:00
|
|
|
gSPDisplayList(POLY_XLU_DISP++, dListsEntry->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-08-31 23:28:51 +00:00
|
|
|
void Room_DrawImage(PlayState* play, Room* room, u32 flags) {
|
|
|
|
RoomShapeImageBase* roomShape = &room->roomShape->image.base;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-08-31 23:28:51 +00:00
|
|
|
if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_SINGLE) {
|
|
|
|
Room_DrawImageSingle(play, room, flags);
|
|
|
|
} else if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_MULTI) {
|
|
|
|
Room_DrawImageMulti(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-10-16 22:00:18 +00:00
|
|
|
: play->spawnList[play->spawn].room;
|
2022-05-21 18:23:43 +00:00
|
|
|
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-11-17 02:57:02 +00:00
|
|
|
DmaMgr_RequestAsync(&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-08-31 23:28:51 +00:00
|
|
|
ASSERT(room->roomShape->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-08-31 23:28:51 +00:00
|
|
|
sRoomDrawHandlers[room->roomShape->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);
|
2022-11-26 21:15:41 +00:00
|
|
|
if (!((play->sceneId >= SCENE_HYRULE_FIELD) && (play->sceneId <= SCENE_LON_LON_RANCH))) {
|
2022-05-21 18:23:43 +00:00
|
|
|
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
|
|
|
}
|