diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 13250760..3aefe8d0 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -6853,7 +6853,7 @@ setDimming__11RPSysSystemFi = .text:0x801831E8; // type:function size:0x8 systemShutDown__11RPSysSystemFv = .text:0x801831F0; // type:function size:0xD8 fn_801832C8 = .text:0x801832C8; // type:function size:0x28 fn_801832F0 = .text:0x801832F0; // type:function size:0x18 -startLoadCount__11RPSysSystemFP11RPSysSystem = .text:0x80183308; // type:function size:0xC +startLoadCount__11RPSysSystemFv = .text:0x80183308; // type:function size:0xC fn_80183314 = .text:0x80183314; // type:function size:0xA0 fn_801833B4 = .text:0x801833B4; // type:function size:0xBC getCalendarTime16__11RPSysSystemFv = .text:0x80183470; // type:function size:0x4C @@ -7309,7 +7309,7 @@ fn_801930F8 = .text:0x801930F8; // type:function size:0x8 fn_80193100 = .text:0x80193100; // type:function size:0x150 fn_80193250 = .text:0x80193250; // type:function size:0x18 fn_80193268 = .text:0x80193268; // type:function size:0x10 -fn_80193278 = .text:0x80193278; // type:function size:0x10 +createEffect__14RPSysEffectMgrFUlUsUl = .text:0x80193278; // type:function size:0x10 fn_80193288 = .text:0x80193288; // type:function size:0x22C fn_801934B4 = .text:0x801934B4; // type:function size:0xD0 fn_80193584 = .text:0x80193584; // type:function size:0x7C @@ -7448,18 +7448,18 @@ parseDynamicAnmLength__11RPSysLayoutFPCc = .text:0x801976B8; // type:function si initialize__11RPSysLayoutFv = .text:0x8019778C; // type:function size:0x4 update__14RPSysFrameCtrlFv = .text:0x80197790; // type:function size:0x268 init__14RPSysFrameCtrlFs = .text:0x801979F8; // type:function size:0x30 -fn_80197A28 = .text:0x80197A28; // type:function size:0x84 -fn_80197AAC = .text:0x80197AAC; // type:function size:0x698 -fn_80198144 = .text:0x80198144; // type:function size:0xD4 -fn_80198218 = .text:0x80198218; // type:function size:0xB4 -fn_801982CC = .text:0x801982CC; // type:function size:0x14 -fn_801982E0 = .text:0x801982E0; // type:function size:0x14 -fn_801982F4 = .text:0x801982F4; // type:function size:0x38 -fn_8019832C = .text:0x8019832C; // type:function size:0x444 -fn_80198770 = .text:0x80198770; // type:function size:0x4 -fn_80198774 = .text:0x80198774; // type:function size:0x4 -fn_80198778 = .text:0x80198778; // type:function size:0x8C -fn_80198804 = .text:0x80198804; // type:function size:0xD4 +draw__18RPSysEffectCreatorFRCQ34nw4r2ef8DrawInfoUlUl = .text:0x80197A28; // type:function size:0x84 +update__18RPSysEffectCreatorFv = .text:0x80197AAC; // type:function size:0x698 +createEffect__18RPSysEffectCreatorFUlUs = .text:0x80198144; // type:function size:0xD4 +stopAllEffect__18RPSysEffectCreatorFv = .text:0x80198218; // type:function size:0xB4 +getUnk20__18RPSysEffectCreatorFv = .text:0x801982CC; // type:function size:0x14 +getEffectSystem__18RPSysEffectCreatorFv = .text:0x801982E0; // type:function size:0x14 +setFrameRate__18RPSysEffectCreatorFf = .text:0x801982F4; // type:function size:0x38 +createSlowSystem__18RPSysEffectCreatorFv = .text:0x8019832C; // type:function size:0x444 +nullCtor1__18RPSysEffectCreatorFv = .text:0x80198770; // type:function size:0x4 +nullCtor2__18RPSysEffectCreatorFv = .text:0x80198774; // type:function size:0x4 +setResource__18RPSysEffectCreatorFPUcPUc = .text:0x80198778; // type:function size:0x8C +__dt__18RPSysEffectCreatorFv = .text:0x80198804; // type:function size:0xD4 __ct__18RPSysEffectCreatorFUl = .text:0x801988D8; // type:function size:0x90 Initialize__19RPSysWideTextWriterFv = .text:0x80198968; // type:function size:0x28 getFrameMax__14RPSysLytAnmObjFv = .text:0x80198990; // type:function size:0x40 @@ -7660,20 +7660,20 @@ fn_801A3F08 = .text:0x801A3F08; // type:function size:0x10C fn_801A4014 = .text:0x801A4014; // type:function size:0xA8 fn_801A40BC = .text:0x801A40BC; // type:function size:0x814 fn_801A48D0 = .text:0x801A48D0; // type:function size:0x60 -fn_801A4930 = .text:0x801A4930; // type:function size:0x24 -fn_801A4954 = .text:0x801A4954; // type:function size:0x2C +beginDrawScreen__16RPSysHomeMenuMgrFv = .text:0x801A4930; // type:function size:0x24 +draw__16RPSysHomeMenuMgrFv = .text:0x801A4954; // type:function size:0x2C update__16RPSysHomeMenuMgrFv = .text:0x801A4980; // type:function size:0x390 startBlackOut__16RPSysHomeMenuMgrFv = .text:0x801A4D10; // type:function size:0x58 -fn_801A4D68 = .text:0x801A4D68; // type:function size:0x124 -fn_801A4E8C = .text:0x801A4E8C; // type:function size:0x12C -fn_801A4FB8 = .text:0x801A4FB8; // type:function size:0x224 -fn_801A51DC = .text:0x801A51DC; // type:function size:0x68 -fn_801A5244 = .text:0x801A5244; // type:function size:0x40 -fn_801A5284 = .text:0x801A5284; // type:function size:0x1AC +clearMenu__16RPSysHomeMenuMgrFv = .text:0x801A4D68; // type:function size:0x124 +updateOutside__16RPSysHomeMenuMgrFv = .text:0x801A4E8C; // type:function size:0x12C +LoadResource__16RPSysHomeMenuMgrFv = .text:0x801A4FB8; // type:function size:0x224 +init__16RPSysHomeMenuMgrFv = .text:0x801A51DC; // type:function size:0x68 +__dt__16RPSysHomeMenuMgrFv = .text:0x801A5244; // type:function size:0x40 +__ct__16RPSysHomeMenuMgrFPQ23EGG4Heap = .text:0x801A5284; // type:function size:0x1AC fn_801A5430 = .text:0x801A5430; // type:function size:0x54 -fn_801A5484 = .text:0x801A5484; // type:function size:0x158 +drawScreen__16RPSysHomeMenuMgrFPQ216RPSysHomeMenuMgr12fileAccessor = .text:0x801A5484; // type:function size:0x158 fn_801A55DC = .text:0x801A55DC; // type:function size:0x11C -fn_801A56F8 = .text:0x801A56F8; // type:function size:0x60 +CreateInstance__16RPSysHomeMenuMgrFPQ23EGG4Heap = .text:0x801A56F8; // type:function size:0x60 GetValidNum__15RPSysOfficialDBFv = .text:0x801A5758; // type:function size:0xA8 Reset__15RPSysOfficialDBFv = .text:0x801A5800; // type:function size:0x7C GetIndexFromCreateID__15RPSysOfficialDBFPC11RFLCreateID = .text:0x801A587C; // type:function size:0x44 @@ -15151,7 +15151,7 @@ lbl_8038338C = .rodata:0x8038338C; // type:object size:0xE data:string lbl_8038339A = .rodata:0x8038339A; // type:object size:0xE data:string lbl_803833A8 = .rodata:0x803833A8; // type:object size:0xE data:string lbl_803833B6 = .rodata:0x803833B6; // type:object size:0x18A -lbl_80383540 = .rodata:0x80383540; // type:object size:0x130 +@stringBase0 = .rodata:0x80383540; // type:object size:0x130 data:string_table TYPE_NAME__Q34nw4r3g3d6ScnRfl = .rodata:0x80383670; // type:object size:0xC scope:global lbl_80383680 = .rodata:0x80383680; // type:object size:0x18 data:4byte GEOMETRY_MAGNIFY__10RPGrpModel = .rodata:0x80383698; // type:object size:0x18 @@ -18628,7 +18628,7 @@ lbl_803B9E00 = .data:0x803B9E00; // type:object size:0xC lbl_803B9E0C = .data:0x803B9E0C; // type:object size:0xC @STRING@changeNameToIdRP__13RPSndAudioMgrFPCc@0 = .data:0x803B9E18; // type:object size:0x19 data:string @STRING@changeNameToIdRP__13RPSndAudioMgrFPCc = .data:0x803B9E38; // type:object size:0x10 data:string -lbl_803B9E48 = .data:0x803B9E48; // type:object size:0x10 +__vt__16RPSysHomeMenuMgr = .data:0x803B9E48; // type:object size:0x10 __vt__15RPSysOfficialDB = .data:0x803B9E58; // type:object size:0xC __vt__23RPSysKokeshiCtrlDataMgr = .data:0x803B9E68; // type:object size:0xC __vt__19RPSysKokeshiCtrlMgr = .data:0x803B9E78; // type:object size:0xC diff --git a/include/Pack/RPAudio/RPSndHomeMenuArcMgr.h b/include/Pack/RPAudio/RPSndHomeMenuArcMgr.h index c1620125..e8ca20eb 100644 --- a/include/Pack/RPAudio/RPSndHomeMenuArcMgr.h +++ b/include/Pack/RPAudio/RPSndHomeMenuArcMgr.h @@ -22,6 +22,10 @@ class RPSndHomeMenuArcMgr : public EGG::SoundHeapMgr, public EGG::ArcPlayer { */ virtual ~RPSndHomeMenuArcMgr(); // at 0x8 + static RPSndHomeMenuArcMgr* instance() { + return spInstance; + } + /** * @brief Updates the state of the sound player */ @@ -36,6 +40,7 @@ class RPSndHomeMenuArcMgr : public EGG::SoundHeapMgr, public EGG::ArcPlayer { bool setupArchive(const void* pBinary); private: + static RPSndHomeMenuArcMgr* spInstance; //! Active sound handle nw4r::snd::SoundHandle mSoundHandle; // at 0x6A4 //! Whether the sound archive has been setup diff --git a/include/Pack/RPAudio/RPSndMoveParam.h b/include/Pack/RPAudio/RPSndMoveParam.h index d935565b..26188271 100644 --- a/include/Pack/RPAudio/RPSndMoveParam.h +++ b/include/Pack/RPAudio/RPSndMoveParam.h @@ -132,11 +132,11 @@ class RPSndMoveParam : public RPSndMoveParamLink, public RPSndMoveValueF32 { private: //! Sound handle - nw4r::snd::SoundHandle& mrHandle; // at 0x28 + nw4r::snd::SoundHandle& mrHandle; // at 0x24 //! Sound parameter category - ParamCategory mCategory; // at 0x2C + ParamCategory mCategory; // at 0x28 //! Sequence sound track flags - u32 mTrackFlags; // at 0x30 + u32 mTrackFlags; // at 0x2C }; /****************************************************************************** diff --git a/include/Pack/RPKernel/RPSysEffectCreator.h b/include/Pack/RPKernel/RPSysEffectCreator.h index bfd43719..5acd7ded 100644 --- a/include/Pack/RPKernel/RPSysEffectCreator.h +++ b/include/Pack/RPKernel/RPSysEffectCreator.h @@ -1,6 +1,7 @@ #ifndef RP_KERNEL_EFFECT_CREATOR_H #define RP_KERNEL_EFFECT_CREATOR_H #include +#include //! @addtogroup rp_kernel //! @{ @@ -22,8 +23,33 @@ class RPSysEffectCreator { */ virtual ~RPSysEffectCreator(); // at 0x8 + void setResource(u8* pEffData, u8* pTexData); + void nullCtor1(); + void nullCtor2(); + /** + * @brief Sets the current frame rate. Uses constant values. + * + * @param pFrameRate Can either be ticks per millisecond or ticks per minute. + */ + void setFrameRate(f32 pFrameRate); + void createEffect(u32 pGroupID, u16 pCalcRemain); + bool isSlowEffect() const; + bool getUnk20() const; + void stopAllEffect(); + void draw(const nw4r::ef::DrawInfo& pDrawInfo, u32 pGroupID_1, u32 pGroupID_2); + private: - char unk4[0x44 - 0x4]; + char unk4[0xB]; // at 0x4 + u32 mUnknownID; // at 0x10 + nw4r::ef::EffectProject* mEffectProject; // at 0x14 + nw4r::ef::TextureProject* mTextureProject; // at 0x18 + u32 unk1c; // at 0x1c + BOOL unk20; // at 0x20 + char unk24[4]; // at 0x24 + f32 mFrameRate; // at 0x28 + nw4r::ef::EffectSystem* mEffectSystem; // at 0x2C + u32 unk30; // at 0x30 + char unk34[0x10]; }; //! @} diff --git a/include/Pack/RPKernel/RPSysEffectMgr.h b/include/Pack/RPKernel/RPSysEffectMgr.h index 36159494..8a18de3e 100644 --- a/include/Pack/RPKernel/RPSysEffectMgr.h +++ b/include/Pack/RPKernel/RPSysEffectMgr.h @@ -29,10 +29,14 @@ class RPSysEffectMgr { }; public: + void createEffect(u32 pGroupID, u16 pCalcRemain, u32 pCreator); void stopAllEffect(); void setCreator(RPSysEffectCreator* pCreator, u32 effectScene); void resetCreator(RPSysEffectCreator* pCreator); + +private: + RPSysEffectCreator* mEffectCreators[4]; // at 0x8 }; //! @} diff --git a/include/Pack/RPKernel/RPSysHomeMenuMgr.h b/include/Pack/RPKernel/RPSysHomeMenuMgr.h index 5c61d8b3..aa1f863e 100644 --- a/include/Pack/RPKernel/RPSysHomeMenuMgr.h +++ b/include/Pack/RPKernel/RPSysHomeMenuMgr.h @@ -1,6 +1,7 @@ #ifndef RP_KERNEL_HOME_MENU_MGR_H #define RP_KERNEL_HOME_MENU_MGR_H #include +#include #include #include @@ -17,37 +18,44 @@ class RPSysHomeMenuMgr { RP_SINGLETON_DECL_EX(RPSysHomeMenuMgr); public: - void update(); + //! This uses its own scheme instead of HBMSelectBtnNum for some reason + enum homeButtonState { + BUTTON_NONE, // used when inactive or returning to Wii Menu + BUTTON_OPEN, + BUTTON_CLOSE, // exiting Home Menu, but game still running + BUTTON_RESET, + BUTTON_MAX + }; - bool isOpen() const { - return mIsOpen; - } + struct fileAccessor { + void* mFile; + BOOL UNK_0x04; // set to 1 if DVD error occurs in function 801A4E8C + u16 UNK_0x08; + u16 UNK_0x0A; + }; - /** - * @brief Check if program is exiting/resetting and black out if true - * - * @return BOOL - */ + void drawScreen(fileAccessor* texture); + void init(); + void LoadResource(); + void updateOutside(); + void clearMenu(); BOOL startBlackOut(); + void update(); + void draw(); + void beginDrawScreen(); private: - struct unknownArcStruct { - void* mArcFile; - u32 UNK_0x04; // set to 1 if DVD error occurs in function 801A4E8C - u16 UNK_0x08; - u16 UNK_0x0A; - }; - u8 mUNK_0x08; // set to 1 at the end of LoadResource. bool? - bool mUNK_0x09; // checked in 801A4E8C to make sure error has not occurred - bool mUNK_0x0A; // set to true if no DVD error and scene change disabled - bool mIsOpen; + bool mResLoaded; // at 0x08 + bool mUNK_0x09; + bool mUNK_0x0A; + bool mIsOpen; // at 0x0B u8 mUNK_0x0C; - u8 mUNK_0x0D; - u32 mUNK_0x10; + bool mBlackOutCalled; // at 0x0D + homeButtonState mButtonState; // at 0x10 u16 mUNK_0x14; RPSysProjectLocal* mProjectLocal; - unknownArcStruct* mARC_0x1C; + fileAccessor* mFileAccessor; HBMDataInfo* mMenuDataInfo; u32 mUNK_0x24; u32 mUNK_0x28; @@ -62,12 +70,14 @@ class RPSysHomeMenuMgr { u32 mUNK_0x4C; f32 mUNK_0x50; // Set to 1.2 if the console is in PAL 50 Hz mode, // otherwise 1.0 - f32 mUNK_0x54; - f32 mUNK_0x58; + f32 mScaleX; + f32 mAdjScaleX; u32 mUNK_0x5C; const HBMControllerData* mHbmControllerData; - u8 mUNK_0x64[60]; - KPADStatus mKpadStatus; + Vec2 mVec2; + u8 mUNK_0x6C[50]; + KPADStatus mKpadStatus; //todo(texline) why is this duped? + u8 mPadding[396]; }; //! @} diff --git a/include/Pack/RPKernel/RPSysSystem.h b/include/Pack/RPKernel/RPSysSystem.h index b8cc1b2d..74d5b3ef 100644 --- a/include/Pack/RPKernel/RPSysSystem.h +++ b/include/Pack/RPKernel/RPSysSystem.h @@ -4,6 +4,7 @@ #include #include +#include #include @@ -266,7 +267,9 @@ class RPSysSystem { /** * @brief Gets the thread for asynchronous disc operations */ - EGG::TaskThread* getDvdThread(); + EGG::TaskThread* getDvdThread() { + return mpDvdThread; + } /** * @brief Gets the thread for asynchronous WiiConnect24 operations */ diff --git a/include/Pack/RPSystem/RPSysPauseMgr.h b/include/Pack/RPSystem/RPSysPauseMgr.h index afcd258f..6e939762 100644 --- a/include/Pack/RPSystem/RPSysPauseMgr.h +++ b/include/Pack/RPSystem/RPSysPauseMgr.h @@ -20,6 +20,9 @@ class RPSysPauseMgr { private: u32 unk8; + u32 unkC; + f32 mFloats_0x10[120]; + void *mLytPause; }; //! @} diff --git a/src/Pack/RPKernel/RPSysEffectCreator.cpp b/src/Pack/RPKernel/RPSysEffectCreator.cpp new file mode 100644 index 00000000..8c8960e2 --- /dev/null +++ b/src/Pack/RPKernel/RPSysEffectCreator.cpp @@ -0,0 +1,106 @@ +#include + +#include + +/** + * @brief Destructor + */ +RPSysEffectCreator::~RPSysEffectCreator() { + BOOL doRelocate = FALSE; + nw4r::ef::Resource *resInstance = nw4r::ef::Resource::GetInstance(); + + stopAllEffect(); + if (mEffectProject != NULL) { + resInstance->RemoveEffectProject(mEffectProject); + doRelocate = TRUE; + mEffectProject = NULL; + } + if (mTextureProject != NULL) { + resInstance->RemoveTextureProject(mTextureProject); + doRelocate = TRUE; + mTextureProject = NULL; + } + if (doRelocate) { + resInstance->RelocateCommand(); + } //todo(texline) this implicitly calls ~Disposer +} + +/** + * @brief Registers and resolves given effects and textures. + * + * @param pEffData pointer to given .breff data + * @param pTexData pointer to given .breft data + */ + +void RPSysEffectCreator::setResource(u8* pEffData, u8* pTexData) { + if (mEffectProject == NULL && mTextureProject == NULL) { + nw4r::ef::Resource *instance = nw4r::ef::Resource::GetInstance(); + mEffectProject = instance->Add(pEffData); + mTextureProject = instance->AddTexture(pTexData); + instance->RelocateCommand(); + } +} + +/** + * @brief Treated as constructor functions in createSlowSystem. Both are stubbed. + */ +void RPSysEffectCreator::nullCtor2() {} // 2 is first for linking purposes +void RPSysEffectCreator::nullCtor1() {} + +/** + * @brief Gets mEffectSystem. + */ +bool RPSysEffectCreator::isSlowEffect() const { + return mEffectSystem != NULL; +} + +/** + * @brief Temporary name. Returns an unknown BOOL at offset 0x20. + * + * @details Function used in RPBoxScene function 802E6A00 + */ +bool RPSysEffectCreator::getUnk20() const { + return unk20 != NULL; +} + +/** + * @brief Deletes all emitters and particles upon exiting a scene. + */ +void RPSysEffectCreator::stopAllEffect() { + int i; + int j; + u32 pGroupID; + u32 pGroupID_2; + + // todo(texline): regswaps + // instance is set as its own variable because code gets less accurate otherwise + nw4r::ef::EffectSystem* instance = nw4r::ef::EffectSystem::GetInstance(); + for (i = 0; i < 64; i++) { + pGroupID = mUnknownID | i; + instance->RetireEmitterAll(pGroupID); + instance->RetireParticleAll(pGroupID); + } + if (mEffectSystem != NULL) { + for (j = 0; j < 64; j++) { + pGroupID_2 = mUnknownID | j; + mEffectSystem->RetireEmitterAll(pGroupID_2); + mEffectSystem->RetireParticleAll(pGroupID_2); + } + } +} + +/** + * @brief Renders effects that are part of a given group. + * + * @param pDrawInfo reference to DrawInfo used in NintendoWare function + * @param pGroupID_1 part of calculation for bitor'd groupID + * @param pGroupID_2 part of calculation for bitor'd groupID + */ + +void RPSysEffectCreator::draw(const nw4r::ef::DrawInfo& pDrawInfo, u32 pGroupID_1, u32 pGroupID_2) { + nw4r::ef::EffectSystem *instance = nw4r::ef::EffectSystem::GetInstance(); + instance->Draw(pDrawInfo, pGroupID_1 | pGroupID_2 | mUnknownID); + if (mEffectSystem != NULL) { + mEffectSystem->Draw(pDrawInfo, pGroupID_1 | pGroupID_2 | mUnknownID); + } +} diff --git a/src/Pack/RPKernel/RPSysEffectMgr.cpp b/src/Pack/RPKernel/RPSysEffectMgr.cpp new file mode 100644 index 00000000..da2f2876 --- /dev/null +++ b/src/Pack/RPKernel/RPSysEffectMgr.cpp @@ -0,0 +1,30 @@ +#include + +#include + +void RPSysEffectMgr::setCreator(RPSysEffectCreator* pCreator, u32 pEffectScene) { + if (pCreator != NULL) { + mEffectCreators[pEffectScene] = pCreator; + } +} + +void RPSysEffectMgr::stopAllEffect() { + int i; + int j; + nw4r::ef::EffectSystem* effSysInst = nw4r::ef::EffectSystem::GetInstance(); + + for (i = 0; i < 0x180; i++) { + effSysInst->RetireEmitterAll(i); + effSysInst->RetireParticleAll(i); + } + + for (j = 0; j < 3; j++) { + if (mEffectCreators[0] != NULL && mEffectCreators[0]->getEffectSystem() != 0) { + mEffectCreators[0]->stopAllEffect(); + } + } +} + +void RPSysEffectMgr::createEffect(u32 pGroupID, u16 pCalcRemain, u32 pCreator) { + mEffectCreators[pCreator]->createEffect(pGroupID, pCalcRemain); +} diff --git a/src/Pack/RPKernel/RPSysHomeMenuMgr.cpp b/src/Pack/RPKernel/RPSysHomeMenuMgr.cpp new file mode 100644 index 00000000..194d3916 --- /dev/null +++ b/src/Pack/RPKernel/RPSysHomeMenuMgr.cpp @@ -0,0 +1,297 @@ +#include +#include +#include + +#include + +#include + +RP_SINGLETON_IMPL_EX(RPSysHomeMenuMgr); + +/** + * @brief Destructor + */ +RPSysHomeMenuMgr::~RPSysHomeMenuMgr() {} + +/** + * @brief Initializes the class. + */ +void RPSysHomeMenuMgr::init() { + fileAccessor* arcStruct; + + mUNK_0x09 = FALSE; + mIsOpen = FALSE; + mUNK_0x0C = FALSE; + mBlackOutCalled = FALSE; + mButtonState = BUTTON_NONE; + mUNK_0x14 = NULL; + VISetBlack(FALSE); + mUNK_0x09 = FALSE; // @bug Initialized twice + arcStruct = mFileAccessor; + arcStruct->UNK_0x04 = FALSE; + arcStruct->UNK_0x08 = 0; + arcStruct->UNK_0x0A = 0; +} + +/** + * @brief Loads the files used in the home menu itself. + */ +void RPSysHomeMenuMgr::LoadResource() { + HBMDataInfo* menuDataInfo = mMenuDataInfo; + EGG::Archive* staComArc = RP_GET_INSTANCE(RPSysResourceManager) + ->GetStaticCommonArchive(); + EGG::Archive* staLocArc = RP_GET_INSTANCE(RPSysResourceManager) + ->GetStaticLocalArchive(); + mFileAccessor->mFile = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staComArc, "/HomeMenu/homeBtnIcon.bti"); + + switch (mProjectLocal->getLanguage()) { + case (RPSysProjectLocal::EArea_France): { + menuDataInfo->region = SC_LANG_FR; + menuDataInfo->layoutBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staLocArc, "/HomeMenu/homeBtn_FRA.arc"); + break; + } + case (RPSysProjectLocal::EArea_Germany): { + menuDataInfo->region = SC_LANG_DE; + menuDataInfo->layoutBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staLocArc, "/HomeMenu/homeBtn_GER.arc"); + break; + } + case (RPSysProjectLocal::EArea_Italy): { + menuDataInfo->region = SC_LANG_IT; + menuDataInfo->layoutBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staLocArc, "/HomeMenu/homeBtn_ITA.arc"); + break; + } + case (RPSysProjectLocal::EArea_Spain): { + menuDataInfo->region = SC_LANG_SP; + menuDataInfo->layoutBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staLocArc, "/HomeMenu/homeBtn_SPA.arc"); + break; + } + case (RPSysProjectLocal::EArea_Netherlands): { + menuDataInfo->region = SC_LANG_NL; + menuDataInfo->layoutBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staLocArc, "/HomeMenu/homeBtn_NED.arc"); + break; + } + case (RPSysProjectLocal::EArea_Japan): { + menuDataInfo->region = SC_LANG_JP; + menuDataInfo->layoutBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staLocArc, "/HomeMenu/homeBtn.arc"); + break; + } + default: { + menuDataInfo->region = SC_LANG_EN; + menuDataInfo->layoutBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staLocArc, "/HomeMenu/homeBtn_ENG.arc"); + break; + } + } + menuDataInfo->spkSeBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staComArc, "/HomeMenu/SpeakerSe.arc"); + + menuDataInfo->msgBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staComArc, "/HomeMenu/home_nosave.csv"); + + menuDataInfo->configBuf = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staComArc, "/HomeMenu/config.txt"); + + HBMCreate(menuDataInfo); + HBMSetAdjustFlag(TRUE); + + void *seFile = RP_GET_INSTANCE(RPSysResourceManager) + ->GetFileFromArchive(staComArc, "/HomeMenu/HomeButtonSe.brsar"); + RP_GET_INSTANCE(RPSndHomeMenuArcMgr)->setupArchive(seFile); + + if (mProjectLocal->getPack() == RPSysSceneCreator::EPackID_HealthPack) { + HBMSetBlackOutColor(0xFF, 0xFF, 0xFF); + } + mResLoaded = TRUE; +} + +/** + * @brief Runs every frame when the user is not in the home menu. + */ +void RPSysHomeMenuMgr::updateOutside() { + BOOL unk = FALSE; + fileAccessor* arcStruct; + + for (int index = 0; index < 4; index++) { + if ((RP_GET_CORE_CTRL(index)->getCoreStatus()->getTrigger() & EGG::cCORE_BUTTON_HOME)) { + unk = TRUE; + break; + } + } + + if (unk || mUNK_0x0A) { + if (RP_GET_INSTANCE(RPSysSceneMgr)->getCurrentSceneRP()->isSceneChangeEnable()) { + if (!(mUNK_0x09 || RP_GET_INSTANCE(RPSysDvdStatus)->isErrorOccured())) { + mButtonState = BUTTON_OPEN; + mUNK_0x14 = 0; + mIsOpen = TRUE; + mUNK_0x0C = FALSE; + RP_GET_INSTANCE(RPSndAudioMgr)->enterMenu(); + } else { + arcStruct = mFileAccessor; + arcStruct->UNK_0x04 = 1; + arcStruct->UNK_0x08 = 0; + arcStruct->UNK_0x0A = 0; + } + mUNK_0x0A = FALSE; + } else if (RP_GET_INSTANCE(RPSysDvdStatus)->isErrorOccured()) { + arcStruct = mFileAccessor; + arcStruct->UNK_0x04 = 1; + arcStruct->UNK_0x08 = 0; + arcStruct->UNK_0x0A = 0; + } else { + mUNK_0x0A = TRUE; + } + } +} + +void RPSysHomeMenuMgr::clearMenu() { + RPSysCoreController* con; + + mUNK_0x0C = TRUE; + switch (HBMCalc(mHbmControllerData)) { + //! Reset (yes, the code checks this case first) + case (HBM_SELECT_BTN2): { + mButtonState = BUTTON_RESET; + RP_GET_INSTANCE(RPSysSceneMgr)->softReset(TRUE); + RP_GET_INSTANCE(RPSndAudioMgr)->stopAllSoundOnPauseOff(); + break; + } + //! Return to Wii Menu + case (HBM_SELECT_BTN1): { + RP_GET_INSTANCE(RPSysSceneMgr)->returnToMenu(TRUE); + mButtonState = BUTTON_NONE; + mIsOpen = FALSE; + mUNK_0x0C = FALSE; + RP_GET_INSTANCE(RPSndAudioMgr)->exitMenu(); + con->popDpdCtrlStackAll(); + con->popKPADParamStackAll(); + if (RP_GET_INSTANCE(RPSysPauseMgr)->isPause()) { + return; + } + break; + } + case (HBM_SELECT_BTN3): { + return; + } + default: { + break; + } + } + RPSysScene* sceneRP = RP_GET_INSTANCE(RPSysSceneMgr)->getCurrentSceneRP(); + //! This function is stubbed out in rev 1 + sceneRP->pauseCallBack(FALSE); +} + +/** + * @brief Makes the screen fade out. + * + * @return Home menu status. + */ +BOOL RPSysHomeMenuMgr::startBlackOut() { + BOOL openState; + + if (mIsOpen && !mBlackOutCalled) { + HBMStartBlackOut(); + mBlackOutCalled = TRUE; + } + openState = mIsOpen; + mUNK_0x0A = FALSE; //todo(texline) what does this indicate? + return openState; +} + +void RPSysHomeMenuMgr::update() { + s32 conChan; + RPSysCoreController *con; + KPADStatus* kpadStatPtr; + //! test + f32 current = RPGrpScreen::GetSizeXMax(); + f32 standard = RPGrpScreen::GetSizeYMax(RPGrpScreen::TV_MODE_STD); + mScaleX = current / standard; + mAdjScaleX = 1.0f; + + if (mIsOpen) { + kpadStatPtr = &mKpadStatus; + conChan = 0; + while (conChan < 4) { + con = RP_GET_INSTANCE(RPSysCoreControllerMgr)->findController(conChan); + if (con && con->isCoreBaseDevice()) { + if (mKpadStatus.wpad_err == WPAD_ERR_COMMUNICATION_ERROR) { + std::memset(kpadStatPtr, 0, sizeof(KPADStatus)); + mKpadStatus.horizon = con->getCoreStatus()->horizon; + } else { + mKpadStatus = *con->getCoreStatus(); + } + mVec2 = mKpadStatus.pos; + } else { + mHbmControllerData = NULL; + mVec2.x = 10000.0f; + mVec2.y = 10000.0f; + } + conChan++; + kpadStatPtr++; + } + } + if (mResLoaded) { + switch (mButtonState) { + /* Commenting out: code right now has severe bug that leads to 0% match + case (BUTTON_OPEN): { + mUNK_0x14++; + if (RP_GET_INSTANCE(RPSndSpeakerMgr) + ->isDisconnectAllFinished()) { + mButtonState = BUTTON_CLOSE; + mUNK_0x14 = 0; + HBMInit(); + con->stopMotorAll(); + con->pushDpdCtrlStackAll(TRUE); + } + } + */ + case (BUTTON_CLOSE): { + clearMenu(); + } + case (BUTTON_RESET): { + mButtonState = BUTTON_NONE; + mIsOpen = FALSE; + mUNK_0x0C = FALSE; + RP_GET_INSTANCE(RPSndAudioMgr)->exitMenu(); + con->popDpdCtrlStackAll(); + con->popKPADParamStackAll(); + if (RP_GET_INSTANCE(RPSysPauseMgr)->isPause()) { + RPSysScene* sceneRP = RP_GET_INSTANCE(RPSysSceneMgr) + ->getCurrentSceneRP(); + //! This function is stubbed out in rev 1 + sceneRP->pauseCallBack(FALSE); + } + } + default: { + updateOutside(); + } + } + } + RP_GET_INSTANCE(RPSndHomeMenuArcMgr)->calc(); +} + +/** + * @brief Starts the drawing process for the home menu. + */ +void RPSysHomeMenuMgr::draw() { + if (mResLoaded && mIsOpen && mUNK_0x0C) { + HBMDraw(); + } +} + +void RPSysHomeMenuMgr::beginDrawScreen() { + if (mResLoaded) { + fileAccessor *localAccess = mFileAccessor; + if (localAccess->UNK_0x04) { + drawScreen(localAccess); + } + } +}