diff --git a/include/functions.h b/include/functions.h index 5810b3edb8..27cbbfd803 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1044,12 +1044,12 @@ void func_80095974(GraphicsContext* gfxCtx); void func_80095AA0(PlayState* play, Room* room, Input* input, s32 arg3); 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); -void func_80096FD4(PlayState* play, Room* room); -u32 func_80096FE8(PlayState* play, RoomContext* roomCtx); -s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum); -s32 func_800973FC(PlayState* play, RoomContext* roomCtx); +void Room_Init(PlayState* play, Room* room); +u32 Room_SetupFirstRoom(PlayState* play, RoomContext* roomCtx); +s32 Room_RequestNewRoom(PlayState* play, RoomContext* roomCtx, s32 roomNum); +s32 Room_ProcessRoomRequest(PlayState* play, RoomContext* roomCtx); void Room_Draw(PlayState* play, Room* room, u32 flags); -void func_80097534(PlayState* play, RoomContext* roomCtx); +void Room_FinishRoomChange(PlayState* play, RoomContext* roomCtx); void Sample_Destroy(GameState* thisx); void Sample_Init(GameState* thisx); void Inventory_ChangeEquipment(s16 equipment, u16 value); @@ -1061,7 +1061,7 @@ s32 Object_GetSlot(ObjectContext* objectCtx, s16 objectId); s32 Object_IsLoaded(ObjectContext* objectCtx, s32 slot); void func_800981B8(ObjectContext* objectCtx); s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd); -void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx); +void Scene_ResetTransitionActorList(GameState* state, TransitionActorList* transitionActors); void Scene_SetTransitionForNextEntrance(PlayState* play); void Scene_Draw(PlayState* play); diff --git a/include/z64play.h b/include/z64play.h index bfea008834..432ecc2b19 100644 --- a/include/z64play.h +++ b/include/z64play.h @@ -63,7 +63,7 @@ typedef struct PlayState { /* 0x10B20 */ AnimTaskQueue animTaskQueue; /* 0x117A4 */ ObjectContext objectCtx; /* 0x11CBC */ RoomContext roomCtx; - /* 0x11D34 */ TransitionActorContext transiActorCtx; + /* 0x11D34 */ TransitionActorList transitionActors; /* 0x11D3C */ void (*playerInit)(Player* player, struct PlayState* play, FlexSkeletonHeader* skelHeader); /* 0x11D40 */ void (*playerUpdate)(Player* player, struct PlayState* play, Input* input); /* 0x11D44 */ int (*isPlayerDroppingFish)(struct PlayState* play); @@ -81,8 +81,7 @@ typedef struct PlayState { /* 0x11DE9 */ u8 haltAllActors; /* 0x11DEA */ u8 spawn; /* 0x11DEB */ u8 numActorEntries; - /* 0x11DEC */ u8 numRooms; - /* 0x11DF0 */ RomFile* roomList; + /* 0x11DEC */ RoomList roomList; /* 0x11DF4 */ ActorEntry* playerEntry; /* 0x11DF8 */ ActorEntry* actorEntryList; /* 0x11DFC */ void* unk_11DFC; diff --git a/include/z64scene.h b/include/z64scene.h index 72fb4ebd8b..87c8927d9f 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -40,10 +40,10 @@ typedef struct TransitionActorEntry { /* 0x0E */ s16 params; } TransitionActorEntry; // size = 0x10 -typedef struct TransitionActorContext { - /* 0x00 */ u8 numActors; +typedef struct TransitionActorList { + /* 0x00 */ u8 count; /* 0x04 */ TransitionActorEntry* list; -} TransitionActorContext; // size = 0x8 +} TransitionActorList; // size = 0x8 typedef struct Spawn { /* 0x00 */ u8 playerEntryIndex; @@ -171,7 +171,7 @@ typedef enum RoomBehaviorType2 { } RoomBehaviorType2; typedef struct Room { - /* 0x00 */ s8 num; + /* 0x00 */ s8 num; // -1 is invalid room /* 0x01 */ u8 unk_01; /* 0x02 */ u8 behaviorType2; /* 0x03 */ u8 behaviorType1; @@ -185,16 +185,21 @@ typedef struct Room { typedef struct RoomContext { /* 0x00 */ Room curRoom; /* 0x14 */ Room prevRoom; - /* 0x28 */ void* bufPtrs[2]; - /* 0x30 */ u8 unk_30; - /* 0x31 */ s8 status; - /* 0x34 */ void* unk_34; + /* 0x28 */ void* bufPtrs[2]; // Start and end pointers for the room buffer. Can be split into two pages, where page 0 is allocated from the start pointer and page 1 is allocated from the end pointer. + /* 0x30 */ u8 activeBufPage; // 0 - First page in memory, 1 - Last page in memory + /* 0x31 */ s8 status; // 0 - Free for new room request, 1 - DmaRequest for a new room is in progress + /* 0x34 */ void* roomRequestAddr; // Pointer to where the requested room segment will be stored /* 0x38 */ DmaRequest dmaRequest; /* 0x58 */ OSMesgQueue loadQueue; /* 0x70 */ OSMesg loadMsg; - /* 0x74 */ s16 unk_74[2]; // context-specific data used by the current scene draw config + /* 0x74 */ s16 drawParams[2]; // context-specific data used by the current scene draw config } RoomContext; // size = 0x78 +typedef struct RoomList { + /* 0x00 */ u8 count; + /* 0x04 */ RomFile* romFiles; // Array of rom addresses for each room in a scene +} RoomList; + #define ROOM_DRAW_OPA (1 << 0) #define ROOM_DRAW_XLU (1 << 1) diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 0402573ad3..d3e16ac59c 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -42,8 +42,8 @@ */ #if PLATFORM_GC -#pragma increment_block_number "gc-eu:240 gc-eu-mq:240 gc-eu-mq-dbg:224 gc-jp:240 gc-jp-ce:240 gc-jp-mq:240 gc-us:240" \ - "gc-us-mq:240" +#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-eu-mq-dbg:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224" \ + "gc-us-mq:224" #include "global.h" #include "alloca.h" diff --git a/src/code/fault_gc_drawer.c b/src/code/fault_gc_drawer.c index 5cf088fca6..808b258497 100644 --- a/src/code/fault_gc_drawer.c +++ b/src/code/fault_gc_drawer.c @@ -7,6 +7,7 @@ #include "global.h" #include "fault.h" #include "terminal.h" +#pragma increment_block_number "gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" #if PLATFORM_GC diff --git a/src/code/main.c b/src/code/main.c index 2487725635..ab274c40ea 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -14,7 +14,7 @@ s32 gScreenWidth = SCREEN_WIDTH; s32 gScreenHeight = SCREEN_HEIGHT; u32 gSystemHeapSize = 0; -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" +#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-jp:208 gc-jp-ce:208 gc-jp-mq:208 gc-us:208 gc-us-mq:208" PreNmiBuff* gAppNmiBufferPtr; Scheduler gScheduler; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 96617f4962..78710229fe 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1972,7 +1972,7 @@ void func_8002F994(Actor* actor, s32 timer) { // Tests if something hit Jabu Jabu surface, displaying hit splash and playing sfx if true s32 func_8002F9EC(PlayState* play, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos) { if (SurfaceType_GetFloorType(&play->colCtx, poly, bgId) == FLOOR_TYPE_8) { - play->roomCtx.unk_74[0] = 1; + play->roomCtx.drawParams[0] = 1; CollisionCheck_BlueBlood(play, NULL, pos); Actor_PlaySfx(actor, NA_SE_IT_WALL_HIT_BUYO); return true; @@ -3079,8 +3079,8 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { u8 numActors; s32 i; - transitionActor = play->transiActorCtx.list; - numActors = play->transiActorCtx.numActors; + transitionActor = play->transitionActors.list; + numActors = play->transitionActors.count; for (i = 0; i < numActors; i++) { if (transitionActor->id >= 0) { @@ -3095,7 +3095,7 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { (i << TRANSITION_ACTOR_PARAMS_INDEX_SHIFT) + transitionActor->params); transitionActor->id = -transitionActor->id; - numActors = play->transiActorCtx.numActors; + numActors = play->transitionActors.count; } } transitionActor++; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 6cf3ae941e..f46e33a552 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -310,8 +310,8 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { break; case CS_MISC_FADE_KOKIRI_GRASS_ENV_ALPHA: - if (play->roomCtx.unk_74[0] <= 127) { - play->roomCtx.unk_74[0] += 4; + if (play->roomCtx.drawParams[0] <= 127) { + play->roomCtx.drawParams[0] += 4; } break; @@ -324,14 +324,14 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { break; case CS_MISC_DEKU_TREE_DEATH: - if (play->roomCtx.unk_74[0] < 1650) { - play->roomCtx.unk_74[0] += 20; + if (play->roomCtx.drawParams[0] < 1650) { + play->roomCtx.drawParams[0] += 20; } if (csCtx->curFrame == 783) { Sfx_PlaySfxCentered(NA_SE_EV_DEKU_DEATH); } else if (csCtx->curFrame == 717) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; } break; @@ -344,12 +344,12 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { break; case CS_MISC_TRIFORCE_FLASH: - if (play->roomCtx.unk_74[1] == 0) { + if (play->roomCtx.drawParams[1] == 0) { Sfx_PlaySfxCentered(NA_SE_EV_TRIFORCE_FLASH); } - if (play->roomCtx.unk_74[1] < 255) { - play->roomCtx.unk_74[1] += 5; + if (play->roomCtx.drawParams[1] < 255) { + play->roomCtx.drawParams[1] += 5; } break; diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 49fcbf4357..6a8026cdb9 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -441,8 +441,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) sLightningBolts[i].state = LIGHTNING_BOLT_INACTIVE; } - play->roomCtx.unk_74[0] = 0; - play->roomCtx.unk_74[1] = 0; + play->roomCtx.drawParams[0] = 0; + play->roomCtx.drawParams[1] = 0; for (i = 0; i < ARRAY_COUNT(play->csCtx.actorCues); i++) { play->csCtx.actorCues[i] = NULL; diff --git a/src/code/z_message.c b/src/code/z_message.c index 0f42e5e82f..eff41c44c2 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -8,7 +8,7 @@ #include "n64dd.h" #endif -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" #if PLATFORM_N64 #define OCARINA_BUTTON_A_PRIM_R 80 diff --git a/src/code/z_play.c b/src/code/z_play.c index 4a0309b5fa..99bb024681 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -468,7 +468,8 @@ void Play_Init(GameState* thisx) { Actor_InitContext(this, &this->actorCtx, this->playerEntry); - while (!func_800973FC(this, &this->roomCtx)) { + // Busyloop until the room loads + while (!Room_ProcessRoomRequest(this, &this->roomCtx)) { ; // Empty Loop } @@ -950,7 +951,7 @@ void Play_Update(PlayState* this) { } } else { PLAY_LOG(3606); - func_800973FC(this, &this->roomCtx); + Room_ProcessRoomRequest(this, &this->roomCtx); PLAY_LOG(3612); CollisionCheck_AT(this, &this->colChkCtx); @@ -1524,8 +1525,8 @@ void Play_InitScene(PlayState* this, s32 spawn) { Object_InitContext(this, &this->objectCtx); LightContext_Init(this, &this->lightCtx); - TransitionActor_InitContext(&this->state, &this->transiActorCtx); - func_80096FD4(this, &this->roomCtx.curRoom); + Scene_ResetTransitionActorList(&this->state, &this->transitionActors); + Room_Init(this, &this->roomCtx.curRoom); R_SCENE_CAM_TYPE = SCENE_CAM_TYPE_DEFAULT; gSaveContext.worldMapArea = WORLD_MAP_AREA_HYRULE_FIELD; Scene_ExecuteCommands(this, this->sceneSegment); @@ -1579,7 +1580,7 @@ void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) { } #endif - size = func_80096FE8(this, &this->roomCtx); + size = Room_SetupFirstRoom(this, &this->roomCtx); PRINTF("ROOM SIZE=%fK\n", size / 1024.0f); } @@ -1913,7 +1914,7 @@ s32 func_800C0D34(PlayState* this, Actor* actor, s16* yaw) { return 0; } - transitionActor = &this->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(actor)]; + transitionActor = &this->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(actor)]; frontRoom = transitionActor->sides[0].room; if (frontRoom == transitionActor->sides[1].room) { diff --git a/src/code/z_room.c b/src/code/z_room.c index 5a88f1c281..e0906de17e 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -536,13 +536,18 @@ void Room_DrawImage(PlayState* play, Room* room, u32 flags) { } } -void func_80096FD4(PlayState* play, Room* room) { +void Room_Init(PlayState* play, Room* room) { room->num = -1; room->segment = NULL; } -u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { - u32 maxRoomSize = 0; +/** + * Allocates memory for rooms and fetches the first room that the player will spawn into. + * + * @return u32 size of the buffer reserved for room data + */ +u32 Room_SetupFirstRoom(PlayState* play, RoomContext* roomCtx) { + u32 roomBufferSize = 0; u32 roomSize; s32 i; s32 j; @@ -553,25 +558,27 @@ u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { u32 cumulRoomSize; s32 pad; + // Set roomBufferSize to the largest room { - RomFile* roomList = play->roomList; + RomFile* roomList = play->roomList.romFiles; - for (i = 0; i < play->numRooms; i++) { + for (i = 0; i < play->roomList.count; i++) { roomSize = roomList[i].vromEnd - roomList[i].vromStart; PRINTF("ROOM%d size=%d\n", i, roomSize); - if (maxRoomSize < roomSize) { - maxRoomSize = roomSize; + if (roomBufferSize < roomSize) { + roomBufferSize = roomSize; } } } - if ((u32)play->transiActorCtx.numActors != 0) { - RomFile* roomList = play->roomList; - TransitionActorEntry* transitionActor = &play->transiActorCtx.list[0]; + // If there any rooms are connected, find their combined size and update roomBufferSize if larger + if ((u32)play->transitionActors.count != 0) { + RomFile* roomList = play->roomList.romFiles; + TransitionActorEntry* transitionActor = &play->transitionActors.list[0]; - LOG_NUM("game_play->room_rom_address.num", play->numRooms, "../z_room.c", 912); + LOG_NUM("game_play->room_rom_address.num", play->roomList.count, "../z_room.c", 912); - for (j = 0; j < play->transiActorCtx.numActors; j++) { + for (j = 0; j < play->transitionActors.count; j++) { frontRoom = transitionActor->sides[0].room; backRoom = transitionActor->sides[1].room; frontRoomSize = (frontRoom < 0) ? 0 : roomList[frontRoom].vromEnd - roomList[frontRoom].vromStart; @@ -580,32 +587,52 @@ u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { PRINTF("DOOR%d=<%d> ROOM1=<%d, %d> ROOM2=<%d, %d>\n", j, cumulRoomSize, frontRoom, frontRoomSize, backRoom, backRoomSize); - if (maxRoomSize < cumulRoomSize) { - maxRoomSize = cumulRoomSize; + if (roomBufferSize < cumulRoomSize) { + roomBufferSize = cumulRoomSize; } transitionActor++; } } PRINTF(VT_FGCOL(YELLOW)); - PRINTF(T("部屋バッファサイズ=%08x(%5.1fK)\n", "Room buffer size=%08x(%5.1fK)\n"), maxRoomSize, - maxRoomSize / 1024.0f); - roomCtx->bufPtrs[0] = GAME_STATE_ALLOC(&play->state, maxRoomSize, "../z_room.c", 946); + PRINTF(T("部屋バッファサイズ=%08x(%5.1fK)\n", "Room buffer size=%08x(%5.1fK)\n"), roomBufferSize, + roomBufferSize / 1024.0f); + roomCtx->bufPtrs[0] = GAME_STATE_ALLOC(&play->state, roomBufferSize, "../z_room.c", 946); PRINTF(T("部屋バッファ開始ポインタ=%08x\n", "Room buffer initial pointer=%08x\n"), roomCtx->bufPtrs[0]); - roomCtx->bufPtrs[1] = (void*)((uintptr_t)roomCtx->bufPtrs[0] + maxRoomSize); + roomCtx->bufPtrs[1] = (void*)((uintptr_t)roomCtx->bufPtrs[0] + roomBufferSize); PRINTF(T("部屋バッファ終了ポインタ=%08x\n", "Room buffer end pointer=%08x\n"), roomCtx->bufPtrs[1]); PRINTF(VT_RST); - roomCtx->unk_30 = 0; + roomCtx->activeBufPage = 0; roomCtx->status = 0; frontRoom = gSaveContext.respawnFlag > 0 ? ((void)0, gSaveContext.respawn[gSaveContext.respawnFlag - 1].roomIndex) : play->spawnList[play->spawn].room; - func_8009728C(play, roomCtx, frontRoom); - return maxRoomSize; + // Load into a room for the first time. + // Since curRoom was initialized to `room = -1` and `segment = NULL` in Play_InitScene, the previous room + // will also be initialized to the nulled state when this function completes. + Room_RequestNewRoom(play, roomCtx, frontRoom); + + return roomBufferSize; } -s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { +/** + * Tries to create an asynchronous request to transfer room data into memory. + * If successful, the requested room will be loaded into memory and becomes the new current room; the room that was + * current before becomes the previous room. + * + * Room_RequestNewRoom will be blocked from loading new rooms until Room_ProcessRoomRequest completes room + * initialization. + * + * Calling Room_RequestNewRoom outside of Room_SetupFirstRoom will allow for two rooms being initialized simultaneously. + * This allows an actor like ACTOR_EN_HOLL to seamlessly swap the two rooms as the player moves between them. Calling + * Room_FinishRoomChange afterward will finalize the room swap. + * + * @param roomNum is the id of the room to load. roomNum must NOT be the same id as curRoom.num, since this will create + * duplicate actor instances that cannot be cleaned up by calling Room_FinishRoomChange + * @returns bool false if the request could not be created. + */ +s32 Room_RequestNewRoom(PlayState* play, RoomContext* roomCtx, s32 roomNum) { if (roomCtx->status == 0) { u32 size; @@ -614,11 +641,11 @@ s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { roomCtx->curRoom.segment = NULL; roomCtx->status = 1; - ASSERT(roomNum < play->numRooms, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); + ASSERT(roomNum < play->roomList.count, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); - size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart; - roomCtx->unk_34 = - (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); + size = play->roomList.romFiles[roomNum].vromEnd - play->roomList.romFiles[roomNum].vromStart; + roomCtx->roomRequestAddr = (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->activeBufPage] - + ((size + 8) * roomCtx->activeBufPage + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); @@ -626,37 +653,44 @@ s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { if ((B_80121220 != NULL) && (B_80121220->unk_08 != NULL)) { B_80121220->unk_08(play, roomCtx, roomNum); } else { - DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, - &roomCtx->loadQueue, NULL, "../z_room.c", 1036); + DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->roomRequestAddr, + play->roomList.romFiles[roomNum].vromStart, size, 0, &roomCtx->loadQueue, NULL, + "../z_room.c", 1036); } #else - DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, - &roomCtx->loadQueue, NULL, "../z_room.c", 1036); + DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->roomRequestAddr, play->roomList.romFiles[roomNum].vromStart, + size, 0, &roomCtx->loadQueue, NULL, "../z_room.c", 1036); #endif - roomCtx->unk_30 ^= 1; + roomCtx->activeBufPage ^= 1; return true; } return false; } -s32 func_800973FC(PlayState* play, RoomContext* roomCtx) { +/** + * Completes room initialization for the room requested by a call to Room_RequestNewRoom. + * This function does not block the thread if the room data is still being transferred. + * + * @returns bool false if a dma transfer is in progress. + */ +s32 Room_ProcessRoomRequest(PlayState* play, RoomContext* roomCtx) { if (roomCtx->status == 1) { if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { roomCtx->status = 0; - roomCtx->curRoom.segment = roomCtx->unk_34; - gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); + roomCtx->curRoom.segment = roomCtx->roomRequestAddr; + gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->curRoom.segment); Scene_ExecuteCommands(play, roomCtx->curRoom.segment); Player_SetBootData(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); } else { - return 0; + return false; } } - return 1; + return true; } void Room_Draw(PlayState* play, Room* room, u32 flags) { @@ -668,9 +702,17 @@ void Room_Draw(PlayState* play, Room* room, u32 flags) { } } -void func_80097534(PlayState* play, RoomContext* roomCtx) { +/** + * Finalizes a swap between two rooms. + * + * When a new room is created with Room_RequestNewRoom, the previous room and its actors remain in memory. This allows + * an actor like ACTOR_EN_HOLL to seamlessly swap the two rooms as the player moves between them. + */ +void Room_FinishRoomChange(PlayState* play, RoomContext* roomCtx) { + // Delete the previous room roomCtx->prevRoom.num = -1; roomCtx->prevRoom.segment = NULL; + func_80031B14(play, &play->actorCtx); Actor_SpawnTransitionActors(play, &play->actorCtx); Map_InitRoomData(play, roomCtx->curRoom.num); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 83714b8a4d..f72c06cada 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -230,8 +230,8 @@ BAD_RETURN(s32) Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd) { } BAD_RETURN(s32) Scene_CommandRoomList(PlayState* play, SceneCmd* cmd) { - play->numRooms = cmd->roomList.length; - play->roomList = SEGMENTED_TO_VIRTUAL(cmd->roomList.data); + play->roomList.count = cmd->roomList.length; + play->roomList.romFiles = SEGMENTED_TO_VIRTUAL(cmd->roomList.data); } BAD_RETURN(s32) Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) { @@ -327,12 +327,12 @@ BAD_RETURN(s32) Scene_CommandPathList(PlayState* play, SceneCmd* cmd) { } BAD_RETURN(s32) Scene_CommandTransitionActorEntryList(PlayState* play, SceneCmd* cmd) { - play->transiActorCtx.numActors = cmd->transiActorList.length; - play->transiActorCtx.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.data); + play->transitionActors.count = cmd->transiActorList.length; + play->transitionActors.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.data); } -void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx) { - transiActorCtx->numActors = 0; +void Scene_ResetTransitionActorList(GameState* state, TransitionActorList* transitionActors) { + transitionActors->count = 0; } BAD_RETURN(s32) Scene_CommandLightSettingsList(PlayState* play, SceneCmd* cmd) { diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index 6767993f0c..ed18c33c62 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -289,12 +289,12 @@ void Scene_DrawConfigDodongosCavern(PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x0B, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT]); + gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT]); + gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT]); gSPEndDisplayList(displayListHead++); CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4956); @@ -306,7 +306,7 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5069); - temp = play->roomCtx.unk_74[0] / 255.0f; + temp = play->roomCtx.drawParams[0] / 255.0f; gSPSegment(POLY_XLU_DISP++, 0x08, displayListHead); gSPSegment(POLY_OPA_DISP++, 0x08, displayListHead); @@ -323,7 +323,7 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x0A, displayListHead); gSPSegment(POLY_XLU_DISP++, 0x0A, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0B, displayListHead); @@ -331,7 +331,7 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { gDPSetPrimColor(displayListHead++, 0, 0, 89 + (u8)(166.0f * temp), 89 + (u8)(166.0f * temp), 89 + (u8)(166.0f * temp), 255); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, displayListHead); @@ -339,13 +339,13 @@ void Scene_DrawConfigTempleOfTime(PlayState* play) { gDPSetPrimColor(displayListHead++, 0, 0, 255 + (u8)(179.0f * temp), 255 + (u8)(179.0f * temp), 255 + (u8)(179.0f * temp), 255); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0D, displayListHead); gSPSegment(POLY_XLU_DISP++, 0x0D, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[1]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.drawParams[1]); gSPEndDisplayList(displayListHead); CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5145); @@ -539,8 +539,8 @@ void Scene_DrawConfigWaterTemple(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5535); - spB0 = (play->roomCtx.unk_74[1] >> 8) & 0xFF; - spAC = play->roomCtx.unk_74[1] & 0xFF; + spB0 = (play->roomCtx.drawParams[1] >> 8) & 0xFF; + spAC = play->roomCtx.drawParams[1] & 0xFF; gameplayFrames = play->gameplayFrames; #if !OOT_MQ @@ -613,7 +613,7 @@ void Scene_DrawConfigWaterTempleBoss(PlayState* play) { Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, play->roomCtx.unk_74[0]); + gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, play->roomCtx.drawParams[0]); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 145); @@ -913,7 +913,7 @@ void Scene_DrawConfigFishingPond(PlayState* play) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScrollPrimColor(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 255, 255, - 255, play->roomCtx.unk_74[0] + 127)); + 255, play->roomCtx.drawParams[0] + 127)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1093,16 +1093,16 @@ void Scene_DrawConfigHyruleField(PlayState* play) { gSPEndDisplayList(displayListHead++); } else { if (gSaveContext.save.dayTime > CLOCK_TIME(18, 30)) { - if (play->roomCtx.unk_74[0] != 255) { - Math_StepToS(&play->roomCtx.unk_74[0], 255, 5); + if (play->roomCtx.drawParams[0] != 255) { + Math_StepToS(&play->roomCtx.drawParams[0], 255, 5); } } else if (gSaveContext.save.dayTime >= CLOCK_TIME(6, 0)) { - if (play->roomCtx.unk_74[0] != 0) { - Math_StepToS(&play->roomCtx.unk_74[0], 0, 10); + if (play->roomCtx.drawParams[0] != 0) { + Math_StepToS(&play->roomCtx.drawParams[0], 0, 10); } } - gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.unk_74[0]); + gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.drawParams[0]); gSPDisplayList(displayListHead++, spot00_room_0DL_012B20); gSPEndDisplayList(displayListHead++); } @@ -1187,9 +1187,9 @@ void Scene_DrawConfigKokiriForest(PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); if (gSaveContext.sceneLayer == 4) { - spA3 = 255 - (u8)play->roomCtx.unk_74[0]; + spA3 = 255 - (u8)play->roomCtx.drawParams[0]; } else if (gSaveContext.sceneLayer == 6) { - spA0 = play->roomCtx.unk_74[0] + 500; + spA0 = play->roomCtx.drawParams[0] + 500; } else if ((!IS_CUTSCENE_LAYER || LINK_IS_ADULT) && GET_EVENTCHKINF(EVENTCHKINF_07)) { spA0 = 2150; } @@ -1206,8 +1206,8 @@ void Scene_DrawConfigKokiriForest(PlayState* play) { gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, - Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, (s16)(-play->roomCtx.unk_74[0] * 0.02f), 32, 16, - 1, 0, (s16)(-play->roomCtx.unk_74[0] * 0.02f), 32, 16)); + Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, (s16)(-play->roomCtx.drawParams[0] * 0.02f), 32, + 16, 1, 0, (s16)(-play->roomCtx.drawParams[0] * 0.02f), 32, 16)); CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7044); } @@ -1218,16 +1218,16 @@ void Scene_DrawConfigLakeHylia(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7058); if (IS_CUTSCENE_LAYER || (LINK_IS_ADULT && !GET_EVENTCHKINF(EVENTCHKINF_69))) { - play->roomCtx.unk_74[0] = 87; + play->roomCtx.drawParams[0] = 87; } gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, G_TX_RENDERTILE, gameplayFrames, gameplayFrames, 32, 32, 1, - 0, 0, 32, 32, 0, 0, 0, play->roomCtx.unk_74[0] + 168)); + 0, 0, 32, 32, 0, 0, 0, play->roomCtx.drawParams[0] + 168)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, G_TX_RENDERTILE, -gameplayFrames, -gameplayFrames, 32, 32, - 1, 0, 0, 16, 64, 0, 0, 0, play->roomCtx.unk_74[0] + 168)); + 1, 0, 0, 16, 64, 0, 0, 0, play->roomCtx.drawParams[0] + 168)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 128); @@ -1341,12 +1341,12 @@ void Scene_DrawConfigLostWoods(PlayState* play) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - if ((play->roomCtx.unk_74[0] == 0) && (INV_CONTENT(ITEM_COJIRO) == ITEM_COJIRO)) { - if (play->roomCtx.unk_74[1] == 50) { + if ((play->roomCtx.drawParams[0] == 0) && (INV_CONTENT(ITEM_COJIRO) == ITEM_COJIRO)) { + if (play->roomCtx.drawParams[1] == 50) { Player_PlaySfx(GET_PLAYER(play), NA_SE_EV_CHICKEN_CRY_M); - play->roomCtx.unk_74[0] = 1; + play->roomCtx.drawParams[0] = 1; } - play->roomCtx.unk_74[1]++; + play->roomCtx.drawParams[1]++; } CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7309); @@ -1441,16 +1441,16 @@ void Scene_DrawConfigDeathMountainTrail(PlayState* play) { gSPEndDisplayList(displayListHead++); } else { if (gSaveContext.save.dayTime > CLOCK_TIME(18, 0)) { - if (play->roomCtx.unk_74[0] != 255) { - Math_StepToS(&play->roomCtx.unk_74[0], 255, 5); + if (play->roomCtx.drawParams[0] != 255) { + Math_StepToS(&play->roomCtx.drawParams[0], 255, 5); } } else if (gSaveContext.save.dayTime >= CLOCK_TIME(6, 0)) { - if (play->roomCtx.unk_74[0] != 0) { - Math_StepToS(&play->roomCtx.unk_74[0], 0, 10); + if (play->roomCtx.drawParams[0] != 0) { + Math_StepToS(&play->roomCtx.drawParams[0], 0, 10); } } - gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.unk_74[0]); + gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.drawParams[0]); gSPDisplayList(displayListHead++, spot16_room_0DL_00AA48); gSPEndDisplayList(displayListHead++); } @@ -1604,27 +1604,27 @@ void Scene_DrawConfigJabuJabu(PlayState* play) { 1.f + (1 * temp * Math_CosS(D_8012A39C))); View_SetDistortionSpeed(&play->view, 0.95f); - switch (play->roomCtx.unk_74[0]) { + switch (play->roomCtx.drawParams[0]) { case 0: break; case 1: - if (play->roomCtx.unk_74[1] < 1200) { - play->roomCtx.unk_74[1] += 200; + if (play->roomCtx.drawParams[1] < 1200) { + play->roomCtx.drawParams[1] += 200; } else { - play->roomCtx.unk_74[0]++; + play->roomCtx.drawParams[0]++; } break; case 2: - if (play->roomCtx.unk_74[1] > 0) { - play->roomCtx.unk_74[1] -= 30; + if (play->roomCtx.drawParams[1] > 0) { + play->roomCtx.drawParams[1] -= 30; } else { - play->roomCtx.unk_74[1] = 0; - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[1] = 0; + play->roomCtx.drawParams[0] = 0; } break; } - D_8012A398 += 0.15f + (play->roomCtx.unk_74[1] * 0.001f); + D_8012A398 += 0.15f + (play->roomCtx.drawParams[1] * 0.001f); } if (play->roomCtx.curRoom.num == 2) { diff --git a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c index 419f214972..0c1b1b564e 100644 --- a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c +++ b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c @@ -121,7 +121,7 @@ void BgDodoago_Init(Actor* thisx, PlayState* play) { if (Flags_GetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6))) { BgDodoago_SetupAction(this, BgDodoago_DoNothing); this->dyna.actor.shape.rot.x = 0x1333; - play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] = play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] = 255; + play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] = play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] = 255; return; } @@ -154,15 +154,15 @@ void BgDodoago_WaitExplosives(BgDodoago* this, PlayState* play) { ? BGDODOAGO_EYE_RIGHT : BGDODOAGO_EYE_LEFT; - if (((play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] == 255) && (this->state == BGDODOAGO_EYE_RIGHT)) || - ((play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] == 255) && (this->state == BGDODOAGO_EYE_LEFT))) { + if (((play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] == 255) && (this->state == BGDODOAGO_EYE_RIGHT)) || + ((play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] == 255) && (this->state == BGDODOAGO_EYE_LEFT))) { Flags_SetSwitch(play, PARAMS_GET_U(this->dyna.actor.params, 0, 6)); this->state = 0; Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); BgDodoago_SetupAction(this, BgDodoago_OpenJaw); OnePointCutscene_Init(play, 3380, 160, &this->dyna.actor, CAM_ID_MAIN); - } else if (play->roomCtx.unk_74[this->state] == 0) { + } else if (play->roomCtx.drawParams[this->state] == 0) { OnePointCutscene_Init(play, 3065, 40, &this->dyna.actor, CAM_ID_MAIN); BgDodoago_SetupAction(this, BgDodoago_LightOneEye); Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, @@ -212,14 +212,14 @@ void BgDodoago_OpenJaw(BgDodoago* this, PlayState* play) { s32 i; // make both eyes red (one already is) - if (play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] < 255) { - play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] += 5; + if (play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] < 255) { + play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] += 5; } - if (play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] < 255) { - play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] += 5; + if (play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] < 255) { + play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] += 5; } - if (play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] != 255 || play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] != 255) { + if (play->roomCtx.drawParams[BGDODOAGO_EYE_LEFT] != 255 || play->roomCtx.drawParams[BGDODOAGO_EYE_RIGHT] != 255) { sTimer--; return; } @@ -260,9 +260,9 @@ void BgDodoago_DoNothing(BgDodoago* this, PlayState* play) { } void BgDodoago_LightOneEye(BgDodoago* this, PlayState* play) { - play->roomCtx.unk_74[this->state] += 5; + play->roomCtx.drawParams[this->state] += 5; - if (play->roomCtx.unk_74[this->state] == 255) { + if (play->roomCtx.drawParams[this->state] == 255) { BgDodoago_SetupAction(this, BgDodoago_WaitExplosives); } } diff --git a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c index e6f353eacf..141a4617bd 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c @@ -238,7 +238,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 5.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; Message_CloseTextbox(play); } @@ -253,7 +253,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { this->targetY = this->baseY; } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; } waterBoxes[6].ySurface = this->actor.world.pos.y; @@ -265,7 +265,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { this->targetY = this->baseY; } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; } waterBoxes[8].ySurface = this->actor.world.pos.y; @@ -277,7 +277,7 @@ void BgMizuWater_ChangeWaterLevel(BgMizuWater* this, PlayState* play) { this->targetY = this->baseY; } if (Math_StepToF(&this->actor.world.pos.y, this->targetY, 1.0f)) { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; this->actionFunc = BgMizuWater_WaitForAction; } waterBoxes[16].ySurface = this->actor.world.pos.y; @@ -323,7 +323,7 @@ void BgMizuWater_Update(Actor* thisx, PlayState* play) { unk1 = 255 - (s32)((posY - WATER_TEMPLE_WATER_F2_Y) / (WATER_TEMPLE_WATER_F3_Y - WATER_TEMPLE_WATER_F2_Y) * (255 - 160)); } - play->roomCtx.unk_74[1] = ((u8)unk0 << 8) | (unk1 & 0xFF); + play->roomCtx.drawParams[1] = ((u8)unk0 << 8) | (unk1 & 0xFF); } this->actionFunc(this, play); diff --git a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c index 61cd9da383..61a3603baa 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c +++ b/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c @@ -105,7 +105,7 @@ void func_808BA018(Actor* thisx, PlayState* play) { } void func_808BA204(BgTokiHikari* this, PlayState* play) { - if (play->roomCtx.unk_74[1] != 0) { + if (play->roomCtx.drawParams[1] != 0) { this->actionFunc = func_808BA22C; } } diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c index 2a689189c9..e4106619a6 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c @@ -77,7 +77,7 @@ void BgTokiSwd_Init(Actor* thisx, PlayState* play) { } if (gSaveContext.sceneLayer == 5) { - play->roomCtx.unk_74[0] = 0xFF; + play->roomCtx.drawParams[0] = 0xFF; } Collider_InitCylinder(play, &this->collider); @@ -119,10 +119,10 @@ void func_808BAF40(BgTokiSwd* this, PlayState* play) { } } if (gSaveContext.sceneLayer == 5) { - if (play->roomCtx.unk_74[0] > 0) { - play->roomCtx.unk_74[0]--; + if (play->roomCtx.drawParams[0] > 0) { + play->roomCtx.drawParams[0]--; } else { - play->roomCtx.unk_74[0] = 0; + play->roomCtx.drawParams[0] = 0; } } } @@ -146,8 +146,8 @@ void func_808BB0AC(BgTokiSwd* this, PlayState* play) { } void func_808BB128(BgTokiSwd* this, PlayState* play) { - if (CutsceneFlags_Get(play, 1) && (play->roomCtx.unk_74[0] < 0xFF)) { - play->roomCtx.unk_74[0] += 5; + if (CutsceneFlags_Get(play, 1) && (play->roomCtx.drawParams[0] < 0xFF)) { + play->roomCtx.drawParams[0] += 5; } } diff --git a/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c b/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c index d1748fafc0..4edc3a4e3c 100644 --- a/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c +++ b/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c @@ -241,7 +241,7 @@ void BgTreemouth_Draw(Actor* thisx, PlayState* play) { } if (gSaveContext.sceneLayer == 6) { - alpha = (play->roomCtx.unk_74[0] + 0x1F4); + alpha = (play->roomCtx.drawParams[0] + 0x1F4); } gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, alpha * 0.1f); diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index a833dbb523..a5616563d7 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -337,7 +337,7 @@ void BossMo_Init(Actor* thisx, PlayState* play2) { Flags_SetSwitch(play, 0x14); sMorphaCore = this; MO_WATER_LEVEL(play) = this->waterLevel = MO_WATER_LEVEL(play); - play->roomCtx.unk_74[0] = 0xA0; + play->roomCtx.drawParams[0] = 0xA0; play->specialEffects = sEffects; for (i = 0; i < BOSS_MO_EFFECT_COUNT; i++) { sEffects[i].type = MO_FX_NONE; @@ -357,7 +357,7 @@ void BossMo_Init(Actor* thisx, PlayState* play2) { Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, -280.0f, 0.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, -200.0f, -280.0f, 0.0f, 0, 0, 0, 0); - play->roomCtx.unk_74[0] = 0xFF; + play->roomCtx.drawParams[0] = 0xFF; MO_WATER_LEVEL(play) = -500; return; } @@ -1711,9 +1711,9 @@ void BossMo_DeathCs(BossMo* this, PlayState* play) { } } if (sMorphaCore->waterLevel < -200.0f) { - play->roomCtx.unk_74[0]++; - if (play->roomCtx.unk_74[0] >= 0xFF) { - play->roomCtx.unk_74[0] = 0xFF; + play->roomCtx.drawParams[0]++; + if (play->roomCtx.drawParams[0] >= 0xFF) { + play->roomCtx.drawParams[0] = 0xFF; } } if (sMorphaCore->waterLevel < -250.0f) { diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index cd106c8519..16d4fa28c9 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -236,7 +236,7 @@ void DemoKankyo_Init(Actor* thisx, PlayState* play) { Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_TOKI, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x0000); } else { - play->roomCtx.unk_74[1] = 0xFF; + play->roomCtx.drawParams[1] = 0xFF; Actor_Kill(&this->actor); } break; diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 7a5298ebd6..64be9c8321 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -350,7 +350,7 @@ void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc * @return true if the door is barred */ s32 DoorShutter_SetupDoor(DoorShutter* this, PlayState* play) { - TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; + TransitionActorEntry* transitionEntry = &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; s8 frontRoom = transitionEntry->sides[0].room; s32 doorType = this->doorType; DoorShutterStyleInfo* styleInfo = &sStyleInfo[this->styleType]; @@ -462,7 +462,7 @@ void DoorShutter_Destroy(Actor* thisx, PlayState* play) { if (this->dyna.actor.room >= 0) { s32 transitionActorId = GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor); - play->transiActorCtx.list[transitionActorId].id *= -1; + play->transitionActors.list[transitionActorId].id *= -1; } } @@ -801,7 +801,7 @@ void DoorShutter_SetupClosed(DoorShutter* this, PlayState* play) { Vec3f relPlayerPos; Actor_WorldToActorCoords(&this->dyna.actor, &relPlayerPos, &player->actor.world.pos); - this->dyna.actor.room = play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)] + this->dyna.actor.room = play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)] .sides[(relPlayerPos.z < 0.0f) ? 0 : 1] .room; if (room != this->dyna.actor.room) { @@ -809,9 +809,9 @@ void DoorShutter_SetupClosed(DoorShutter* this, PlayState* play) { play->roomCtx.curRoom = play->roomCtx.prevRoom; play->roomCtx.prevRoom = tempRoom; - play->roomCtx.unk_30 ^= 1; + play->roomCtx.activeBufPage ^= 1; } - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); Play_SetupRespawnPoint(play, RESPAWN_MODE_DOWN, 0x0EFF); } this->isActive = false; @@ -1012,7 +1012,7 @@ void DoorShutter_Draw(Actor* thisx, PlayState* play) { } else { if (gfxInfo->barsDL != NULL) { TransitionActorEntry* transitionEntry = - &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; + &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->dyna.actor)]; if (play->roomCtx.prevRoom.num >= 0 || transitionEntry->sides[0].room == transitionEntry->sides[1].room) { diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 0dca15d850..590337ed70 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -166,7 +166,7 @@ void EnDoor_Destroy(Actor* thisx, PlayState* play) { TransitionActorEntry* transitionEntry; EnDoor* this = (EnDoor*)thisx; - transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; + transitionEntry = &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; if (transitionEntry->id < 0) { transitionEntry->id = -transitionEntry->id; } @@ -334,7 +334,7 @@ s32 EnDoor_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* TransitionActorEntry* transitionEntry; Gfx** doorDLists = sDoorDLists[this->dListIndex]; - transitionEntry = &play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; + transitionEntry = &play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&this->actor)]; rot->z += this->actor.world.rot.y; if ((play->roomCtx.prevRoom.num >= 0) || (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { // Draw the side of the door that is visible to the camera diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index bc5d25a168..9b6619730a 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -133,7 +133,7 @@ void EnHoll_Init(Actor* thisx, PlayState* play) { void EnHoll_Destroy(Actor* thisx, PlayState* play) { s32 transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(thisx); - TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[transitionActorIndex]; + TransitionActorEntry* transitionEntry = &play->transitionActors.list[transitionActorIndex]; transitionEntry->id = -transitionEntry->id; } @@ -145,7 +145,7 @@ void EnHoll_SwapRooms(PlayState* play) { tempRoom = roomCtx->curRoom; roomCtx->curRoom = roomCtx->prevRoom; roomCtx->prevRoom = tempRoom; - play->roomCtx.unk_30 ^= 1; + play->roomCtx.activeBufPage ^= 1; } /** @@ -196,14 +196,14 @@ void EnHoll_HorizontalVisibleNarrow(EnHoll* this, PlayState* play) { transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); if (orthogonalDistToPlayer > sHorizontalVisibleNarrowTriggerDists[triggerDistsIndex][1]) { if (play->roomCtx.prevRoom.num >= 0 && play->roomCtx.status == 0) { - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[this->side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[this->side].room; EnHoll_SwapRooms(play); - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); } } else { - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[this->side ^ 1].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[this->side ^ 1].room; if (play->roomCtx.prevRoom.num < 0) { - func_8009728C(play, &play->roomCtx, this->actor.room); + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room); } else { this->planeAlpha = (255.0f / (sHorizontalVisibleNarrowTriggerDists[triggerDistsIndex][2] - @@ -239,14 +239,14 @@ void EnHoll_HorizontalInvisible(EnHoll* this, PlayState* play) { orthogonalDistToSubject > ENHOLL_H_INVISIBLE_LOAD_DEPTH_MIN))) { s32 transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); s32 side = (relSubjectPos.z < 0.0f) ? 0 : 1; - TransitionActorEntry* transitionEntry = &play->transiActorCtx.list[transitionActorIndex]; + TransitionActorEntry* transitionEntry = &play->transitionActors.list[transitionActorIndex]; s32 room = transitionEntry->sides[side].room; this->actor.room = room; if (isKokiriLayer8) {} if (this->actor.room != play->roomCtx.curRoom.num) { if (room) {} - if (func_8009728C(play, &play->roomCtx, this->actor.room)) { + if (Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); } } @@ -273,11 +273,11 @@ void EnHoll_VerticalDownBgCoverLarge(EnHoll* this, PlayState* play) { } if (absYDistToPlayer < ENHOLL_V_DOWN_LOAD_YDIST) { - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[1].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[1].room; Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 1.0f, 50.0f, 10.0f); Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 1.0f, 50.0f, 10.0f); if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); this->resetBgCoverAlpha = true; player->actor.speed = 0.0f; @@ -308,9 +308,9 @@ void EnHoll_VerticalBgCover(EnHoll* this, PlayState* play) { s32 transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); s32 side = (this->actor.yDistToPlayer > 0.0f) ? 0 : 1; - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[side].room; if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); this->resetBgCoverAlpha = true; } @@ -334,9 +334,9 @@ void EnHoll_VerticalInvisible(EnHoll* this, PlayState* play) { absYDistToPlayer > ENHOLL_V_INVISIBLE_LOAD_YDIST_MIN) { transitionActorIndex = GET_TRANSITION_ACTOR_INDEX(&this->actor); side = (this->actor.yDistToPlayer > 0.0f) ? 0 : 1; - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[side].room; if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); } } @@ -375,9 +375,9 @@ void EnHoll_HorizontalBgCoverSwitchFlag(EnHoll* this, PlayState* play) { if (orthogonalDistToPlayer < ENHOLL_H_SWITCHFLAG_LOAD_DEPTH) { s32 side = (relPlayerPos.z < 0.0f) ? 0 : 1; - this->actor.room = play->transiActorCtx.list[transitionActorIndex].sides[side].room; + this->actor.room = play->transitionActors.list[transitionActorIndex].sides[side].room; if (this->actor.room != play->roomCtx.curRoom.num && - func_8009728C(play, &play->roomCtx, this->actor.room)) { + Room_RequestNewRoom(play, &play->roomCtx, this->actor.room)) { EnHoll_SetupAction(this, EnHoll_WaitRoomLoaded); } } @@ -392,7 +392,7 @@ void EnHoll_HorizontalBgCoverSwitchFlag(EnHoll* this, PlayState* play) { void EnHoll_WaitRoomLoaded(EnHoll* this, PlayState* play) { if (!EnHoll_IsKokiriLayer8() && play->roomCtx.status == 0) { - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); if (play->bgCoverAlpha == 0) { this->resetBgCoverAlpha = false; } diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 63dc29fc14..802ed831ab 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -14,7 +14,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:162 gc-jp-ce:162 gc-jp-mq:162 gc-us:162 gc-us-mq:162" +#pragma increment_block_number "gc-eu:157 gc-eu-mq:157 gc-jp:159 gc-jp-ce:159 gc-jp-mq:159 gc-us:159 gc-us-mq:159" #define FLAGS ACTOR_FLAG_4 @@ -920,10 +920,10 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { sFishGameNumber = (HIGH_SCORE(HS_FISHING) & (HS_FISH_PLAYED * 255)) >> 0x10; if ((sFishGameNumber & 7) == 7) { - play->roomCtx.unk_74[0] = 90; + play->roomCtx.drawParams[0] = 90; sFishingFoggy = 1; } else { - play->roomCtx.unk_74[0] = 40; + play->roomCtx.drawParams[0] = 40; sFishingFoggy = 0; } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 9d800d3556..ca8bff100e 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -5008,7 +5008,7 @@ s32 Player_ActionChange_1(Player* this, PlayState* play) { if (slidingDoor->dyna.actor.category == ACTORCAT_DOOR) { this->cv.slidingDoorBgCamIndex = - play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(&slidingDoor->dyna.actor)] + play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(&slidingDoor->dyna.actor)] .sides[(doorDirection > 0) ? 0 : 1] .bgCamIndex; @@ -5091,7 +5091,7 @@ s32 Player_ActionChange_1(Player* this, PlayState* play) { } } else { Camera_ChangeDoorCam(Play_GetCamera(play, CAM_ID_MAIN), doorActor, - play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] + play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] .sides[(doorDirection > 0) ? 0 : 1] .bgCamIndex, 0, 38.0f * D_808535EC, 26.0f * D_808535EC, 10.0f * D_808535EC); @@ -5100,12 +5100,12 @@ s32 Player_ActionChange_1(Player* this, PlayState* play) { } if ((this->doorType != PLAYER_DOORTYPE_FAKE) && (doorActor->category == ACTORCAT_DOOR)) { - frontRoom = play->transiActorCtx.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] + frontRoom = play->transitionActors.list[GET_TRANSITION_ACTOR_INDEX(doorActor)] .sides[(doorDirection > 0) ? 0 : 1] .room; if ((frontRoom >= 0) && (frontRoom != play->roomCtx.curRoom.num)) { - func_8009728C(play, &play->roomCtx, frontRoom); + Room_RequestNewRoom(play, &play->roomCtx, frontRoom); } } @@ -9703,7 +9703,7 @@ void Player_Action_80845EF8(Player* this, PlayState* play) { } else { func_8083C0E8(this, play); if (play->roomCtx.prevRoom.num >= 0) { - func_80097534(play, &play->roomCtx); + Room_FinishRoomChange(play, &play->roomCtx); } Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); Play_SetupRespawnPoint(play, RESPAWN_MODE_DOWN, 0xDFF); diff --git a/tools/disasm/ntsc-1.2/functions.txt b/tools/disasm/ntsc-1.2/functions.txt index 612e83e537..9f2106cc3d 100644 --- a/tools/disasm/ntsc-1.2/functions.txt +++ b/tools/disasm/ntsc-1.2/functions.txt @@ -1595,12 +1595,12 @@ Room_DrawImageSingle = 0x800805E0; // type:func Room_GetImageMultiBgEntry = 0x80080990; // type:func Room_DrawImageMulti = 0x80080A7C; // type:func Room_DrawImage = 0x80080E48; // type:func -func_80096FD4 = 0x80080EB0; // type:func -func_80096FE8 = 0x80080EC8; // type:func -func_8009728C = 0x80081064; // type:func -func_800973FC = 0x800811CC; // type:func +Room_Init = 0x80080EB0; // type:func +Room_SetupFirstRoom = 0x80080EC8; // type:func +Room_RequestNewRoom = 0x80081064; // type:func +Room_ProcessRoomRequest = 0x800811CC; // type:func Room_Draw = 0x80081270; // type:func -func_80097534 = 0x800812C0; // type:func +Room_FinishRoomChange = 0x800812C0; // type:func Sample_HandleStateChange = 0x80081360; // type:func Sample_Draw = 0x80081394; // type:func Sample_Main = 0x80081580; // type:func @@ -1632,7 +1632,7 @@ Scene_CommandObjectList = 0x80082308; // type:func Scene_CommandLightList = 0x800824BC; // type:func Scene_CommandPathList = 0x8008256C; // type:func Scene_CommandTransitionActorEntryList = 0x800825B4; // type:func -TransitionActor_InitContext = 0x8008260C; // type:func +Scene_ResetTransitionActorList = 0x8008260C; // type:func Scene_CommandLightSettingsList = 0x8008261C; // type:func Scene_CommandSkyboxSettings = 0x80082674; // type:func Scene_CommandSkyboxDisables = 0x800826B8; // type:func