From 2763919899063fabcea26533ed1efbedae0c9702 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 25 Feb 2024 14:23:22 -0800 Subject: [PATCH] d_s_name work --- include/d/d_com_inf_game.h | 7 ++ include/d/d_file_select.h | 14 ++++ include/d/d_menu_cloth.h | 2 +- include/d/d_resorce.h | 4 + include/d/d_s_name.h | 25 ++++-- src/d/d_s_name.cpp | 158 ++++++++++++++++++++++++++++--------- 6 files changed, 164 insertions(+), 46 deletions(-) create mode 100644 include/d/d_file_select.h diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index d26084f93..bdde5d172 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -429,6 +429,7 @@ public: void setFmapResArchive(JKRArchive * pArc) { mpFmapResArchive = pArc; } void setDmapResArchive(JKRArchive * pArc) { mpDmapResArchive = pArc; } void setOptResArchive(JKRArchive * pArc) { mpOptResArchive = pArc; } + JKRArchive* getClothResArchive() { return mpClothResArchive; } void setClothResArchive(JKRArchive * pArc) { mpClothResArchive = pArc; } void setSaveResArchive(JKRArchive * pArc) { mpSaveResArchive = pArc; } void setItemIconArchive(JKRArchive * pArc) { mpItemIconArchive = pArc; } @@ -698,6 +699,7 @@ extern GXColor g_saftyWhiteColor; * === SAVE === */ +void dComIfGs_gameStart(); u8 dComIfGs_checkGetItem(u8); inline void dComIfGs_init() { @@ -2831,6 +2833,7 @@ inline void dComIfGp_setClctResArchive(JKRArchive * pArc) { g_dComIfG_gameInfo.p inline void dComIfGp_setFmapResArchive(JKRArchive * pArc) { g_dComIfG_gameInfo.play.setFmapResArchive(pArc); } inline void dComIfGp_setDmapResArchive(JKRArchive * pArc) { g_dComIfG_gameInfo.play.setDmapResArchive(pArc); } inline void dComIfGp_setOptResArchive(JKRArchive * pArc) { g_dComIfG_gameInfo.play.setOptResArchive(pArc); } +inline JKRArchive* dComIfGp_getClothResArchive() { return g_dComIfG_gameInfo.play.getClothResArchive(); } inline void dComIfGp_setClothResArchive(JKRArchive * pArc) { g_dComIfG_gameInfo.play.setClothResArchive(pArc); } inline void dComIfGp_setSaveResArchive(JKRArchive * pArc) { g_dComIfG_gameInfo.play.setSaveResArchive(pArc); } inline void dComIfGp_setItemIconArchive(JKRArchive * pArc) { g_dComIfG_gameInfo.play.setItemIconArchive(pArc); } @@ -2898,6 +2901,10 @@ inline void* dComIfG_getStageRes(const char* arcName, const char* resName) { return g_dComIfG_gameInfo.mResControl.getStageRes(arcName, resName); } +inline void* dComIfG_getStageRes(const char* arcName, int index) { + return g_dComIfG_gameInfo.mResControl.getStageRes(arcName, index); +} + inline void* dComIfG_getObjectRes(const char* arcName, const char* resName) { return g_dComIfG_gameInfo.mResControl.getObjectRes(arcName, resName); } diff --git a/include/d/d_file_select.h b/include/d/d_file_select.h new file mode 100644 index 000000000..2bce22204 --- /dev/null +++ b/include/d/d_file_select.h @@ -0,0 +1,14 @@ +#ifndef D_S_FILE_SELECT +#define D_S_FILE_SELECT + +#include "d/d_drawlist.h" + +class dFile_select_c : public dDlst_base_c { +public: + dFile_select_c(); + +private: + u32 field_0x00[100]; +}; + +#endif diff --git a/include/d/d_menu_cloth.h b/include/d/d_menu_cloth.h index a5b8cdd9c..92fd66375 100644 --- a/include/d/d_menu_cloth.h +++ b/include/d/d_menu_cloth.h @@ -18,7 +18,7 @@ public: void getPos() {} void getShadowPos() {} void getTexObj() {} - void setArchive(JKRArchive*) {} + void setArchive(JKRArchive* arc) {} void setClothType(unsigned char) {} void lightSet1(cXyz); diff --git a/include/d/d_resorce.h b/include/d/d_resorce.h index b36a1bb37..c09a89ca5 100644 --- a/include/d/d_resorce.h +++ b/include/d/d_resorce.h @@ -101,6 +101,10 @@ public: return getRes(arcName, resName, &mStageInfo[0], ARRAY_SIZE(mStageInfo)); } + void* getStageRes(const char* arcName, s32 index) { + return getRes(arcName, index, &mStageInfo[0], ARRAY_SIZE(mStageInfo)); + } + dRes_info_c* getObjectResInfo(const char* arcName) { return getResInfo(arcName, &mObjectInfo[0], ARRAY_SIZE(mObjectInfo)); } diff --git a/include/d/d_s_name.h b/include/d/d_s_name.h index d764887df..c1db73675 100644 --- a/include/d/d_s_name.h +++ b/include/d/d_s_name.h @@ -9,8 +9,8 @@ class J2DScreen; class JKRMemArchive; class dFile_error_c; class dFile_select_c; -class dMCloth; class dMenu_save_c; +class dMCloth_c; class dName_c; class mDoDvdThd_toMainRam_c; @@ -57,7 +57,7 @@ public: ~dDlst_FLSEL_CLOTH_c() {} void draw(); - /* 0x04 */ dMCloth* cloth_c; + /* 0x04 */ dMCloth_c* cloth_c; }; class dScnName_c : public scene_class { @@ -69,9 +69,9 @@ public: void cloth2D_create(); void buttonIconCreate(); void paneTransButtonIcon(s16, u8, f32, f32, u8); - s32 execute(); + BOOL execute(); void setView(); - s32 draw(); + BOOL draw(); void MemCardCheckMain(); void MemCardStatCheck(); void MemCardLoadWait(); @@ -120,7 +120,7 @@ public: /* 0x1C4 */ request_of_phase_process_class mPhs; /* 0x1CC */ JKRHeap* heap; - /* 0x1D0 */ JKRHeap* field_0x1d0; + /* 0x1D0 */ JKRHeap* oldHeap; /* 0x1D4 */ u8 field_0x1d4[0x29C - 0x1D4]; /* 0x29C */ f32 field_0x29c; /* 0x2A0 */ f32 field_0x2a0; @@ -137,7 +137,7 @@ public: /* 0x3A4 */ u8 field_0x3a4[0x3B4 - 0x3A4]; /* 0x3B4 */ Mtx field_0x3b4; /* 0x3E4 */ u8 field_0x3e4[0x40C - 0x3E4]; - /* 0x40C */ JKRMemArchive* field_0x40c; + /* 0x40C */ JKRMemArchive* mArchive; /* 0x410 */ mDoDvdThd_toMainRam_c* field_0x410; /* 0x414 */ dDlst_BTICN_c btnIcon; /* 0x41C */ dDlst_FLSEL_CLOTH_c cloth; @@ -151,7 +151,18 @@ public: /* 0x4AC */ fopMsgM_pane_class field_0x4ac; /* 0x4E4 */ fopMsgM_pane_class field_0x4e4; /* 0x41C */ fopMsgM_pane_class field_0x51c; - /* 0x554 */ u8 field_0x554[0x560 - 0x554]; + /* 0x554 */ u8 mMainProc; + /* 0x555 */ u8 field_0x555; + /* 0x556 */ u8 field_0x556; + /* 0x557 */ u8 mDrawProc; + /* 0x558 */ u8 field_0x558; + /* 0x559 */ u8 field_0x559; + /* 0x55A */ u8 field_0x55a; + /* 0x55B */ u8 field_0x55b; + /* 0x55C */ u8 field_0x55c; + /* 0x55D */ u8 field_0x55d; + /* 0x55E */ u8 field_0x55e; + /* 0x55F */ u8 field_0x55f; /* 0x560 */ u8 field_0x560[0x1650]; /* 0x1BB0 */ void* savePicDatabuf; /* 0x1BB4 */ short field_0x1bb4; diff --git a/src/d/d_s_name.cpp b/src/d/d_s_name.cpp index 67ae4e274..c9f85fe5c 100644 --- a/src/d/d_s_name.cpp +++ b/src/d/d_s_name.cpp @@ -4,49 +4,70 @@ // #include "d/d_s_name.h" +#include "d/d_com_inf_game.h" #include "d/d_com_lib_game.h" +#include "d/d_file_select.h" #include "d/d_procname.h" -#include "new.h" +#include "d/d_menu_cloth.h" +#include "f_op/f_op_draw_iter.h" +#include "f_op/f_op_overlap_mng.h" +#include "f_op/f_op_scene_mng.h" +#include "m_Do/m_Do_audio.h" +#include "m_Do/m_Do_Reset.h" +#include "JSystem/J2DGraph/J2DOrthoGraph.h" +#include "JSystem/J2DGraph/J2DScreen.h" +#include "JSystem/JKernel/JKRExpHeap.h" static Vec lit_2100 = {1.0f, 1.0f, 1.0f}; static Vec lit_2080 = {1.0f, 1.0f, 1.0f}; +class dFile_error_c { +public: + void _move(); +}; + dSn_HIO_c g_snHIO; /* 8022F86C-8022F8F0 .text __ct__9dSn_HIO_cFv */ dSn_HIO_c::dSn_HIO_c() { - this->field_0x5 = 20; - this->field_0x6 = 15; - this->field_0x7 = 30; - this->field_0x8 = 0; - this->field_0x9 = 0; - this->field_0xa = 0; - this->field_0xb = 0; - this->field_0xe = 7; - this->field_0xc = -200; - this->field_0xf = 2; - this->field_0x10 = 0; - this->field_0x11 = 0; - this->field_0x12 = 0; - this->field_0x13 = 0; - this->field_0x14 = 0; - this->field_0x15 = 0; - this->field_0x16 = 0; - this->field_0x17 = 0; - this->field_0x18 = 0; - this->field_0x19 = 0; - this->field_0x1a = 0; - this->field_0x1b = 0; + field_0x5 = 20; + field_0x6 = 15; + field_0x7 = 30; + field_0x8 = 0; + field_0x9 = 0; + field_0xa = 0; + field_0xb = 0; + field_0xe = 7; + field_0xc = -200; + field_0xf = 2; + field_0x10 = 0; + field_0x11 = 0; + field_0x12 = 0; + field_0x13 = 0; + field_0x14 = 0; + field_0x15 = 0; + field_0x16 = 0; + field_0x17 = 0; + field_0x18 = 0; + field_0x19 = 0; + field_0x1a = 0; + field_0x1b = 0; } /* 8022F8F0-8022F95C .text phase_1__FPc */ -static void phase_1(char*) { - /* Nonmatching */ +static s32 phase_1(char* resName) { + mDoAud_bgmStart(JA_BGM_SELECT); + return !dComIfG_setStageRes(resName, NULL) ? cPhs_ERROR_e : cPhs_NEXT_e; } /* 8022F95C-8022F9B4 .text phase_2__FPc */ -static void phase_2(char*) { - /* Nonmatching */ +static s32 phase_2(char* resName) { + s32 rt = dComIfG_syncStageRes(resName); + if (rt < 0) + return cPhs_ERROR_e; + else if (rt > 0) + return cPhs_INIT_e; + return cPhs_NEXT_e; } /* 8022F9B4-8022F9BC .text phase_3__FPc */ @@ -55,36 +76,61 @@ static s32 phase_3(char*) { } /* 8022F9BC-8022F9FC .text resLoad__FP30request_of_phase_process_classPc */ -s32 resLoad(request_of_phase_process_class* param_1, char* param_2) { +s32 resLoad(request_of_phase_process_class* phase, char* resName) { static cPhs__Handler l_method[] = { (cPhs__Handler)phase_1, (cPhs__Handler)phase_2, (cPhs__Handler)phase_3, }; - if (param_1->id == 2) { + if (phase->id == 2) { return cPhs_COMPLEATE_e; } - return dComLbG_PhaseHandler(param_1, l_method, param_2); + return dComLbG_PhaseHandler(phase, l_method, resName); } /* 8022F9FC-802301C8 .text create__10dScnName_cFv */ s32 dScnName_c::create() { /* Nonmatching */ + dComIfGp_offEnableNextStage(); + dComIfGp_setNextStage("Name", 0, 0); + dComIfGp_setStartStage(dComIfGp_getNextStartStage()); + dComIfGp_offEnableNextStage(); + + s32 rt = resLoad(&mPhs, "Stage"); + if (rt == cPhs_COMPLEATE_e) { + heap = JKRCreateExpHeap(0x68000, mDoExt_getGameHeap(), false); + JUT_ASSERT(0x1c8, heap != 0); + } + + oldHeap = mDoExt_setCurrentHeap(heap); + mArchive = new JKRMemArchive(); + mArchive->mountFixed(dComIfG_getStageRes("Stage", 0x17), JKRMEMBREAK_FLAG_UNKNOWN0); + cloth_create(); + buttonIconCreate(); + dFs_c = new dFile_select_c(); } /* 802301C8-802301FC .text cloth_create__10dScnName_cFv */ void dScnName_c::cloth_create() { - /* Nonmatching */ + cloth2D_create(); + field_0x55d = 0; } /* 802301FC-80230240 .text cloth_move__10dScnName_cFv */ void dScnName_c::cloth_move() { /* Nonmatching */ + if (field_0x55d && !g_snHIO.field_0xb) + cloth.cloth_c->cloth_move(); } /* 80230240-802302F8 .text cloth2D_create__10dScnName_cFv */ void dScnName_c::cloth2D_create() { /* Nonmatching */ + JKRArchive* clothRes = dComIfGp_getClothResArchive(); + cloth.cloth_c = new dMCloth_c(); + JUT_ASSERT(0x321, cloth.cloth_c != 0); + cloth.cloth_c->setArchive(clothRes); + cloth.cloth_c->setClothType(1); // ? } /* 802302F8-80230500 .text buttonIconCreate__10dScnName_cFv */ @@ -155,8 +201,20 @@ void (dScnName_c::*DrawProc[])() = { }; /* 802305E0-80230678 .text execute__10dScnName_cFv */ -s32 dScnName_c::execute() { +BOOL dScnName_c::execute() { /* Nonmatching */ + if (!fopOvlpM_IsPeek()) + dComIfG_resetToOpening(this); + + if (mDoRst::isReset()) + return TRUE; + cloth_move(); + + if (dFe_c != NULL) + dFe_c->_move(); + (this->*(MainProc[mMainProc]))(); + buttonIconProc(); + return TRUE; } /* 80230678-80230714 .text setView__10dScnName_cFv */ @@ -165,8 +223,16 @@ void dScnName_c::setView() { } /* 80230714-802307EC .text draw__10dScnName_cFv */ -s32 dScnName_c::draw() { - /* Nonmatching */ +BOOL dScnName_c::draw() { + setView(); + for (create_tag_class* pTag = fopDwIt_Begin(); pTag != NULL; pTag = fopDwIt_Next(pTag)) + fpcM_Draw(pTag->mpTagData); + if (field_0x55d && !g_snHIO.field_0xb) { + dComIfGd_set2DOpa(&cloth); + } + (this->*(DrawProc[mDrawProc]))(); + dComIfGd_set2DOpa(&btnIcon); + return TRUE; } /* 802307EC-80230A14 .text __dt__10dScnName_cFv */ @@ -312,7 +378,11 @@ void dScnName_c::FileSelectMainExSave() { /* 80231D00-80231D28 .text ResetWait__10dScnName_cFv */ void dScnName_c::ResetWait() { - /* Nonmatching */ + if (field_0x558) { + field_0x558--; + return; + } + mDoRst::onReset(); } /* 80231D28-80231E9C .text FileSelectClose__10dScnName_cFv */ @@ -384,11 +454,21 @@ void dScnName_c::SaveDraw() { } /* 8023229C-802322A0 .text NoneDraw__10dScnName_cFv */ -void dScnName_c::NoneDraw() {} +void dScnName_c::NoneDraw() { +} /* 802322A0-80232338 .text changeGameScene__10dScnName_cFv */ void dScnName_c::changeGameScene() { - /* Nonmatching */ + if (fopOvlpM_IsPeek()) + return; + + dComIfGs_gameStart(); + u32 procName = field_0x55f ? PROC_OPEN_SCENE : PROC_PLAY_SCENE; + if (fopScnM_ChangeReq(this, procName, 0, 5)) { + g_dComIfG_gameInfo.save.getDan().mStageNo = -1; + dComIfGs_setRestartRoomParam(0); + mDoAud_setSceneName(dComIfGp_getNextStageName(), dComIfGp_getNextStageRoomNo(), dComIfGp_getNextStageLayer()); + } } /* 80232338-80232358 .text dScnName_Draw__FP10dScnName_c */ @@ -420,7 +500,9 @@ s32 dScnName_Create(scene_class* i_scn) { /* 802323F8-8023245C .text draw__13dDlst_BTICN_cFv */ void dDlst_BTICN_c::draw() { - /* Nonmatching */ + J2DOrthoGraph* graf = dComIfGp_getCurrentGrafPort(); + graf->setPort(); + scr->draw(0.0f, 0.0f, graf); } /* 8023245C-80232518 .text draw__19dDlst_FLSEL_CLOTH_cFv */