diff --git a/include/JSystem/J2DGraph/J2DPane.h b/include/JSystem/J2DGraph/J2DPane.h index 00deb40fe..0b6f3bf1f 100644 --- a/include/JSystem/J2DGraph/J2DPane.h +++ b/include/JSystem/J2DGraph/J2DPane.h @@ -69,6 +69,8 @@ public: u8 getAlpha() const { return mAlpha; } void setAlpha(u8 alpha) { mAlpha = alpha; } bool isConnectParent() const { return mIsConnectParent; } + void show() { mVisible = true; } + void hide() { mVisible = false; } public: /* 0x04 */ u32 mMagic; diff --git a/include/JSystem/J2DGraph/J2DScreen.h b/include/JSystem/J2DGraph/J2DScreen.h index 0e041e67a..44713a73b 100644 --- a/include/JSystem/J2DGraph/J2DScreen.h +++ b/include/JSystem/J2DGraph/J2DScreen.h @@ -9,6 +9,12 @@ class JKRArchive; class J2DScreen : public J2DPane { public: + J2DScreen(J2DPane* parent, bool visible, u32 tag, const JGeometry::TBox2& bounds) + : J2DPane(parent, visible, tag, bounds) + , mColor() + , mbClipToParent(false) + {} + virtual ~J2DScreen(); virtual u16 getTypeID() { return 0x08; } virtual void calcMtx() { makeMatrix(mBounds.i.x, mBounds.i.y); } @@ -16,10 +22,11 @@ public: virtual J2DPane* search(u32 tag); virtual J2DPane* createPane(J2DPane::J2DScrnBlockHeader const & header, JSURandomInputStream * pStream, J2DPane * pParent); -protected: void draw(f32 x, f32 y, const J2DGrafContext * pCtx); bool set(const char *pName, JKRArchive * pArc); bool set(JSURandomInputStream * pStream); + +protected: s32 makeHierarchyPanes(J2DPane * pParent, JSURandomInputStream * pStream); bool checkSignature(JSURandomInputStream * pStream); bool getScreenInformation(JSURandomInputStream * pStream); diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index e551580cd..633cc79a8 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -385,6 +385,8 @@ public: void setCurrentView(view_class* i_view) { mCurrentView = i_view; } void setCurrentViewport(view_port_class* i_viewport) { mCurrentViewport = i_viewport; } + J2DOrthoGraph* getCurrentGrafPort() { return mCurrentGrafPort; } + void setMsgArchive(JKRArchive * pArc) { mpMsgArchive = pArc; } void setDmsgArchive(JKRArchive * pArc) { mpDmsgArchive = pArc; } void setTmsgArchive(JKRArchive * pArc) { mpTmsgArchive = pArc; } @@ -552,7 +554,7 @@ public: /* 0x4955 */ u8 field_0x4955; /* 0x4956 */ u8 field_0x4956; /* 0x4957 */ u8 mPlacenameIndex; - /* 0x4958 */ u8 field_0x4958; + /* 0x4958 */ u8 mPlacenameState; /* 0x4959 */ u8 field_0x4959; /* 0x495A */ u8 field_0x495a; /* 0x495B */ u8 field_0x495b; @@ -1081,6 +1083,10 @@ inline const char* dComIfGp_getStartStageName() { return g_dComIfG_gameInfo.play.getStartStageName(); } +inline u32 dComIfGp_getNowStageNum() { + return g_dComIfG_gameInfo.play.mPlacenameIndex; +} + inline s8 dComIfGp_getStartStageRoomNo() { return g_dComIfG_gameInfo.play.getStartStageRoomNo(); } @@ -1517,6 +1523,10 @@ inline dADM_CharTbl* dComIfGp_CharTbl() { return &g_dComIfG_gameInfo.play.mADM.mCharTbl; } +inline J2DOrthoGraph* dComIfGp_getCurrentGrafPort() { + return g_dComIfG_gameInfo.play.getCurrentGrafPort(); +} + /** * === EVENT ===*/ @@ -1915,6 +1925,10 @@ inline void* dComIfG_getObjectIDRes(const char* arcName, u16 id) { return g_dComIfG_gameInfo.mResControl.getObjectIDRes(arcName, id); } +inline dRes_info_c* dComIfG_getObjectResInfo(const char* arcName) { + return g_dComIfG_gameInfo.mResControl.getObjectResInfo(arcName); +} + /** * === PARTICLE === */ diff --git a/include/d/d_drawlist.h b/include/d/d_drawlist.h index e8492e9c4..ef0db4482 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -13,7 +13,7 @@ class cM3dGPla; class dDlst_base_c { public: dDlst_base_c() {} - virtual ~dDlst_base_c(); + virtual ~dDlst_base_c() {} virtual void draw(); }; diff --git a/include/f_op/f_op_msg.h b/include/f_op/f_op_msg.h index f792aaa71..47ed2a070 100644 --- a/include/f_op/f_op_msg.h +++ b/include/f_op/f_op_msg.h @@ -6,11 +6,15 @@ class fopAc_ac_c; +struct msg_method_class { + /* 0x00 */ leafdraw_method_class base; +}; + class msg_class : public leafdraw_class { public: /* 0xC0 */ int mMsgType; /* 0xC4 */ create_tag_class mDwTg; - /* 0xD8 */ leafdraw_method_class* mSubMtd; + /* 0xD8 */ msg_method_class* mSubMtd; /* 0xDC */ fopAc_ac_c* mpActor; /* 0xE0 */ cXyz mPos; /* 0xEC */ u32 mMsgID; diff --git a/include/f_op/f_op_msg_mng.h b/include/f_op/f_op_msg_mng.h index 77f584b3f..d6dcdf1bc 100644 --- a/include/f_op/f_op_msg_mng.h +++ b/include/f_op/f_op_msg_mng.h @@ -12,7 +12,7 @@ class msg_class; struct msg_process_profile_definition { /* 0x00 */ leaf_process_profile_definition mBase; - /* 0x24 */ leafdraw_method_class* mSubMtd; // Subclass methods + /* 0x24 */ msg_method_class* mSubMtd; // Subclass methods }; struct fopMsg_prm_class { @@ -39,12 +39,26 @@ struct fopMsg_prm_timer { /* 0x34 */ f32 field_0x34; }; // Size: 0x38 +class J2DScreen; + +struct fopMsgM_pane_class { + /* 0x00 */ J2DScreen * scrn; + /* 0x04 */ cXy mPosTopLeftOrig; + /* 0x0C */ cXy mPosTopLeft; + /* 0x14 */ cXy mPosCenterOrig; + /* 0x1C */ cXy mPosCenter; + /* 0x24 */ cXy mSizeOrig; + /* 0x2C */ cXy mSize; + /* 0x34 */ u8 mAlphaOrig; + /* 0x35 */ u8 mAlpha; + /* 0x36 */ s16 mUserArea; +}; + typedef int (*fopMsgCreateFunc)(void*); JKRExpHeap* fopMsgM_createExpHeap(u32, JKRHeap*); u32 fopMsgM_Create(s16, fopMsgCreateFunc, void*); -s32 fopMsgM_create(s16 param_0, fopAc_ac_c* param_1, cXyz* param_2, u32* param_3, u32* param_4, - fopMsgCreateFunc createFunc); +s32 fopMsgM_create(s16 param_0, fopAc_ac_c* param_1, cXyz* param_2, u32* param_3, u32* param_4, fopMsgCreateFunc createFunc); void fopMsgM_Delete(void* process); fopMsg_prm_class* fopMsgM_GetAppend(void* msg); void fopMsgM_setMessageID(unsigned int); @@ -66,6 +80,10 @@ inline s32 fopMsgM_Timer_create(s16 param_0, u8 param_1, u32 param_2, u8 param_3 param_8, createFunc); } +void fopMsgM_setPaneData(fopMsgM_pane_class*, J2DScreen*, unsigned long); +void fopMsgM_setNowAlpha(fopMsgM_pane_class*, f32); +void fopMsgM_setAlpha(fopMsgM_pane_class*); + u32 fopMsgM_searchMessageNumber(u32); void fopMsgM_messageSendOn(); diff --git a/src/d/d_kyeff.cpp b/src/d/d_kyeff.cpp index 64e4102d3..fe1c742be 100644 --- a/src/d/d_kyeff.cpp +++ b/src/d/d_kyeff.cpp @@ -49,6 +49,8 @@ s16 s16_data_ratio_set(s16 param_0, s16 param_1, f32 param_2) { /* 8019808C-8019847C .text menu_vrbox_set__Fv */ void menu_vrbox_set() { /* Nonmatching - regalloc. */ + f32 blendPalAB, curTime; + camera_class * pCamera = dComIfGp_getCamera(0); pCamera->mLookat.mEye.x = 9377.0f; @@ -59,7 +61,7 @@ void menu_vrbox_set() { pCamera->mLookat.mCenter.z = 1000.0f; g_env_light.mWind.mWindPower = 0.7f; - f32 curTime = g_env_light.mCurTime; + curTime = g_env_light.mCurTime; g_env_light.mCurTime += 0.03f; if ((u32)g_env_light.mCurTime >= 360.0f) @@ -70,8 +72,7 @@ void menu_vrbox_set() { g_env_light.mpSchejule = dKyd_schejule_menu_getp(); - u8 palIdx0, palIdx1; - f32 blendPalAB; + u8 palIdx1, palIdx0; for (s32 i = 0; i < 11; i++) { if (curTime >= g_env_light.mpSchejule[i].mTimeEnd && curTime <= g_env_light.mpSchejule[i].mTimeBegin) { palIdx0 = g_env_light.mpSchejule[i].mPalIdx0; @@ -83,8 +84,8 @@ void menu_vrbox_set() { stage_vrbox_info_class* vrbox = dKyd_dmvrbox_getp(); g_env_light.mpVrboxInfo = vrbox; - stage_vrbox_info_class* vrbox0 = &vrbox[palIdx0]; - stage_vrbox_info_class* vrbox1 = &vrbox[palIdx1]; + stage_vrbox_info_class* vrbox0 = &vrbox[palIdx0]; + stage_vrbox_info_class* vrbox1 = &vrbox[palIdx1]; g_env_light.mVrSkyColor.r = s16_data_ratio_set(vrbox0->mSkyColor.r, vrbox1->mSkyColor.r, blendPalAB); g_env_light.mVrSkyColor.g = s16_data_ratio_set(vrbox0->mSkyColor.g, vrbox1->mSkyColor.g, blendPalAB); g_env_light.mVrSkyColor.b = s16_data_ratio_set(vrbox0->mSkyColor.b, vrbox1->mSkyColor.b, blendPalAB); diff --git a/src/d/d_place_name.cpp b/src/d/d_place_name.cpp index 0c837bc5e..15ad283d1 100644 --- a/src/d/d_place_name.cpp +++ b/src/d/d_place_name.cpp @@ -3,76 +3,250 @@ // Translation Unit: d_place_name.cpp // -#include "d_place_name.h" -#include "dolphin/types.h" +#include "f_op/f_op_msg.h" +#include "f_op/f_op_msg_mng.h" +#include "d/d_com_inf_game.h" +#include "d/d_drawlist.h" +#include "d/d_meter.h" +#include "d/d_procname.h" +#include "m_Do/m_Do_dvd_thread.h" +#include "m_Do/m_Do_ext.h" +#include "JSystem/JKernel/JKRArchive.h" +#include "JSystem/JKernel/JKRExpHeap.h" +#include "JSystem/J2DGraph/J2DOrthoGraph.h" +#include "JSystem/J2DGraph/J2DPane.h" +#include "JSystem/J2DGraph/J2DScreen.h" + +enum { dPn_stage_max_e = 19 }; + +const char * name_texture[] = { + "/res/placename/pn_01.bti", + "/res/placename/pn_02.bti", + "/res/placename/pn_03.bti", + "/res/placename/pn_04.bti", + "/res/placename/pn_05.bti", + "/res/placename/pn_06.bti", + "/res/placename/pn_07.bti", + "/res/placename/pn_08.bti", + "/res/placename/pn_09.bti", + "/res/placename/pn_10.bti", + "/res/placename/pn_11.bti", + "/res/placename/pn_12.bti", + "/res/placename/pn_13.bti", + "/res/placename/pn_14.bti", + "/res/placename/pn_15.bti", + "/res/placename/pn_16.bti", + "/res/placename/pn_17.bti", + "/res/placename/pn_18.bti", + "/res/placename/pn_19.bti", +}; + +class dPlace_name_c : public dDlst_base_c { +public: + ~dPlace_name_c() {} + void setScreen(const char*, JKRArchive*); + BOOL _openAnime(); + BOOL _closeAnime(); + virtual void draw(); + +public: + /* 0x04 */ J2DScreen * scrn; + /* 0x08 */ fopMsgM_pane_class pane; +}; + +class dPn_c : public msg_class { +public: + s32 _create(); + BOOL _execute(); + BOOL _draw(); + BOOL _delete(); + +public: + /* 0x0FC */ JKRExpHeap * mpHeap; + /* 0x100 */ request_of_phase_process_class mPhs; + /* 0x108 */ dPlace_name_c * dPn_scrn; + /* 0x11C */ mDoDvdThd_toMainRam_c * dvd; + /* 0x114 */ ResTIMG * mpTIMG; + /* 0x118 */ u8 mState; + /* 0x119 */ u8 pad[3]; +}; /* 80160F60-801610A8 .text setScreen__13dPlace_name_cFPCcP10JKRArchive */ -void dPlace_name_c::setScreen(const char*, JKRArchive*) { - /* Nonmatching */ +void dPlace_name_c::setScreen(const char* name, JKRArchive* arc) { + scrn = new J2DScreen(NULL, true, 0x726F6F74, JGeometry::TBox2(0.0f, 0.0f, 640.0f, 480.0f)); + JUT_ASSERT(0x5b, scrn != 0); + + scrn->set(name, arc); + fopMsgM_setPaneData(&pane, scrn, 0x706e); + + scrn->search('blc1')->hide(); + scrn->search('blc2')->hide(); } /* 801610A8-80161100 .text _openAnime__13dPlace_name_cFv */ -void dPlace_name_c::_openAnime() { - /* Nonmatching */ +BOOL dPlace_name_c::_openAnime() { + if (pane.mUserArea < 10) { + pane.mUserArea++; + f32 alpha = fopMsgM_valueIncrease(10, pane.mUserArea, 0); + fopMsgM_setNowAlpha(&pane, alpha); + } + + return TRUE; } /* 80161100-80161174 .text _closeAnime__13dPlace_name_cFv */ -void dPlace_name_c::_closeAnime() { - /* Nonmatching */ +BOOL dPlace_name_c::_closeAnime() { + BOOL ret = FALSE; + + if (pane.mUserArea > 0) { + pane.mUserArea--; + f32 alpha = fopMsgM_valueIncrease(10, pane.mUserArea, 0); + fopMsgM_setNowAlpha(&pane, alpha); + } + + if (pane.mUserArea <= 0) + ret = TRUE; + + return ret; } /* 80161174-801611E0 .text draw__13dPlace_name_cFv */ void dPlace_name_c::draw() { - /* Nonmatching */ + fopMsgM_setAlpha(&pane); + J2DOrthoGraph * graf = dComIfGp_getCurrentGrafPort(); + graf->setPort(); + scrn->draw(0.0f, 0.0f, graf); } /* 801611E0-801614E8 .text _create__5dPn_cFv */ -void dPn_c::_create() { - /* Nonmatching */ +s32 dPn_c::_create() { + s32 rt = dComIfG_resLoad(&mPhs, "PName"); + + if (dMenu_flag() || g_dComIfG_gameInfo.play.field_0x4962 != 0 || g_dComIfG_gameInfo.play.field_0x4962 != 11 || g_dComIfG_gameInfo.play.field_0x492a != 0) + return; + + if (mState == 0) { + if (rt != cPhs_COMPLEATE_e) + return rt; + + dRes_info_c * resInfo = dComIfG_getObjectResInfo("PName"); + JUT_ASSERT(0xa9, resInfo != 0); + + mpHeap = g_dComIfG_gameInfo.play.field_0x497c; + g_dComIfG_gameInfo.play.field_0x4962 = 10; + JKRHeap * oldHeap = mDoExt_setCurrentHeap(mpHeap); + dPn_scrn = new dPlace_name_c(); + JUT_ASSERT(0xb1, dPn_scrn != 0); + dPn_scrn->setScreen("place_name.blo", resInfo->getArchive()); + mpTIMG = (ResTIMG*)mpHeap->alloc(0x3c00, 0x20); + mDoExt_setCurrentHeap(oldHeap); + mState = 1; + dvd = NULL; + if (dComIfGp_getNowStageNum() != 0) + return cPhs_INIT_e; + } else if (mState == 1) { + JKRHeap * oldHeap = mDoExt_setCurrentHeap(mpHeap); + JUT_ASSERT(0xc9, dComIfGp_getNowStageNum() < dPn_stage_max_e); + + dvd = mDoDvdThd_toMainRam_c::create(name_texture[dComIfGp_getNowStageNum()], 0, mpHeap); + mState = 2; + mDoExt_setCurrentHeap(oldHeap); + return cPhs_INIT_e; + } else { + JKRHeap * oldHeap = mDoExt_setCurrentHeap(mpHeap); + if (dvd->sync()) { + memcpy(mpTIMG, dvd->getMemAddress(), 0x3c00); + DCStoreRangeNoSync(mpTIMG, 0x3c00); + ((J2DPicture*)dPn_scrn->pane.scrn)->changeTexture(mpTIMG, 0); + mState = 3; + } + mDoExt_setCurrentHeap(oldHeap); + + if (mState != 3) + return cPhs_INIT_e; + } + + return cPhs_COMPLEATE_e; } /* 801614E8-80161554 .text _execute__5dPn_cFv */ -void dPn_c::_execute() { - /* Nonmatching */ +BOOL dPn_c::_execute() { + if (g_dComIfG_gameInfo.play.mPlacenameState == 2) { + dPn_scrn->_openAnime(); + } else if (g_dComIfG_gameInfo.play.mPlacenameState == 1) { + if (dPn_scrn->_closeAnime()) + fopMsgM_Delete(this); + } + + return TRUE; } /* 80161554-80161594 .text _draw__5dPn_cFv */ -void dPn_c::_draw() { - /* Nonmatching */ +BOOL dPn_c::_draw() { + dComIfGd_set2DOpa(dPn_scrn); + return TRUE; } /* 80161594-8016168C .text _delete__5dPn_cFv */ -void dPn_c::_delete() { - /* Nonmatching */ +BOOL dPn_c::_delete() { + JKRHeap * oldHeap = mDoExt_setCurrentHeap(mpHeap); + g_dComIfG_gameInfo.play.mPlacenameState = 0; + delete dPn_scrn->scrn; + delete dPn_scrn; + if (dvd != NULL) + delete dvd; + mpHeap->free(mpTIMG); + mpHeap->freeAll(); + g_dComIfG_gameInfo.play.field_0x4962 = 0; + mDoExt_setCurrentHeap(oldHeap); + dComIfG_resDelete(&mPhs, "PName"); + return TRUE; } /* 8016168C-801616AC .text dPn_Draw__FP5dPn_c */ -void dPn_Draw(dPn_c*) { - /* Nonmatching */ +BOOL dPn_Draw(dPn_c* i_this) { + return i_this->_draw(); } /* 801616AC-801616CC .text dPn_Execute__FP5dPn_c */ -void dPn_Execute(dPn_c*) { - /* Nonmatching */ +BOOL dPn_Execute(dPn_c* i_this) { + return i_this->_execute(); } /* 801616CC-801616D4 .text dPn_IsDelete__FP5dPn_c */ -void dPn_IsDelete(dPn_c*) { - /* Nonmatching */ +BOOL dPn_IsDelete(dPn_c* i_this) { + return TRUE; } /* 801616D4-801616F4 .text dPn_Delete__FP5dPn_c */ -void dPn_Delete(dPn_c*) { - /* Nonmatching */ +BOOL dPn_Delete(dPn_c* i_this) { + return i_this->_delete(); } /* 801616F4-80161714 .text dPn_Create__FP9msg_class */ -void dPn_Create(msg_class*) { - /* Nonmatching */ +s32 dPn_Create(msg_class* i_msg) { + dPn_c * i_this = (dPn_c *)i_msg; + return i_this->_create(); } -/* 80161714-80161770 .text __dt__13dPlace_name_cFv */ -dPlace_name_c::~dPlace_name_c() { - /* Nonmatching */ -} +msg_method_class l_dPlace_name_Method = { + (process_method_func)dPn_Create, + (process_method_func)dPn_Delete, + (process_method_func)dPn_Execute, + (process_method_func)dPn_IsDelete, + (process_method_func)dPn_Draw, +}; +msg_process_profile_definition g_profile_PLACE_NAME = { + fpcLy_CURRENT_e, + 12, + fpcPi_CURRENT_e, + PROC_PLACE_NAME, + &g_fpcLf_Method.mBase, + sizeof(dPn_c), + 0, + 0, + &g_fopMsg_Method, + 0x1DD, + &l_dPlace_name_Method, +}; diff --git a/src/f_op/f_op_msg.cpp b/src/f_op/f_op_msg.cpp index 1a2783dfa..d8a24c64b 100644 --- a/src/f_op/f_op_msg.cpp +++ b/src/f_op/f_op_msg.cpp @@ -12,7 +12,7 @@ /* 8002A688-8002A6B0 .text fopMsg_Draw__FPv */ int fopMsg_Draw(void* i_this) { msg_class* _this = static_cast(i_this); - return fpcLf_DrawMethod(_this->mSubMtd, i_this); + return fpcLf_DrawMethod((leafdraw_method_class*)_this->mSubMtd, i_this); } /* 8002A6B0-8002A6E8 .text fopMsg_Execute__FPv */ @@ -21,7 +21,7 @@ int fopMsg_Execute(void* i_this) { int stat = 1; if (!dScnPly_ply_c::isPause()) { - stat = fpcMtd_Execute(&_this->mSubMtd->mBase, i_this); + stat = fpcMtd_Execute((process_method_class*)_this->mSubMtd, i_this); } return stat; @@ -31,7 +31,7 @@ int fopMsg_Execute(void* i_this) { int fopMsg_IsDelete(void* i_this) { msg_class* _this = static_cast(i_this); - int stat = fpcMtd_IsDelete(&_this->mSubMtd->mBase, i_this); + int stat = fpcMtd_IsDelete((process_method_class*)_this->mSubMtd, i_this); if (stat == 1) { fopDwTg_DrawQTo(&_this->mDwTg); } @@ -43,7 +43,7 @@ int fopMsg_IsDelete(void* i_this) { int fopMsg_Delete(void* i_this) { msg_class* _this = static_cast(i_this); - int stat = fpcMtd_Delete(&_this->mSubMtd->mBase, i_this); + int stat = fpcMtd_Delete((process_method_class*)_this->mSubMtd, i_this); fopDwTg_DrawQTo(&_this->mDwTg); return stat; @@ -70,7 +70,7 @@ int fopMsg_Create(void* i_this) { } } - int status = fpcMtd_Create(&_this->mSubMtd->mBase, _this); + int status = fpcMtd_Create((process_method_class*)_this->mSubMtd, _this); if (status == cPhs_COMPLEATE_e) { s32 priority = fpcLf_GetPriority(_this); fopDwTg_ToDrawQ(&_this->mDwTg, priority);