From 26e2692b9dd19241945c0748979e5aa6e1c97c2c Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 22 Jan 2024 19:39:50 -0500 Subject: [PATCH] d_s_play 99% --- include/d/d_com_inf_game.h | 39 ++++++++-- include/m_Do/m_Do_hostIO.h | 2 + src/d/actor/d_a_magma.cpp | 4 +- src/d/d_s_play.cpp | 143 +++++++++++++++++++++++++++++-------- 4 files changed, 148 insertions(+), 40 deletions(-) diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 2d1e1ecb4..df089e352 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -500,7 +500,9 @@ public: mCameraInfo[idx].mCamIdx = cam_idx; mCameraInfo[idx].field_0x06 = p5; } - // void setCameraAttentionStatus(u32 stts) { mCameraInfo[0].mCameraAttentionStatus = stts; ) + void setCameraAttentionStatus(int idx, u32 stts) { + mCameraInfo[idx].mCameraAttentionStatus = stts; + } void setCurrentGrafPort(J2DOrthoGraph* i_graf) { mCurrentGrafPort = i_graf; } void setCurrentWindow(dDlst_window_c* i_window) { mCurrentWindow = i_window; } void setCurrentView(view_class* i_view) { mCurrentView = i_view; } @@ -509,10 +511,10 @@ public: void setWindowNum(u8 num) { mDlstWindowNum = num; } dDlst_window_c * getWindow(int idx) { return &mDlstWindow[idx]; } void setWindow(int idx, f32 x, f32 y, f32 w, f32 h, f32 n, f32 f, int cameraID, int mode) { - getWindow(idx)->setViewPort(x, y, w, h, n, f); - getWindow(idx)->setScissor(x, y, w, h); - getWindow(idx)->setCameraID(cameraID); - getWindow(idx)->setMode(mode); + mDlstWindow[idx].setViewPort(x, y, w, h, n, f); + mDlstWindow[idx].setScissor(x, y, w, h); + mDlstWindow[idx].setCameraID(cameraID); + mDlstWindow[idx].setMode(mode); } J2DOrthoGraph* getCurrentGrafPort() { return mCurrentGrafPort; } @@ -1714,11 +1716,14 @@ inline u8 dComIfGs_checkFwaterTimer() { } void dComIfGs_setPlayerRecollectionData(); +void dComIfGs_revPlayerRecollectionData(); /** * === PLAY === */ +inline void dComIfGp_init() { g_dComIfG_gameInfo.play.init(); } + void dComIfGp_setNextStage(const char* i_stageName, s16 i_point, s8 i_roomNo, s8 i_layer = -1, f32 i_lastSpeed = 0.0f, u32 i_lastMode = 0, BOOL i_setPoint = TRUE, s8 i_wipe = 0); @@ -2008,6 +2013,7 @@ inline dDetect_c& dComIfGp_getDetect() { return g_dComIfG_gameInfo.play.getDetect(); } +inline dMagma_packet_c* dComIfGp_createMagma() { return g_dComIfG_gameInfo.play.createMagma(); } inline dGrass_packet_c* dComIfGp_createGrass() { return g_dComIfG_gameInfo.play.createGrass(); } inline dTree_packet_c* dComIfGp_createTree() { return g_dComIfG_gameInfo.play.createTree(); } inline dFlower_packet_c* dComIfGp_createFlower() { return g_dComIfG_gameInfo.play.createFlower(); } @@ -2031,6 +2037,12 @@ inline void dComIfGp_drawTree() { return g_dComIfG_gameInfo.play.drawTree(); } inline void dComIfGp_drawFlower() { return g_dComIfG_gameInfo.play.drawFlower(); } inline void dComIfGp_drawWood() { return g_dComIfG_gameInfo.play.drawWood(); } +inline void dComIfGp_removeMagma() { g_dComIfG_gameInfo.play.removeMagma(); } +inline void dComIfGp_removeGrass() { g_dComIfG_gameInfo.play.removeGrass(); } +inline void dComIfGp_removeTree() { g_dComIfG_gameInfo.play.removeTree(); } +inline void dComIfGp_removeWood() { g_dComIfG_gameInfo.play.removeWood(); } +inline void dComIfGp_removeFlower() { g_dComIfG_gameInfo.play.removeFlower(); } + inline void dComIfGp_map_mapBufferSendAGB(int param_0) { dMap_c::mapBufferSendAGB(param_0); } @@ -2055,6 +2067,10 @@ inline void dComIfGp_createDemo() { return g_dComIfG_gameInfo.play.createDemo(); } +inline void dComIfGp_removeDemo() { + return g_dComIfG_gameInfo.play.removeDemo(); +} + inline dDemo_manager_c* dComIfGp_demo_get() { return g_dComIfG_gameInfo.play.getDemo(); } @@ -2349,11 +2365,16 @@ inline void dComIfGp_plusMiniGameRupee(s16 count) { g_dComIfG_gameInfo.play.plusMiniGameRupee(count); } -inline void dComIfGp_setCameraInfo(int idx, camera_class* camera, int dlst, int cam, int p5) { g_dComIfG_gameInfo.play.setCameraInfo(idx, camera, dlst, cam, p5); } +inline void dComIfGp_setCameraInfo(int idx, camera_class* camera, int dlst, int cam, int p5) { + g_dComIfG_gameInfo.play.setCameraInfo(idx, camera, dlst, cam, p5); + g_dComIfG_gameInfo.play.setCameraAttentionStatus(0, 0); +} inline s32 dComIfGp_getWindowNum() { return g_dComIfG_gameInfo.play.getWindowNum(); } inline void dComIfGp_setWindowNum(u8 num) { g_dComIfG_gameInfo.play.setWindowNum(num); } inline dDlst_window_c * dComIfGp_getWindow(int idx) { return g_dComIfG_gameInfo.play.getWindow(idx); } -inline void dComIfGp_setWindow(int idx, f32 x, f32 y, f32 w, f32 h, f32 n, f32 f, int cameraID, int mode) { g_dComIfG_gameInfo.play.setWindow(idx, x, y, w, h, n, f, cameraID, mode); } +inline void dComIfGp_setWindow(int idx, f32 x, f32 y, f32 w, f32 h, f32 n, f32 f, int cameraID, int mode) { + g_dComIfG_gameInfo.play.setWindow(idx, x, y, w, h, n, f, cameraID, mode); +} inline J2DOrthoGraph* dComIfGp_getCurrentGrafPort() { return g_dComIfG_gameInfo.play.getCurrentGrafPort(); } inline void dComIfGp_setCurrentWindow(dDlst_window_c* window) { return g_dComIfG_gameInfo.play.setCurrentWindow(window); } inline void dComIfGp_setCurrentView(view_class* view) { return g_dComIfG_gameInfo.play.setCurrentView(view); } @@ -3099,6 +3120,10 @@ inline void dComIfGp_particle_removeRoomScene() { g_dComIfG_gameInfo.play.getParticle()->removeRoomScene(); } +inline void dComIfGp_particle_removeScene() { + g_dComIfG_gameInfo.play.getParticle()->removeScene(); +} + inline void dComIfGp_particle_swapFrameBufferTexture() { g_dComIfG_gameInfo.play.getParticle()->swapFrameBufferTexture(); } diff --git a/include/m_Do/m_Do_hostIO.h b/include/m_Do/m_Do_hostIO.h index bec68c711..25327571d 100644 --- a/include/m_Do/m_Do_hostIO.h +++ b/include/m_Do/m_Do_hostIO.h @@ -37,6 +37,8 @@ public: s8 createChild(const char*, JORReflexible*); void deleteChild(s8); + void updateChild(s8) {} + private: /* 0x4 */ mDoHIO_child_c mChild[64]; }; diff --git a/src/d/actor/d_a_magma.cpp b/src/d/actor/d_a_magma.cpp index 156220dc4..036a0e833 100644 --- a/src/d/actor/d_a_magma.cpp +++ b/src/d/actor/d_a_magma.cpp @@ -26,8 +26,8 @@ s32 daMagma_c::create() { return result; } - if (g_dComIfG_gameInfo.play.createMagma()) { - g_dComIfG_gameInfo.play.mpMagmaPacket->newFloor( + if (dComIfGp_createMagma()) { + dComIfGp_getMagma()->newFloor( current.pos, mScale, current.roomNo, diff --git a/src/d/d_s_play.cpp b/src/d/d_s_play.cpp index 84fd7516f..50f1b7c34 100644 --- a/src/d/d_s_play.cpp +++ b/src/d/d_s_play.cpp @@ -9,6 +9,7 @@ #include "JSystem/JUtility/JUTConsole.h" #include "JSystem/JUtility/JUTReport.h" #include "SSystem/SComponent/c_counter.h" +#include "c/c_dylink.h" #include "d/actor/d_a_dai.h" #include "d/actor/d_a_ib.h" #include "d/actor/d_a_npc_kg2.h" @@ -238,8 +239,8 @@ void dScnPly_msg_HIO_c::dScnPly_msg_HIO_padCheck() { } /* 80234AA8-80234B9C .text dScnPly_msg_HIO_messageProc__17dScnPly_msg_HIO_cFv */ -// NONMATCHING - regalloc void dScnPly_msg_HIO_c::dScnPly_msg_HIO_messageProc() { + /* Nonmatching - missing mGroup load */ dScnPly_msg_HIO_padCheck(); if (field_0x06) { @@ -283,7 +284,6 @@ static request_of_phase_process_class dylPhase[PRELOAD_DYL_MAX]; static dScnPly_preLoad_HIO_c g_preLoadHIO; /* 80234B9C-80234FD0 .text dScnPly_Draw__FP13dScnPly_ply_c */ -// NONMATCHING - close, just an issue with the wipe conditional int dScnPly_Draw(dScnPly_ply_c* i_this) { dComIfG_Ccsp()->Move(); dComIfG_Bgsp()->ClrMoveFlag(); @@ -302,22 +302,21 @@ int dScnPly_Draw(dScnPly_ply_c* i_this) { fopScnM_ChangeReq(i_this, PROC_PLAY_SCENE, l_wipeType[dComIfGp_getNextStageWipe()], 5); int hour = dKy_getdaytime_hour(); - bool useWhiteColor = false; + BOOL useWhiteColor = FALSE; if (dKy_checkEventNightStop()) { - useWhiteColor = true; + useWhiteColor = TRUE; } else { - useWhiteColor = (hour >= 6 && hour < 18) == 0; + useWhiteColor = (hour >= 6 && hour < 18) ? FALSE : TRUE; } - int wipe = dComIfGp_getNextStageWipe(); - if (wipe == 1 || wipe == 2 || wipe == 7 || - ((wipe == 8 || wipe == 10) && useWhiteColor) || - ((wipe == 9 || wipe == 11) && !useWhiteColor)) + if (dComIfGp_getNextStageWipe() == 1 || dComIfGp_getNextStageWipe() == 2 || dComIfGp_getNextStageWipe() == 7 || + ((dComIfGp_getNextStageWipe() == 8 || dComIfGp_getNextStageWipe() == 10) && useWhiteColor) || + ((dComIfGp_getNextStageWipe() == 9 || dComIfGp_getNextStageWipe() == 11) && !useWhiteColor)) { - mDoGph_gInf_c::setFadeColor(g_saftyWhiteColor); + mDoGph_gInf_c::setFadeColor(*(JUtility::TColor*)&g_saftyWhiteColor); // Fakematch? } else { - mDoGph_gInf_c::setFadeColor(g_blackColor); + mDoGph_gInf_c::setFadeColor(*(JUtility::TColor*)&g_blackColor); // Fakematch? } mDoAud_setSceneName(dComIfGp_getNextStageName(), dComIfGp_getNextStageRoomNo(), @@ -1058,13 +1057,73 @@ int dScnPly_IsDelete(dScnPly_ply_c* i_this) { return 1; } +static s8 preLoadNo = 0xFF; +static bool doPreLoad = true; + /* 802350BC-80235364 .text dScnPly_Delete__FP13dScnPly_ply_c */ -void dScnPly_Delete(dScnPly_ply_c* i_this) { - /* Nonmatching */ - OSReport("Xboss0"); - OSReport("Xboss1"); - OSReport("Xboss2"); - OSReport("Xboss3"); +BOOL dScnPly_Delete(dScnPly_ply_c* i_this) { + dComIfGp_getAttention().~dAttention_c(); + dComIfGp_getVibration().dVibration_c::~dVibration_c(); + dComIfG_Bgsp()->Dt(); + dComIfG_Ccsp()->Dt(); + dSnap_Delete(); + dStage_Delete(); + + dComIfGp_event_remove(); + dComIfGp_particle_removeScene(); + // dComIfGp_removeJcame(); // Debug only + // dComIfGp_removeJprev(); // Debug only + dComIfGp_removeDemo(); + dMat_control_c::remove(); + + fopMsgM_destroyExpHeap(dComIfGp_getExpHeap2D()); + + if (strcmp(dComIfGp_getStartStageName(), "Xboss0") == 0 || + strcmp(dComIfGp_getStartStageName(), "Xboss1") == 0 || + strcmp(dComIfGp_getStartStageName(), "Xboss2") == 0 || + strcmp(dComIfGp_getStartStageName(), "Xboss3") == 0 + ) { + dComIfGs_revPlayerRecollectionData(); + } + + dComIfGp_removeMagma(); + dComIfGp_removeGrass(); + dComIfGp_removeTree(); + dComIfGp_removeWood(); + dComIfGp_removeFlower(); + + g_dComIfG_gameInfo.play.mAirMeter = 0; // TODO inline + g_dComIfG_gameInfo.play.field_0x4928 = 0; // TODO inline + + g_msgDHIO.field_0x06 = 0; + g_msgDHIO.field_0x10 = -1; + mDoHIO_root.mDoHIO_deleteChild(g_darkHIO.mChildID); + mDoHIO_root.mDoHIO_deleteChild(g_envHIO.mChildID); + mDoHIO_root.mDoHIO_deleteChild(g_msgDHIO.mChildID); + + dComIfGp_setWindowNum(0); + + if (preLoadNo >= 0) { + const char** resName = PreLoadInfoT[preLoadNo].resName; + s32 resNameNum = PreLoadInfoT[preLoadNo].resNameNum; + if (resName != NULL && resName[0] != NULL) { + for (int i = 0; i < resNameNum; i++) { + dComIfG_resDelete(&resPhase[i], resName[i]); + } + } + + const s16* dylKeyTbl = PreLoadInfoT[preLoadNo].dylKeyTbl; + s32 dylKeyTblNum = PreLoadInfoT[preLoadNo].dylKeyTblNum; + if (dylKeyTbl != NULL && dylKeyTbl[0] != NULL) { + for (int i = 0; i < dylKeyTblNum; i++) { + cDylPhs::Unlink(&dylPhase[i], dylKeyTbl[i]); + } + } + } + + dComIfGp_init(); + + return TRUE; } /* 80235364-802355A8 .text heapSizeCheck__Fv */ @@ -1146,7 +1205,7 @@ static mDoDvdThd_mountXArchive_c* l_lkDemoAnmCommand; /* 802356E0-802357F4 .text phase_0__FP13dScnPly_ply_c */ s32 phase_0(dScnPly_ply_c* i_this) { - /* Nonmatching */ + /* Nonmatching - darcIdx type */ if (mDoAud_checkAllWaveLoadStatus()) { return cPhs_INIT_e; } else { @@ -1227,13 +1286,8 @@ int phase_3(dScnPly_ply_c* i_this) { return cPhs_NEXT_e; } -static s8 preLoadNo = 0xFF; -static bool doPreLoad = true; - /* 80235B0C-80236334 .text phase_4__FP13dScnPly_ply_c */ s32 phase_4(dScnPly_ply_c* i_this) { - /* Nonmatching */ - if (i_this->sceneCommand != NULL) { JUT_ASSERT(0xdef, i_this->sceneCommand->getMemAddress() != 0); dComIfGp_particle_createScene(i_this->sceneCommand->getMemAddress()); @@ -1254,7 +1308,6 @@ s32 phase_4(dScnPly_ply_c* i_this) { dComIfGp_setWindowNum(1); dComIfGp_setWindow(0, 0.0f, 0.0f, mDoMch_render_c::getFbWidth(), mDoMch_render_c::getEfbHeight(), 0.0f, 1.0f, 0, 2); dComIfGp_setCameraInfo(0, NULL, 0, 0, -1); - // setCameraAttentionStatus? dComIfGd_setWindow(NULL); dComIfGd_setViewport(NULL); dComIfGd_setView(NULL); @@ -1307,7 +1360,11 @@ s32 phase_4(dScnPly_ply_c* i_this) { dComIfGs_setItem(12, BOW); } - if (strcmp(dComIfGp_getStartStageName(), "Xboss0") == 0 || strcmp(dComIfGp_getStartStageName(), "Xboss1") == 0 || strcmp(dComIfGp_getStartStageName(), "Xboss2") == 0 || strcmp(dComIfGp_getStartStageName(), "Xboss3") == 0) { + if (strcmp(dComIfGp_getStartStageName(), "Xboss0") == 0 || + strcmp(dComIfGp_getStartStageName(), "Xboss1") == 0 || + strcmp(dComIfGp_getStartStageName(), "Xboss2") == 0 || + strcmp(dComIfGp_getStartStageName(), "Xboss3") == 0 + ) { dComIfGs_setPlayerRecollectionData(); } @@ -1360,10 +1417,22 @@ s32 phase_4(dScnPly_ply_c* i_this) { /* 80236334-80236444 .text phase_5__FP13dScnPly_ply_c */ s32 phase_5(dScnPly_ply_c* i_this) { - /* Nonmatching */ if (preLoadNo >= 0) { - u8 resNameNum = PreLoadInfoT[preLoadNo].resNameNum; - JUT_ASSERT(0, resNameNum <= (sizeof(resPhase) / sizeof(resPhase[0]))); + s32 rt = cPhs_NEXT_e; + const char** resName = PreLoadInfoT[preLoadNo].resName; + s32 resNameNum = PreLoadInfoT[preLoadNo].resNameNum; + if (resName != NULL && resName[0] != NULL) { + JUT_ASSERT(3824, resNameNum <= (sizeof(resPhase) / sizeof(resPhase[0]))); + for (int i = 0; i < resNameNum; i++) { + if (dComIfG_resLoad(&resPhase[i], resName[i]) != cPhs_COMPLEATE_e) { + rt = cPhs_INIT_e; + } + } + } + if (rt == cPhs_COMPLEATE_e) { + resPreLoadTime1 = OSGetTime(); + } + return rt; } else { return cPhs_NEXT_e; } @@ -1371,10 +1440,22 @@ s32 phase_5(dScnPly_ply_c* i_this) { /* 80236444-80236554 .text phase_6__FP13dScnPly_ply_c */ s32 phase_6(dScnPly_ply_c* i_this) { - /* Nonmatching */ if (preLoadNo >= 0) { - u8 dylKeyTblNum = PreLoadInfoT[preLoadNo].dylKeyTblNum; - JUT_ASSERT(0, dylKeyTblNum <= (sizeof(dylPhase) / sizeof(dylPhase[0]))); + s32 rt = cPhs_NEXT_e; + const s16* dylKeyTbl = PreLoadInfoT[preLoadNo].dylKeyTbl; + s32 dylKeyTblNum = PreLoadInfoT[preLoadNo].dylKeyTblNum; + if (dylKeyTbl != NULL && dylKeyTbl[0] != NULL) { + JUT_ASSERT(3858, dylKeyTblNum <= (sizeof(dylPhase) / sizeof(dylPhase[0]))); + for (int i = 0; i < dylKeyTblNum; i++) { + if (cDylPhs::Link(&dylPhase[i], dylKeyTbl[i]) != cPhs_COMPLEATE_e) { + rt = cPhs_INIT_e; + } + } + } + if (rt == cPhs_COMPLEATE_e) { + dylPreLoadTime1 = OSGetTime(); + } + return rt; } else { return cPhs_NEXT_e; }