From a507d8fc0ae4c1ec2cf86dc412efe2bf6fd4bac1 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Mar 2025 19:32:07 +0100 Subject: [PATCH] Repair some room damage --- config/SOUE01/symbols.txt | 4 ++-- include/d/d_bzs_types.h | 2 +- include/d/d_room.h | 9 ++++++-- src/d/d_room.cpp | 47 ++++++++++++++++++++++++++------------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index a6e63f0d..16f98324 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -11039,8 +11039,8 @@ execute__7dRoom_cFv = .text:0x801B6670; // type:function size:0x140 executeState__75sStateMgr_c<7dRoom_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801B67B0; // type:function size:0x10 draw__7dRoom_cFv = .text:0x801B67C0; // type:function size:0x84 getEntranceById__7dRoom_cCFUc = .text:0x801B6850; // type:function size:0x34 -fn_801B6890 = .text:0x801B6890; // type:function size:0x10 -RoomManager__getEVNTForIndex = .text:0x801B68A0; // type:function size:0x10 +getCamForIndex__7dRoom_cCFUl = .text:0x801B6890; // type:function size:0x10 +getEventForIndex__7dRoom_cCFUl = .text:0x801B68A0; // type:function size:0x10 deactivateUpdatesCb__FP9dAcBase_c = .text:0x801B68B0; // type:function size:0x20 deactivateUpdates__7dRoom_cFv = .text:0x801B68D0; // type:function size:0x54 activateUpdatesCb__FP9dAcBase_c = .text:0x801B6930; // type:function size:0x20 diff --git a/include/d/d_bzs_types.h b/include/d/d_bzs_types.h index 0ff841ba..23487956 100644 --- a/include/d/d_bzs_types.h +++ b/include/d/d_bzs_types.h @@ -55,7 +55,7 @@ struct EVNT { /* 0x11 */ u8 skipFlag; /* 0x12 */ u8 _0x12[2]; /* 0x14 */ u16 item; - /* 0x16 */ u16 _0x16[2]; + /* 0x16 */ u16 _0x16[1]; /* 0x18 */ char name[32]; }; diff --git a/include/d/d_room.h b/include/d/d_room.h index 233b8439..051532e8 100644 --- a/include/d/d_room.h +++ b/include/d/d_room.h @@ -27,6 +27,9 @@ struct DrawPriorityConfig { u8 pDrawOpa2; }; +#define ROOM_NUM_MODELS (8) +#define ROOM_NUM_BG (2) + class dRoom_c : public dBase_c { class mdl_c : public m3d::smdl_c { public: @@ -113,6 +116,8 @@ public: void drawOnMapIfVisible(mMtx_c *mtx, int param); void getBounds(mVec3_c *min, mVec3_c *max) const; const PLY *getEntranceById(u8 id) const; + const CAM *getCamForIndex(u32 idx) const; + const EVNT *getEventForIndex(u32 idx) const; void someLastBossThing(bool arg); f32 getFrame() const; @@ -194,8 +199,8 @@ private: /* 0x068 */ mHeapAllocator_c mAllocator; /* 0x084 */ nw4r::g3d::ResFile mRoomRes; /* 0x088 */ UnkWithWater mWaterThing; - /* 0x0A0 */ model_c mModels[8]; - /* 0x220 */ dBgWKCol mBg[2]; + /* 0x0A0 */ model_c mModels[ROOM_NUM_MODELS]; + /* 0x220 */ dBgWKCol mBg[ROOM_NUM_BG]; /* 0x4E0 */ STATE_MGR_DECLARE(dRoom_c); /* 0x51C */ const bzsFILE *mpFile; diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index 3bfd760f..359c4d32 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -10,6 +10,7 @@ #include "d/d_sc_game.h" #include "d/d_stage.h" #include "d/d_stage_mgr.h" +#include "d/d_stage_parse.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" #include "d/t/d_t_mass_obj.h" @@ -45,8 +46,6 @@ SPECIAL_BASE_PROFILE(ROOM, dRoom_c, fProfile::ROOM, 0x9, 96); STATE_DEFINE(dRoom_c, Active); STATE_DEFINE(dRoom_c, NonActive); -extern "C" void parseRoomBzs(int roomid, void *bzs); - int dRoom_c::create() { roomid = params & 0x3F; mCanHavePastState = dStageMgr_c::GetInstance()->getSTIFunk1() == 0 && @@ -69,7 +68,7 @@ int dRoom_c::create() { dStage_c::bindStageResToFile(&mRoomRes); dStage_c::bindSkyCmnToResFile(&mRoomRes); - for (s32 i = 0; i < ARRAY_LENGTH(mModels); i++) { + for (s32 i = 0; i < ROOM_NUM_MODELS; i++) { model_c *mdl = &mModels[i]; if (i != 2 || roomid != 1 || dScGame_c::currentSpawnInfo.layer != 14 || !dScGame_c::isCurrentStage("F406")) { if (!mdl->create(mRoomRes, mAllocator, i, &mWaterThing)) { @@ -144,7 +143,7 @@ int dRoom_c::execute() { } executeBg(); - for (s32 i = 0; i < ARRAY_LENGTH(mModels); i++) { + for (s32 i = 0; i < ROOM_NUM_MODELS; i++) { mModels[i].execute(i, mCanHavePastState, val); } @@ -155,12 +154,33 @@ int dRoom_c::draw() { if ((mFlags & 2) != 0 || mSkipDrawing) { return SUCCEEDED; } - for (s32 i = 0; i < ARRAY_LENGTH(mModels); i++) { + for (s32 i = 0; i < ROOM_NUM_MODELS; i++) { mModels[i].draw(roomid); } return SUCCEEDED; } +const PLY *dRoom_c::getEntranceById(u8 entranceId) const { + s32 i = mPlyCount; + const PLY *ply = mpPly; + while (i > 0) { + if (ply->entranceId == entranceId) { + return ply; + } + ply++; + i--; + } + return mpPly; +} + +const CAM *dRoom_c::getCamForIndex(u32 idx) const { + return &mpCam[idx]; +} + +const EVNT *dRoom_c::getEventForIndex(u32 idx) const { + return &mpEvnt[idx]; +} + void deactivateUpdatesCb(dAcBase_c *ac) { if (!ac->checkActorProperty(0x400)) { return; @@ -220,7 +240,7 @@ static const BgData sRoomBg[] = { }; bool dRoom_c::setupBg() { - for (int i = 0; i < ARRAY_LENGTH(mBg); i++) { + for (int i = 0; i < ROOM_NUM_BG; i++) { dBgWKCol *bg = &mBg[i]; void *kcl = CurrentStageArcManager::sInstance->getDataFromRoomArc(roomid, sRoomBg[i].kcl); if (kcl != nullptr) { @@ -245,7 +265,7 @@ bool dRoom_c::setupBg() { } void dRoom_c::executeBg() { - for (int i = 0; i < ARRAY_LENGTH(mBg); i++) { + for (int i = 0; i < ROOM_NUM_BG; i++) { if (!mBg[i].ChkNotReady()) { dBgS::GetInstance()->Regist(&mBg[i], (dAcObjBase_c *)nullptr); } @@ -281,7 +301,7 @@ void dRoom_c::drawOnMapIfVisible(mMtx_c *mtx, int param) { } void dRoom_c::getBounds(mVec3_c *min, mVec3_c *max) const { - for (int i = 0; i < ARRAY_LENGTH(mModels); i++) { + for (int i = 0; i < ROOM_NUM_MODELS; i++) { mVec3_c tMin, tMax; mModels[i].getBounds(&tMin, &tMax); if (i == 0) { @@ -301,13 +321,13 @@ void dRoom_c::formatObj(int obj, SizedString<8> &str) { void dRoom_c::updateObjNodeInEachRoom(int obj, bool visible) { SizedString<8> objName; formatObj(obj, objName); - for (int i = 0; i < ARRAY_LENGTH(mModels); i++) { + for (int i = 0; i < ROOM_NUM_MODELS; i++) { mModels[i].updateObjNode(objName, visible); } } void dRoom_c::destroyModels() { - for (int i = 0; i < ARRAY_LENGTH(mModels); i++) { + for (int i = 0; i < ROOM_NUM_MODELS; i++) { mModels[i].destroy(); } } @@ -329,15 +349,12 @@ f32 dRoom_c::getFrame() const { return mModels[0].getFrame(); } -extern "C" void fn_800641D0(int roomid, void *roomBzs); -extern "C" void fn_80064160(int roomid, void *roomBzs); - void dRoom_c::initializeState_Active() { SceneflagManager::sInstance->unsetZoneflagsForRoom(roomid); executeBg(); - fn_800641D0(roomid, BZS); + parseRoomActivateBzs(roomid, BZS); if (mDidAlreadyInit) { - fn_80064160(roomid, BZS); + parseRoomReactivateBzs(roomid, BZS); } else { mFlags |= 8 | 2; mDidAlreadyInit = true;