From e8e36445ba150456fc590c5e1a727e6c4dabc280 Mon Sep 17 00:00:00 2001 From: TakaRikka <38417346+TakaRikka@users.noreply.github.com> Date: Wed, 28 May 2025 04:04:30 -0700 Subject: [PATCH] cleanup d_meter2_info / little JMessage work (#2460) * d_meter2_info cleanup * parseBlock_next matching --- include/JSystem/JGadget/linklist.h | 7 + include/JSystem/JKernel/JKRArchive.h | 4 +- include/JSystem/JMessage/JMessage.h | 41 + include/JSystem/JMessage/data.h | 17 + include/JSystem/JMessage/resource.h | 21 +- include/d/actor/d_a_balloon_2D.h | 8 +- include/d/d_meter2_info.h | 410 ++++----- include/d/d_msg_class.h | 53 +- include/d/d_msg_unit.h | 43 +- src/JSystem/JMessage/resource.cpp | 70 +- src/d/actor/d_a_balloon_2D.cpp | 2 +- src/d/d_meter2_draw.cpp | 4 +- src/d/d_meter2_info.cpp | 1221 +++++++++++++++++--------- src/d/d_msg_object.cpp | 62 +- src/d/d_msg_unit.cpp | 24 +- 15 files changed, 1243 insertions(+), 744 deletions(-) create mode 100644 include/JSystem/JMessage/JMessage.h diff --git a/include/JSystem/JGadget/linklist.h b/include/JSystem/JGadget/linklist.h index 5147a9a0ce6..c6b3b083474 100644 --- a/include/JSystem/JGadget/linklist.h +++ b/include/JSystem/JGadget/linklist.h @@ -231,6 +231,7 @@ struct TLinkList_factory : public TLinkList { inline virtual ~TLinkList_factory() = 0; virtual T* Do_create() = 0; virtual void Do_destroy(T*) = 0; + void Clear_destroy() { while (!this->empty()) { T* item = &this->front(); @@ -238,6 +239,12 @@ struct TLinkList_factory : public TLinkList { Do_destroy(item); } } + + TLinkList::iterator Erase_destroy(T* param_0) { + TLinkList::iterator spC(Erase(param_0)); + Do_destroy(param_0); + return spC; + } }; template diff --git a/include/JSystem/JKernel/JKRArchive.h b/include/JSystem/JKernel/JKRArchive.h index 3b6a5959d71..a7538c53ed8 100644 --- a/include/JSystem/JKernel/JKRArchive.h +++ b/include/JSystem/JKernel/JKRArchive.h @@ -247,8 +247,8 @@ inline void JKRUnmountArchive(JKRArchive* arc) { arc->unmount(); } -inline void JKRReadIdxResource(void* param_1, u32 param_2, u32 param_3, JKRArchive* param_4) { - param_4->readIdxResource(param_1, param_2, param_3); +inline u32 JKRReadIdxResource(void* buffer, u32 bufsize, u32 resIdx, JKRArchive* archive) { + return archive->readIdxResource(buffer, bufsize, resIdx); } #endif diff --git a/include/JSystem/JMessage/JMessage.h b/include/JSystem/JMessage/JMessage.h new file mode 100644 index 00000000000..f727dd390e7 --- /dev/null +++ b/include/JSystem/JMessage/JMessage.h @@ -0,0 +1,41 @@ +#ifndef JMESSAGE_H +#define JMESSAGE_H + +#include + +// Struct definitions might be wrong +typedef struct bmg_header_t { + /* 0x00 */ char magic[8]; // "MESGbmg1" + /* 0x08 */ u32 size; // total size of file not including FLW1/FLI1 sections + /* 0x0C */ u32 n_sections; // number of sections + /* 0x10 */ u8 encoding; // text encoding + /* 0x11 */ u8 padding[0x20 - 0x11]; // padding +} bmg_header_t; + +typedef struct bmg_section_t { + /* 0x0 */ u32 magic; // four character magic string + /* 0x4 */ u32 size; // total size of the section +} bmg_section_t; + +typedef struct inf1_entry_t { + /* 0x0 */ u32 string_offset; // offset into DAT1 section entries, pointing to where message text starts + /* 0x4 */ // attributes // attribute data. size fills up the rest of defined INF1 "entry_size" +} inf1_entry_t; + +typedef struct inf1_section_t { + /* 0x00 */ bmg_section_t header; // section header + /* 0x08 */ u16 entry_num; // number of entries in this section + /* 0x0A */ u16 entry_size; // size of an entry + /* 0x0C */ u8 padding[4]; // padding +} inf1_section_t; + +typedef struct str1_entry_t { + char str[0]; +} str1_entry_t; + +typedef struct str1_section_t { + /* 0x00 */ bmg_section_t header; // section header + /* 0x08 */ str1_entry_t entries[0]; +} str1_section_t; + +#endif /* JMESSAGE_H */ diff --git a/include/JSystem/JMessage/data.h b/include/JSystem/JMessage/data.h index 6dcf003652e..ef10d352352 100644 --- a/include/JSystem/JMessage/data.h +++ b/include/JSystem/JMessage/data.h @@ -24,6 +24,11 @@ struct data { struct TParse_TBlock : public JGadget::binary::TParseData_aligned<4> { TParse_TBlock(const void* data) : TParseData_aligned(data) {} + + const char* get() const { return (char*)getRaw(); } + u32 get_size() const { return *(u32*)(get() + 0x4); } + const void* getNext() const { return (char*)getRaw() + get_size(); } + u32 get_type() const { return *(u32*)(get() + 0x0); } }; struct TParse_TBlock_info : public TParse_TBlock { @@ -55,6 +60,18 @@ struct data { TParse_TBlock_color(const void* data) : TParse_TBlock(data) {} }; + struct TParse_TBlock_messageText : public TParse_TBlock { + TParse_TBlock_messageText(const void* data) : TParse_TBlock(data) {} + + char* getContent() const { return (char*)getRaw() + 0x8; } + }; + + struct TParse_TBlock_stringAttribute : public TParse_TBlock { + TParse_TBlock_stringAttribute(const void* data) : TParse_TBlock(data) {} + + char* getContent() const { return (char*)getRaw() + 0x8; } + }; + static u32 getTagCode(u32 tag) { return tag & 0xFFFF; } static u32 getTagGroup(u32 tag) { return (tag >> 0x10) & 0xFF; } diff --git a/include/JSystem/JMessage/resource.h b/include/JSystem/JMessage/resource.h index 9462b3b34dc..3ab892bb29c 100644 --- a/include/JSystem/JMessage/resource.h +++ b/include/JSystem/JMessage/resource.h @@ -13,7 +13,7 @@ namespace JMessage { */ struct TResource { TResource() - : field_0x8(NULL), field_0xc(NULL), field_0x10(NULL), field_0x14(0), mMessageID(NULL) {} + : field_0x8(NULL), field_0xc(NULL), field_0x10(NULL), field_0x14(NULL), mMessageID(NULL) {} /* 802A8CDC */ u16 toMessageIndex_messageID(u32, u32, bool*) const; @@ -50,11 +50,28 @@ struct TResource { void setData_header(const void* pData) { field_0x8.setRaw(pData); } + + void setData_block_info(const void* pData) { + field_0xc.setRaw(pData); + } + + void setData_block_messageText(const void* pData) { + field_0x10 = data::TParse_TBlock_messageText(pData).getContent(); + } + + void setData_block_stringAttribute(const void* pData) { + field_0x14 = data::TParse_TBlock_stringAttribute(pData).getContent(); + } + + void setData_block_messageID(const void* pData) { + mMessageID.setRaw(pData); + } + JGadget::TLinkListNode ocObject_; /* 0x08 */ data::TParse_THeader field_0x8; /* 0x0C */ data::TParse_TBlock_info field_0xc; /* 0x10 */ char* field_0x10; - /* 0x14 */ int field_0x14; + /* 0x14 */ char* field_0x14; /* 0x18 */ data::TParse_TBlock_messageID mMessageID; }; diff --git a/include/d/actor/d_a_balloon_2D.h b/include/d/actor/d_a_balloon_2D.h index 148cf413f0c..b66db2653df 100644 --- a/include/d/actor/d_a_balloon_2D.h +++ b/include/d/actor/d_a_balloon_2D.h @@ -166,15 +166,9 @@ public: /* 0xC0 */ f32 field_0xc0; /* 0xC4 */ f32 field_0xc4; }; + #include "f_op/f_op_actor_mng.h" -class JMSMesgEntry_c : public fopEn_enemy_c { -private: - /* 0x5ac */ u8 field_0x5ac[0x748 - 0x5ac]; -}; - -STATIC_ASSERT(sizeof(JMSMesgEntry_c) == 0x748); - struct JKRExpHeap {}; diff --git a/include/d/d_meter2_info.h b/include/d/d_meter2_info.h index c171bd7bb13..1ea6cbc17ac 100644 --- a/include/d/d_meter2_info.h +++ b/include/d/d_meter2_info.h @@ -41,110 +41,117 @@ public: /* 0x08 */ cXyz mPosition; /* 0x14 */ s16 mAngle; /* 0x16 */ u8 mRoomNo; - /* 0x17 */ u8 unk79; - /* 0x18 */ u8 mWarpPlayerNo; + /* 0x17 */ u8 unk_0x17; + /* 0x18 */ u8 mPlayerNo; }; dMeter2Info_c(); virtual ~dMeter2Info_c(); - void init(void); - int setFloatingMessage(u16, s16, bool); - int setFloatingFlow(u16, s16, bool); - bool isFloatingMessageVisible(void); - s16 decFloatingMessageTimer(void); - void resetFloatingMessage(void); - void decMsgKeyWaitTimer(void); - void getString(u32, char*, JMSMesgEntry_c*); // define JMSMesgEntry - void getStringKana(u32, char*, JMSMesgEntry_c*); - void getStringKanji(u32, char*, JMSMesgEntry_c*); - f32 getStringLength(J2DTextBox*, char*); - f32 getStringLength(JUTFont*, f32, f32, char*); + + void init(); + int setFloatingMessage(u16 i_msgID, s16 i_msgTimer, bool i_wakuVisible); + int setFloatingFlow(u16 i_flowID, s16 i_msgTimer, bool i_wakuVisible); + bool isFloatingMessageVisible(); + s16 decFloatingMessageTimer(); + void resetFloatingMessage(); + void decMsgKeyWaitTimer(); + void getString(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry); + void getStringKana(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry); + void getStringKanji(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry); + f32 getStringLength(J2DTextBox* i_textbox, char* i_string); + f32 getStringLength(JUTFont* i_font, f32 param_2, f32 param_3, char* i_string); void onDirectUseItem(int); BOOL isDirectUseItem(int); - int setMeterString(s32); - void resetWarpStatus(void); - void warpInProc(void); - void warpOutProc(void); - void resetMeterString(void); - void setWarpInfo(const char*, const cXyz&, s16, u8, u8, u8); - u8 getItemType(u8); - int readItemTexture(u8, void*, J2DPicture*, void*, J2DPicture*, void*, J2DPicture*, void*, - J2DPicture*, int); - void setItemColor(u8, J2DPicture*, J2DPicture*, J2DPicture*, J2DPicture*); - s16 get2ndTexture(u8); - s16 get3rdTexture(u8); - s16 get4thTexture(u8); - void set1stColor(u8, J2DPicture*); - void set2ndColor(u8, J2DPicture*); - void set3rdColor(u8, J2DPicture*); - void set4thColor(u8, J2DPicture*); - void setHotSpringTimer(u8); - void decHotSpringTimer(void); - void changeWater(u8); - void setMiniGameItem(u8); - void resetMiniGameItem(bool); - void setMiniGameCount(s8); - void setSaveStageName(const char*); + int setMeterString(s32 i_string); + void resetWarpStatus(); + void warpInProc(); + void warpOutProc(); + void resetMeterString(); + void setWarpInfo(const char* i_stageName, const cXyz& i_position, s16 i_angle, + u8 i_roomNo, u8 param_4, u8 i_warpPlayerNo); + u8 getItemType(u8 i_itemNo); + int readItemTexture(u8 i_itemNo, void* i_texBuf1, J2DPicture* i_pic1, void* i_texBuf2, + J2DPicture* i_pic2, void* i_texBuf3, J2DPicture* i_pic3, + void* i_texBuf4, J2DPicture* i_pic4, int param_9); + void setItemColor(u8 i_itemNo, J2DPicture* i_pic1, J2DPicture* i_pic2, + J2DPicture* i_pic3, J2DPicture* i_pic4); + s16 get2ndTexture(u8 i_itemType); + s16 get3rdTexture(u8 i_itemType); + s16 get4thTexture(u8 i_itemType); + void set1stColor(u8 i_itemType, J2DPicture* i_pic); + void set2ndColor(u8 i_itemType, J2DPicture* i_pic); + void set3rdColor(u8 i_itemType, J2DPicture* i_pic); + void set4thColor(u8 i_itemType, J2DPicture* i_pic); + void setHotSpringTimer(u8 i_slotNo); + void decHotSpringTimer(); + void changeWater(u8 i_slotNo); + void setMiniGameItem(u8 i_minigameFlag); + void resetMiniGameItem(bool i_saveItem); + void setMiniGameCount(s8 i_count); + void setSaveStageName(const char* i_stageName); - void setWindowStatus(u8 status) { - unk186 = mWindowStatus; - mWindowStatus = status; + void setWindowStatus(u8 i_status) { + unk_0xba = mWindowStatus; + mWindowStatus = i_status; } + u8& getDirectUseItem() { return mDirectUseItem; } dMeterMap_c* getMeterMapClass() { return mMeterMap; } - void setMenuWindowClass(dMw_c* p_menu) { mMenuWindowClass = p_menu; } + void setMenuWindowClass(dMw_c* i_menu) { mMenuWindowClass = i_menu; } dMw_c* getMenuWindowClass() { return mMenuWindowClass; } CPaneMgr* getMeterItemPanePtr(s32 i_idx) { return mMeterItemPanePtr[i_idx]; } - void offUseButton(int pButton) { mUseButton &= ~(u16)pButton; } + void offUseButton(int i_buttonBit) { mUseButton &= ~(u16)i_buttonBit; } u16 getOilGaugeBackUp() { return mOilGaugeBackUp; } u8 getInsectSelectType() { return mInsectSelectType; } void setInsectSelectType(u8 i_type) { mInsectSelectType = i_type; } u8 getWarpStatus() { return mWarpStatus; } - void setWarpStatus(u8 status) { mWarpStatus = status; } + void setWarpStatus(u8 i_status) { mWarpStatus = i_status; } u8 getWarpRoomNo() { return mWarpInfo.mRoomNo; } - u8 getWarpPlayerNo() { return mWarpInfo.mWarpPlayerNo; } + u8 getWarpPlayerNo() { return mWarpInfo.mPlayerNo; } cXyz& getWarpPos() { return mWarpInfo.mPosition; } const char* getWarpStageName() { return mWarpInfo.mStageName; } - void setNowCount(u8 count) { mNowCount = count; } - void setMaxCount(u8 count) { mMaxCount = count; } - void allUseButton() { mUseButton = -1; } - bool isUseButton(int param_0) { return param_0 & mUseButton; } - void setMeterMapClass(dMeterMap_c* p_map) { mMeterMap = p_map; } + void setNowCount(u8 i_count) { mNowCount = i_count; } + void setMaxCount(u8 i_count) { mMaxCount = i_count; } + void allUseButton() { mUseButton = 0xFFFF; } + bool isUseButton(int i_buttonBit) { return i_buttonBit & mUseButton; } + void setMeterMapClass(dMeterMap_c* i_map) { mMeterMap = i_map; } void resetGameStatus() { mGameStatus = 0; } - void onGameStatus(int status) { mGameStatus |= status; } - void setMapStatus(u8 status) { mMapStatus = status; } + void onGameStatus(int i_status) { mGameStatus |= i_status; } + void setMapStatus(u8 i_status) { mMapStatus = i_status; } u8 getMapStatus() { return mMapStatus; } - void setPauseStatus(u8 status) { mPauseStatus = status; } + void setPauseStatus(u8 i_status) { mPauseStatus = i_status; } void resetPauseStatus() { mPauseStatus = 0; } u8 getPauseStatus() { return mPauseStatus; } - bool isGameStatus(int status) { return mGameStatus & status; } + bool isGameStatus(int i_status) { return mGameStatus & i_status; } bool isTouchKeyCheck(int i_status) { return mTouchKeyCheck & (1 << i_status); } + // fake function, should be isTouchKeyCheck bool isTouchKeyCheck_alt(int i_status) { return (mTouchKeyCheck >> i_status) & 1; } - void setMapKeyDirection(u16 direction) { mMapKeyDirection = direction; } - bool isSub2DStatus(int flag) { return mSub2DStatus & (1 << flag); } - void offMenuInForce(int flag) { unk152 &= ~(1 << flag); } - bool isMenuInForce(int flag) { return unk152 & (1 << flag); } + + void setMapKeyDirection(u16 i_direction) { mMapKeyDirection = i_direction; } + bool isSub2DStatus(int i_flag) { return mSub2DStatus & (1 << i_flag); } + void offMenuInForce(int i_flag) { unk_0x98 &= ~(1 << i_flag); } + bool isMenuInForce(int i_flag) { return unk_0x98 & (1 << i_flag); } u16 getMapKeyDirection() { return mMapKeyDirection; } u8 getWindowStatus() { return mWindowStatus; } - void setMsgResource(void* res) { mMsgResource = res; } - void setStageMsgResource(void* res) { mStageMsgResource = res; } - void setMsgUnitResource(void* res) { mMsgUnitResource = res; } + void setMsgResource(void* i_res) { mMsgResource = i_res; } + void setStageMsgResource(void* i_res) { mStageMsgResource = i_res; } + void setMsgUnitResource(void* i_res) { mMsgUnitResource = i_res; } void* getMsgResource() { return mMsgResource; } void* getStageMsgResource() { return mStageMsgResource; } void* getMsgUnitResource() { return mMsgUnitResource; } - u8 getLightDropGetFlag(int i) { return mLightDropGetFlag[i]; } + u8 getLightDropGetFlag(int i_no) { return mLightDropGetFlag[i_no]; } u32 getMeterStringType() { return mMeterString; } - void setMeterClass(dMeter2_c* meter) { mMeterClass = meter; } + void setMeterClass(dMeter2_c* i_meter) { mMeterClass = i_meter; } void onLifeGaugeSE() { mLifeGaugeSE = 1; } void offLifeGaugeSE() { mLifeGaugeSE = 0; } u8 getLifeGaugeSE() { return mLifeGaugeSE; } const char* getSaveStageName() { return mSaveStageName; } void onShopTalkFlag() { mShopTalkFlag = true; } void offShopTalkFlag() { mShopTalkFlag = false; } - void setLightDropGetFlag(int index, u8 flag) { mLightDropGetFlag[index] = flag; } + void setLightDropGetFlag(int i_no, u8 i_flag) { mLightDropGetFlag[i_no] = i_flag; } u8 getRentalBombBag() { return mRentalBombBagIdx; } - void setTableMapRegionNo(u8 regionNo) { mTableMapRegionNo = regionNo; } + void setTableMapRegionNo(u8 i_regionNo) { mTableMapRegionNo = i_regionNo; } void setGoldWolfMapType(u8 i_mapType) { mGoldWolfMapType = i_mapType; } dMeter2_c* getMeterClass() { return mMeterClass; } u8 getMiniGameItemSetFlag() { return mMiniGameItemSetFlag; } @@ -153,7 +160,7 @@ public: void setGameOverType(u8 i_gameoverType) { mGameOverType = i_gameoverType; } void setMsgKeyWaitTimer(s16 i_waitTimer) { mMsgKeyWaitTimer = i_waitTimer; } s32 getMsgTimeMs() { return mMsgTimeMs; } - void setMsgTimeMs(s32 msgTime) { mMsgTimeMs = msgTime; } + void setMsgTimeMs(s32 i_msgTime) { mMsgTimeMs = i_msgTime; } void setTimeMs(s32 i_time) { mTimeMs = i_time; } s32 getTimeMs() { return mTimeMs; } u8 getNowCount() { return mNowCount; } @@ -178,16 +185,16 @@ public: mCollectCursorPosX = x; mCollectCursorPosY = y; } - void setMapDrugFlag(bool flag) { mMapDrugFlag = flag; } + void setMapDrugFlag(bool i_flag) { mMapDrugFlag = i_flag; } void offTempBit(int i_bit) { mTempBits &= ~(1 << i_bit); } void onTempBit(int i_bit) { mTempBits |= (1 << i_bit); } - bool isTempBit(int bit) { return mTempBits & (1 << bit); } - void offSub2DStatus(int bit) { mSub2DStatus &= ~(1 << bit); } - void onSub2DStatus(int bit) { mSub2DStatus |= 1 << bit; } - void set2DWidth(float width) { m2DWidth = width; } - void set2DHeight(float height) { m2DHeight = height; } - void set2DPosH(float posH) { m2DPosH = posH; } - void set2DPosV(float posV) { m2DPosV = posV; } + bool isTempBit(int i_bit) { return mTempBits & (1 << i_bit); } + void offSub2DStatus(int i_bit) { mSub2DStatus &= ~(1 << i_bit); } + void onSub2DStatus(int i_bit) { mSub2DStatus |= 1 << i_bit; } + void set2DWidth(f32 i_width) { m2DWidth = i_width; } + void set2DHeight(f32 i_height) { m2DHeight = i_height; } + void set2DPosH(f32 i_posH) { m2DPosH = i_posH; } + void set2DPosV(f32 i_posV) { m2DPosV = i_posV; } void onUseButton(int i_button) { mUseButton |= i_button; } f32 get2DWidth() { return m2DWidth; } f32 get2DHeight() { return m2DHeight; } @@ -195,10 +202,12 @@ public: u8 getGoldWolfMapType() { return mGoldWolfMapType; } bool isWindowAccept(int param_0) { return mWindowAccept & (1 << param_0); } void setHorseLifeCount(s16 i_count) { mHorseLifeCount = i_count; } + void resetTouchKeyCheck() { mTouchKeyCheck = 0; } + void resetWindowAccept() { mWindowAccept = 0xFFFF; } public: - /* 0x04 */ u8 unk4[4]; - /* 0x08 */ u64 unk8; + /* 0x04 */ u8 unk_0x4[4]; + /* 0x08 */ u64 unk_0x8; /* 0x10 */ void* mMsgResource; /* 0x14 */ void* mStageMsgResource; /* 0x18 */ void* mMsgUnitResource; @@ -207,25 +216,25 @@ public: /* 0x24 */ dMw_c* mMenuWindowClass; /* 0x28 */ CPaneMgr* mMeterItemPanePtr[4]; /* 0x38 */ WarpInfo_c mWarpInfo; - /* 0x54 */ f32 unk84; - /* 0x58 */ f32 unk88; - /* 0x5C */ f32 unk92; - /* 0x60 */ f32 unk96; - /* 0x64 */ f32 unk100; - /* 0x68 */ f32 unk104; - /* 0x6C */ f32 unk108; + /* 0x54 */ f32 unk_0x54; + /* 0x58 */ f32 unk_0x58; + /* 0x5C */ f32 unk_0x5c; + /* 0x60 */ f32 unk_0x60; + /* 0x64 */ f32 unk_0x64; + /* 0x68 */ f32 unk_0x68; + /* 0x6C */ f32 unk_0x6c; /* 0x70 */ f32 m2DWidth; /* 0x74 */ f32 m2DHeight; /* 0x78 */ f32 m2DPosH; /* 0x7C */ f32 m2DPosV; - /* 0x80 */ f32 unk128; + /* 0x80 */ f32 unk_0x80; /* 0x84 */ s32 mTimeMs; /* 0x88 */ s32 mMsgTimeMs; /* 0x8C */ s32 mMeterString; /* 0x90 */ u32 mTempBits; /* 0x94 */ s16 mMsgKeyWaitTimer; /* 0x96 */ s16 mHorseLifeCount; - /* 0x98 */ u16 unk152; + /* 0x98 */ u16 unk_0x98; /* 0x9A */ u16 mHotSpringTimer[4]; /* 0xA2 */ u16 mSub2DStatus; /* 0xA4 */ u16 mFloatingFlowID; @@ -239,13 +248,12 @@ public: /* 0xB4 */ u16 mWindowAccept; /* 0xB6 */ u16 mOilGaugeBackUp; /* 0xB8 */ u8 mDirectUseItem; - /* 0xB9 */ u8 mWindowStatus; // 0: normal play, 2: item wheel, 3: pause menu, 4: map, 10: pause - // menu submenus, 11: map in dungeon - /* 0xBA */ u8 unk186; + /* 0xB9 */ u8 mWindowStatus; // 0: normal play, 2: item wheel, 3: pause menu, 4: map, 10: pause menu submenus, 11: map in dungeon + /* 0xBA */ u8 unk_0xba; /* 0xBB */ u8 mMaxCount; /* 0xBC */ u8 mNowCount; /* 0xBD */ bool mShopTalkFlag; - /* 0xBE */ u8 unk190; + /* 0xBE */ u8 unk_0xbe; /* 0xBF */ u8 mMapStatus; /* 0xC0 */ u8 mWarpStatus; /* 0xC1 */ u8 mPauseStatus; @@ -265,7 +273,7 @@ public: /* 0xDB */ u8 mSaveBombItemMG; /* 0xDC */ u8 mRentalBombBagIdx; /* 0xDD */ u8 mMiniGameItemSetFlag; // 1: rented in game, 3: rented not in game - /* 0xDE */ u8 mMiniGameCount; + /* 0xDE */ s8 mMiniGameCount; /* 0xDF */ u8 mCollectCursorPosX; /* 0xE0 */ u8 mCollectCursorPosY; /* 0xE1 */ u8 mTableMapRegionNo; @@ -277,21 +285,28 @@ public: /* 0xE9 */ char mSaveStageName[8]; /* 0xF1 */ bool mFloatingMessageWakuVisible; /* 0xF2 */ bool mMapDrugFlag; - /* 0xF3 */ u8 unk243[5]; + /* 0xF3 */ u8 unk_0xf3[5]; }; extern dMeter2Info_c g_meter2_info; -void dMeter2Info_setSword(u8, bool); -void dMeter2Info_setCloth(u8 i_clothId, bool param_1); -void dMeter2Info_setShield(u8 i_itemId, bool param_1); +void dMeter2Info_setSword(u8 i_itemId, bool i_offItemBit); +void dMeter2Info_setCloth(u8 i_clothId, bool i_offItemBit); +void dMeter2Info_setShield(u8 i_itemId, bool i_offItemBit); void dMeter2Info_set2DVibration(); void dMeter2Info_set2DVibrationM(); void dMeter2Info_offUseButton(int pButton); bool dMeter2Info_is2DActiveTouchArea(); u8 dMeter2Info_getRecieveLetterNum(); -bool dMeter2Info_getPixel(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4, - f32 param_5, struct ResTIMG const* param_6); +bool dMeter2Info_getPixel(f32 i_posX, f32 i_posY, f32 param_2, f32 param_3, f32 i_sizeX, + f32 i_sizeY, struct ResTIMG const* i_resTimg); +const char* dMeter2Info_getPlusTextureName(); +const char* dMeter2Info_getNumberTextureName(int i_num); +int dMeter2Info_recieveLetter(); +u8 dMeter2Info_getNewLetterNum(); +int dMeter2Info_setNewLetterSender(); +bool dMeter2Info_isItemOpenCheck(); +bool dMeter2Info_isMapOpenCheck(); inline void dMeter2Info_Initialize() { g_meter2_info.init(); @@ -305,44 +320,44 @@ inline dMw_c* dMeter2Info_getMenuWindowClass() { return g_meter2_info.getMenuWindowClass(); } -inline void dMeter2Info_setWindowStatus(u8 status) { - g_meter2_info.setWindowStatus(status); +inline void dMeter2Info_setWindowStatus(u8 i_status) { + g_meter2_info.setWindowStatus(i_status); } inline CPaneMgr* dMeter2Info_getMeterItemPanePtr(s32 i_idx) { return g_meter2_info.getMeterItemPanePtr(i_idx); } -inline void dMeter2Info_getString(u32 param_0, char* param_1, JMSMesgEntry_c* param_2) { - g_meter2_info.getString(param_0, param_1, param_2); +inline void dMeter2Info_getString(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry) { + g_meter2_info.getString(i_stringID, o_string, i_msgEntry); } -inline void dMeter2Info_getStringKanji(u32 param_0, char* param_1, JMSMesgEntry_c* param_2) { - g_meter2_info.getStringKanji(param_0, param_1, param_2); +inline void dMeter2Info_getStringKanji(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry) { + g_meter2_info.getStringKanji(i_stringID, o_string, i_msgEntry); } -inline void dMeter2Info_getStringKana(u32 param_0, char* param_1, JMSMesgEntry_c* param_2) { - g_meter2_info.getStringKana(param_0, param_1, param_2); +inline void dMeter2Info_getStringKana(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry) { + g_meter2_info.getStringKana(i_stringID, o_string, i_msgEntry); } -inline f32 dMeter2Info_getStringLength(JUTFont* param_0, f32 param_1, f32 param_2, char* param_3) { - return g_meter2_info.getStringLength(param_0, param_1, param_2, param_3); +inline f32 dMeter2Info_getStringLength(JUTFont* i_font, f32 param_2, f32 param_3, char* i_string) { + return g_meter2_info.getStringLength(i_font, param_2, param_3, i_string); } -inline f32 dMeter2Info_getStringLength(J2DTextBox* param_0, char* param_1) { - return g_meter2_info.getStringLength(param_0, param_1); +inline f32 dMeter2Info_getStringLength(J2DTextBox* i_textbox, char* i_string) { + return g_meter2_info.getStringLength(i_textbox, i_string); } -inline void dMeter2Info_setHotSpringTimer(u8 time) { - g_meter2_info.setHotSpringTimer(time); +inline void dMeter2Info_setHotSpringTimer(u8 i_slotNo) { + g_meter2_info.setHotSpringTimer(i_slotNo); } inline u16 dMeter2Info_getOilGaugeBackUp() { return g_meter2_info.getOilGaugeBackUp(); } -inline void dMeter2Info_setSaveStageName(const char* name) { - g_meter2_info.setSaveStageName(name); +inline void dMeter2Info_setSaveStageName(const char* i_stageName) { + g_meter2_info.setSaveStageName(i_stageName); } inline u8 dMeter2Info_getInsectSelectType() { @@ -357,21 +372,20 @@ inline u8 dMeter2Info_getWarpStatus() { return g_meter2_info.getWarpStatus(); } -inline void dMeter2Info_setWarpStatus(u8 status) { - return g_meter2_info.setWarpStatus(status); +inline void dMeter2Info_setWarpStatus(u8 i_status) { + return g_meter2_info.setWarpStatus(i_status); } -inline int dMeter2Info_readItemTexture(u8 i_itemNo, void* param_1, J2DPicture* param_2, - void* param_3, J2DPicture* param_4, void* param_5, - J2DPicture* param_6, void* param_7, J2DPicture* param_8, - int param_9) { - return g_meter2_info.readItemTexture(i_itemNo, param_1, param_2, param_3, param_4, param_5, - param_6, param_7, param_8, param_9); +inline int dMeter2Info_readItemTexture(u8 i_itemNo, void* i_texBuf1, J2DPicture* i_pic1, void* i_texBuf2, + J2DPicture* i_pic2, void* i_texBuf3, J2DPicture* i_pic3, + void* i_texBuf4, J2DPicture* i_pic4, int param_9) { + return g_meter2_info.readItemTexture(i_itemNo, i_texBuf1, i_pic1, i_texBuf2, i_pic2, i_texBuf3, + i_pic3, i_texBuf4, i_pic4, param_9); } -inline void dMeter2Info_setItemColor(u8 param_0, J2DPicture* param_1, J2DPicture* param_2, - J2DPicture* param_3, J2DPicture* param_4) { - g_meter2_info.setItemColor(param_0, param_1, param_2, param_3, param_4); +inline void dMeter2Info_setItemColor(u8 i_itemNo, J2DPicture* i_pic1, J2DPicture* i_pic2, + J2DPicture* i_pic3, J2DPicture* i_pic4) { + g_meter2_info.setItemColor(i_itemNo, i_pic1, i_pic2, i_pic3, i_pic4); } inline u8 dMeter2Info_getWarpRoomNo() { @@ -390,24 +404,24 @@ inline const char* dMeter2Info_getWarpStageName() { return g_meter2_info.getWarpStageName(); } -inline void dMeter2Info_setNowCount(u8 count) { - g_meter2_info.setNowCount(count); +inline void dMeter2Info_setNowCount(u8 i_count) { + g_meter2_info.setNowCount(i_count); } -inline void dMeter2Info_setMaxCount(u8 count) { - g_meter2_info.setMaxCount(count); +inline void dMeter2Info_setMaxCount(u8 i_count) { + g_meter2_info.setMaxCount(i_count); } inline BOOL dMeter2Info_isDirectUseItem(int param_0) { return g_meter2_info.isDirectUseItem(param_0); } -inline bool dMeter2Info_isUseButton(int param_0) { - return g_meter2_info.isUseButton(param_0); +inline bool dMeter2Info_isUseButton(int i_buttonBit) { + return g_meter2_info.isUseButton(i_buttonBit); } -inline void dMeter2Info_setMeterMapClass(dMeterMap_c* p_map) { - g_meter2_info.setMeterMapClass(p_map); +inline void dMeter2Info_setMeterMapClass(dMeterMap_c* i_map) { + g_meter2_info.setMeterMapClass(i_map); } inline void dMeter2Info_decHotSpringTimer() { @@ -418,28 +432,28 @@ inline void dMeter2Info_allUseButton() { g_meter2_info.allUseButton(); } -inline void dMeter2Info_offUseButton(int flag) { - g_meter2_info.offUseButton(flag); +inline void dMeter2Info_offUseButton(int i_buttonBit) { + g_meter2_info.offUseButton(i_buttonBit); } inline void dMeter2Info_resetGameStatus() { g_meter2_info.resetGameStatus(); } -inline void dMeter2Info_onGameStatus(int status) { - g_meter2_info.onGameStatus(status); +inline void dMeter2Info_onGameStatus(int i_status) { + g_meter2_info.onGameStatus(i_status); } -inline void dMeter2Info_setMapStatus(u8 status) { - g_meter2_info.setMapStatus(status); +inline void dMeter2Info_setMapStatus(u8 i_status) { + g_meter2_info.setMapStatus(i_status); } inline u8 dMeter2Info_getMapStatus() { return g_meter2_info.getMapStatus(); } -inline void dMeter2Info_setPauseStatus(u8 status) { - g_meter2_info.setPauseStatus(status); +inline void dMeter2Info_setPauseStatus(u8 i_status) { + g_meter2_info.setPauseStatus(i_status); } inline void dMeter2Info_resetPauseStatus() { @@ -450,8 +464,8 @@ inline u8 dMeter2Info_getPauseStatus() { return g_meter2_info.getPauseStatus(); } -inline bool dMeter2Info_isGameStatus(int status) { - return g_meter2_info.isGameStatus(status); +inline bool dMeter2Info_isGameStatus(int i_status) { + return g_meter2_info.isGameStatus(i_status); } inline bool dMeter2Info_isTouchKeyCheck(int i_status) { @@ -463,24 +477,24 @@ inline bool dMeter2Info_isTouchKeyCheck_alt(int i_status) { return g_meter2_info.isTouchKeyCheck_alt(i_status); } -inline void dMeter2Info_setMapKeyDirection(u16 direction) { - g_meter2_info.setMapKeyDirection(direction); +inline void dMeter2Info_setMapKeyDirection(u16 i_direction) { + g_meter2_info.setMapKeyDirection(i_direction); } -inline bool dMeter2Info_isSub2DStatus(int flag) { - return g_meter2_info.isSub2DStatus(flag); +inline bool dMeter2Info_isSub2DStatus(int i_flag) { + return g_meter2_info.isSub2DStatus(i_flag); } -inline void dMeter2Info_offMenuInForce(int flag) { - g_meter2_info.offMenuInForce(flag); +inline void dMeter2Info_offMenuInForce(int i_flag) { + g_meter2_info.offMenuInForce(i_flag); } -inline bool dMeter2Info_isMenuInForce(int flag) { - return g_meter2_info.isMenuInForce(flag); +inline bool dMeter2Info_isMenuInForce(int i_flag) { + return g_meter2_info.isMenuInForce(i_flag); } -inline void dMeter2Info_setMenuWindowClass(dMw_c* p_menu) { - g_meter2_info.setMenuWindowClass(p_menu); +inline void dMeter2Info_setMenuWindowClass(dMw_c* i_menu) { + g_meter2_info.setMenuWindowClass(i_menu); } inline void dMeter2Info_resetWarpStatus() { @@ -495,16 +509,16 @@ inline u8 dMeter2Info_getWindowStatus() { return g_meter2_info.getWindowStatus(); } -inline void dMeter2Info_setMsgResource(void* res) { - g_meter2_info.setMsgResource(res); +inline void dMeter2Info_setMsgResource(void* i_res) { + g_meter2_info.setMsgResource(i_res); } -inline void dMeter2Info_setStageMsgResource(void* res) { - g_meter2_info.setStageMsgResource(res); +inline void dMeter2Info_setStageMsgResource(void* i_res) { + g_meter2_info.setStageMsgResource(i_res); } -inline void dMeter2Info_setMsgUnitResource(void* res) { - g_meter2_info.setMsgUnitResource(res); +inline void dMeter2Info_setMsgUnitResource(void* i_res) { + g_meter2_info.setMsgUnitResource(i_res); } inline void* dMeter2Info_getMsgResource() { @@ -519,16 +533,16 @@ inline void* dMeter2Info_getMsgUnitResource() { return g_meter2_info.getMsgUnitResource(); } -inline u8 dMeter2Info_getLightDropGetFlag(int i) { - return g_meter2_info.getLightDropGetFlag(i); +inline u8 dMeter2Info_getLightDropGetFlag(int i_no) { + return g_meter2_info.getLightDropGetFlag(i_no); } inline s32 dMeter2Info_getMeterStringType() { return g_meter2_info.getMeterStringType(); } -inline void dMeter2Info_setMeterClass(dMeter2_c* meter) { - g_meter2_info.setMeterClass(meter); +inline void dMeter2Info_setMeterClass(dMeter2_c* i_meter) { + g_meter2_info.setMeterClass(i_meter); } inline void dMeter2Info_onLifeGaugeSE() { @@ -551,8 +565,8 @@ inline void dMeter2Info_onShopTalkFlag() { g_meter2_info.onShopTalkFlag(); } -inline void dMeter2Info_setLightDropGetFlag(int index, u8 flag) { - g_meter2_info.setLightDropGetFlag(index, flag); +inline void dMeter2Info_setLightDropGetFlag(int i_no, u8 i_flag) { + g_meter2_info.setLightDropGetFlag(i_no, i_flag); } inline u8 dMeter2Info_getRentalBombBag() { @@ -563,24 +577,24 @@ inline u8 dMeter2Info_getMiniGameItemSetFlag() { return g_meter2_info.getMiniGameItemSetFlag(); } -inline void dMeter2Info_setMiniGameItem(u8 item) { - g_meter2_info.setMiniGameItem(item); +inline void dMeter2Info_setMiniGameItem(u8 i_minigameFlag) { + g_meter2_info.setMiniGameItem(i_minigameFlag); } -inline void dMeter2Info_resetMiniGameItem(bool param_0) { - g_meter2_info.resetMiniGameItem(param_0); +inline void dMeter2Info_resetMiniGameItem(bool i_saveItem) { + g_meter2_info.resetMiniGameItem(i_saveItem); } -inline void dMeter2Info_setTableMapRegionNo(u8 regionNo) { - g_meter2_info.setTableMapRegionNo(regionNo); +inline void dMeter2Info_setTableMapRegionNo(u8 i_regionNo) { + g_meter2_info.setTableMapRegionNo(i_regionNo); } inline void dMeter2Info_setGoldWolfMapType(u8 i_mapType) { g_meter2_info.setGoldWolfMapType(i_mapType); } -inline void dMeter2Info_changeWater(u8 bottleIdx) { - g_meter2_info.changeWater(bottleIdx); +inline void dMeter2Info_changeWater(u8 i_slotNo) { + g_meter2_info.changeWater(i_slotNo); } inline void dMeter2Info_warpInProc() { @@ -603,8 +617,8 @@ inline void dMeter2Info_onDirectUseItem(int param_0) { g_meter2_info.onDirectUseItem(param_0); } -inline void dMeter2Info_setFloatingFlow(u16 param_0, s16 param_1, bool param_2) { - g_meter2_info.setFloatingFlow(param_0, param_1, param_2); +inline void dMeter2Info_setFloatingFlow(u16 i_flowID, s16 i_msgTimer, bool i_wakuVisible) { + g_meter2_info.setFloatingFlow(i_flowID, i_msgTimer, i_wakuVisible); } inline u8 dMeter2Info_getGameOverType() { @@ -627,8 +641,8 @@ inline s32 dMeter2Info_getTimeMs() { return g_meter2_info.getTimeMs(); } -inline void dMeter2Info_setMsgTimeMs(s32 msgTime) { - g_meter2_info.setMsgTimeMs(msgTime); +inline void dMeter2Info_setMsgTimeMs(s32 i_msgTime) { + g_meter2_info.setMsgTimeMs(i_msgTime); } inline void dMeter2Info_setTimeMs(s32 i_time) { @@ -731,36 +745,36 @@ inline bool dMeter2Info_isShopTalkFlag() { return g_meter2_info.isShopTalkFlag(); } -inline void dMeter2Info_setMapDrugFlag(bool flag) { - g_meter2_info.setMapDrugFlag(flag); +inline void dMeter2Info_setMapDrugFlag(bool i_flag) { + g_meter2_info.setMapDrugFlag(i_flag); } -inline bool dMeter2Info_isTempBit(int bit) { - return g_meter2_info.isTempBit(bit); +inline bool dMeter2Info_isTempBit(int i_bit) { + return g_meter2_info.isTempBit(i_bit); } -inline void dMeter2Info_offSub2DStatus(int bit) { - g_meter2_info.offSub2DStatus(bit); +inline void dMeter2Info_offSub2DStatus(int i_bit) { + g_meter2_info.offSub2DStatus(i_bit); } -inline void dMeter2Info_onSub2DStatus(int bit) { - g_meter2_info.onSub2DStatus(bit); +inline void dMeter2Info_onSub2DStatus(int i_bit) { + g_meter2_info.onSub2DStatus(i_bit); } -inline void dMeter2Info_set2DWidth(float width) { - g_meter2_info.set2DWidth(width); +inline void dMeter2Info_set2DWidth(f32 i_width) { + g_meter2_info.set2DWidth(i_width); } -inline void dMeter2Info_set2DHeight(float height) { - g_meter2_info.set2DHeight(height); +inline void dMeter2Info_set2DHeight(f32 i_height) { + g_meter2_info.set2DHeight(i_height); } -inline void dMeter2Info_set2DPosH(float posH) { - g_meter2_info.set2DPosH(posH); +inline void dMeter2Info_set2DPosH(f32 i_posH) { + g_meter2_info.set2DPosH(i_posH); } -inline void dMeter2Info_set2DPosV(float posV) { - g_meter2_info.set2DPosV(posV); +inline void dMeter2Info_set2DPosV(f32 i_posV) { + g_meter2_info.set2DPosV(i_posV); } inline void dMeter2Info_offShopTalkFlag() { @@ -780,7 +794,7 @@ inline f32 dMeter2Info_get2DHeight() { } inline void dMeter2Info_setWarpInfo(const char* i_stageName, const cXyz& i_position, s16 i_angle, - u8 i_roomNo, u8 param_4, u8 i_warpPlayerNo) { + u8 i_roomNo, u8 param_4, u8 i_warpPlayerNo) { g_meter2_info.setWarpInfo(i_stageName, i_position, i_angle, i_roomNo, param_4, i_warpPlayerNo); } @@ -812,20 +826,12 @@ inline bool dMeter2Info_isNextStage(const char*, s16, s16, s16) { return false; } -inline void dMeter2Info_setFloatingMessage(u16 pMessageID, s16 pMessageTimer, bool pWakuVisible) { - g_meter2_info.setFloatingMessage(pMessageID, pMessageTimer, pWakuVisible); +inline void dMeter2Info_setFloatingMessage(u16 i_msgID, s16 i_msgTimer, bool i_wakuVisible) { + g_meter2_info.setFloatingMessage(i_msgID, i_msgTimer, i_wakuVisible); } inline void dMeter2Info_setMiniGameCount(s8 i_count) { g_meter2_info.setMiniGameCount(i_count); } -const char* dMeter2Info_getPlusTextureName(); -const char* dMeter2Info_getNumberTextureName(int pIndex); -int dMeter2Info_recieveLetter(); -u8 dMeter2Info_getNewLetterNum(); -int dMeter2Info_setNewLetterSender(); -bool dMeter2Info_isItemOpenCheck(); -bool dMeter2Info_isMapOpenCheck(); - #endif /* D_METER_D_METER2_INFO_H */ diff --git a/include/d/d_msg_class.h b/include/d/d_msg_class.h index f77d09d9de6..9cb58d7ebc2 100644 --- a/include/d/d_msg_class.h +++ b/include/d/d_msg_class.h @@ -2,37 +2,40 @@ #define D_MSG_D_MSG_CLASS_H #include "JSystem/JMessage/control.h" +#include "JSystem/JMessage/JMessage.h" #include "SSystem/SComponent/c_xyz.h" +class JMSMesgEntry_c { +public: + /* 0x0 */ u32 string_offset; + + // Attributes + /* 0x04 */ u16 message_id; + /* 0x06 */ u16 unk_0x6; + /* 0x08 */ u8 unk_0x8; + /* 0x09 */ u8 display_style; + /* 0x0A */ u8 print_style; + /* 0x0B */ u8 position; + /* 0x0C */ u8 unk_0xc; + /* 0x0D */ u8 unk_0xd; + /* 0x0E */ u8 unk_0xe; + /* 0x0F */ u8 camera_id; + /* 0x10 */ u32 unk_0x10; +}; + +class JMSMesgInfo_c { +public: + /* 0x00 */ bmg_section_t header; // section header + /* 0x08 */ u16 entry_num; // number of entries in this section + /* 0x0A */ u16 entry_size; // size of an entry + /* 0x0C */ u8 padding[4]; // padding + /* 0x10 */ JMSMesgEntry_c entries[0]; +}; + class COutFont_c; class J2DTextBox; class JUTFont; -struct JMSMesgEntry_c { - /* 0x00 */ u32 mStringOffset; - /* 0x04 */ u16 mStringId; - /* 0x06 */ u16 field_0x06; - /* 0x08 */ u8 field_0x08; - /* 0x09 */ u8 field_0x09; - /* 0x0A */ u8 field_0x0a; - /* 0x0B */ u8 field_0x0b; - /* 0x0C */ u8 field_0x0c; - /* 0x0D */ u8 field_0x0d; - /* 0x0E */ u8 field_0x0e; - /* 0x0F */ u8 field_0x0f; - /* 0x10 */ u32 field_0x10; -}; // Size: 0x14 - -struct JMSMesgHeader_c { - /* 0x00 */ u32 magic; - /* 0x04 */ u32 sectionSize; - /* 0x08 */ u16 entryCount; - /* 0x0A */ u16 entrySize; - /* 0x0C */ u16 field_0xc; - /* 0x0E */ u16 field_0xe; - /* 0x10 */ JMSMesgEntry_c entries[0]; -}; // Size: 0x10 - class STControl; class dMsgObject_c; struct jmessage_tReference : public JMessage::TReference { diff --git a/include/d/d_msg_unit.h b/include/d/d_msg_unit.h index a3a687b06db..67e50b3439c 100644 --- a/include/d/d_msg_unit.h +++ b/include/d/d_msg_unit.h @@ -1,48 +1,7 @@ #ifndef D_MSG_D_MSG_UNIT_H #define D_MSG_D_MSG_UNIT_H -#include "global.h" - -// Struct definitions might be wrong -typedef struct bmg_section_t { - u32 msgType; // sectionType - u32 size; // total size of the section - u8 data[0]; // section data -} bmg_section_t; - -typedef struct bmg_header_t { - /* 0x00 */ char magic[8]; // = BMG_MAGIC - /* 0x08 */ u32 size; // total size of file - /* 0x0c */ u32 n_sections; // number of sections - /* 0x10 */ u32 encoding; // text encoding - /* 0x11 */ u8 unknown[12]; // unknown data - /* 0x20 */ bmg_section_t section[0]; // first section header -} bmg_header_t; - -typedef struct inf1_entry_t { - u32 dat1EntryOffset; - u16 startFrame; - u16 endFrame; -} inf1_entry_t; - -typedef struct inf1_section_t { - /* 0x00 */ u32 msgType; // sectionType - /* 0x04 */ u32 size; // total size of the section - /* 0x08 */ u16 entryCount; - /* 0x0A */ u16 entryLength; - /* 0x0C */ u16 msgArchiveId; - /* 0x0E */ inf1_entry_t entries[0]; -} inf1_section_t; - -typedef struct str1_entry_t { - char str[0]; -} str1_entry_t; - -typedef struct str1_section_t { - /* 0x00 */ u32 msgType; // sectionType - /* 0x04 */ u32 size; // total size of the section - /* 0x08 */ str1_entry_t entries[0]; -} str1_section_t; +#include "JSystem/JMessage/JMessage.h" class dMsgUnit_c { public: diff --git a/src/JSystem/JMessage/resource.cpp b/src/JSystem/JMessage/resource.cpp index 8de8effe4c1..0b0faafe998 100644 --- a/src/JSystem/JMessage/resource.cpp +++ b/src/JSystem/JMessage/resource.cpp @@ -5,6 +5,7 @@ #include "JSystem/JMessage/resource.h" #include "JSystem/JGadget/search.h" +#include "JSystem/JGadget/define.h" #include #include "string.h" @@ -205,8 +206,73 @@ bool JMessage::TParse::parseHeader_next(void const** ppData_inout, u32* puBlock_ /* 802A92F4-802A9490 2A3C34 019C+00 1/0 0/0 0/0 .text * parseBlock_next__Q28JMessage6TParseFPPCvPUlUl */ -bool JMessage::TParse::parseBlock_next(void const** param_0, u32* param_1, u32 param_2) { - // NONMATCHING +bool JMessage::TParse::parseBlock_next(void const** ppData_inout, u32* puData_out, u32 param_2) { + JUT_ASSERT(401, ppData_inout!=0); + JUT_ASSERT(402, puData_out!=0); + + const void* pData = *ppData_inout; + JUT_ASSERT(404, pData!=0); + + data::TParse_TBlock sp34(pData); + + *ppData_inout = sp34.getNext(); + *puData_out = sp34.get_size(); + + TResourceContainer::TCResource& rcResource = pContainer_->resContainer_; + JUT_ASSERT(412, pResource_==&*--(rcResource.end())); + + u32 sp30 = sp34.get_type(); + switch (sp30) { + case 'INF1': + pResource_->setData_block_info(pData); + break; + case 'FLI1': + break; + case 'FLW1': + break; + case 'DAT1': + pResource_->setData_block_messageText(pData); + u16 temp_r26 = pResource_->getGroupID(); + + if (param_2 & 0x80) { + JGadget::TLinkList::iterator sp2C(rcResource.begin()); + JMessage::TResource* sp28; + while ((sp28 = &*sp2C) != pResource_) { + if ((u16)temp_r26 != sp28->getGroupID()) { + ++sp2C; + } else { + sp2C = rcResource.Erase_destroy(sp28); + } + } + } else { + #ifdef DEBUG + JMessage::TResource* sp24 = rcResource.Get_groupID(temp_r26); + if (sp24 != pResource_) { + JGadget_outMessage sp148(JGadget_outMessage::warning, __FILE__, 444); + sp148 << "group-ID already exist : " << temp_r26; + } + #endif + } + break; + case 'STR1': + pResource_->setData_block_stringAttribute(pData); + break; + case 'MID1': + pResource_->setData_block_messageID(pData); + break; + default: + #ifdef DEBUG + JGadget_outMessage sp148(JGadget_outMessage::warning, __FILE__, 463); + sp148 << "unknown block : " << sp30; + #endif + + if (!(param_2 & 0x40)) { + return 0; + } + break; + } + + return 1; } /* 802A9490-802A94A8 2A3DD0 0018+00 1/0 0/0 0/0 .text diff --git a/src/d/actor/d_a_balloon_2D.cpp b/src/d/actor/d_a_balloon_2D.cpp index f151d2707a7..ef59090e294 100644 --- a/src/d/actor/d_a_balloon_2D.cpp +++ b/src/d/actor/d_a_balloon_2D.cpp @@ -684,7 +684,7 @@ extern actor_process_profile_definition g_profile_BALLOON2D = { fpcPi_CURRENT_e, // mListPrio PROC_BALLOON2D, // mProcName &g_fpcLf_Method.base, // sub_method - sizeof(JMSMesgEntry_c), // mSize + sizeof(daBalloon2D_c), // mSize 0, // mSizeOther 0, // mParameters &g_fopAc_Method.base, // sub_method diff --git a/src/d/d_meter2_draw.cpp b/src/d/d_meter2_draw.cpp index 1fe6589461e..f979af3c8b5 100644 --- a/src/d/d_meter2_draw.cpp +++ b/src/d/d_meter2_draw.cpp @@ -3346,7 +3346,7 @@ char* dMeter2Draw_c::getActionString(u8 i_action, u8 i_type, u8* param_2) { } if (param_2 != NULL) { - *param_2 = mesg_entry.field_0x0a; + *param_2 = mesg_entry.print_style; if (g_drawHIO.mButtonATextActionID == 0x3E6) { *param_2 = 7; @@ -3363,7 +3363,7 @@ char* dMeter2Draw_c::getActionString(u8 i_action, u8 i_type, u8* param_2) { } if (param_2 != NULL) { - *param_2 = mesg_entry.field_0x0a; + *param_2 = mesg_entry.print_style; if (i_action_num[i_action] == 0x3E6) { *param_2 = 7; diff --git a/src/d/d_meter2_info.cpp b/src/d/d_meter2_info.cpp index 6d0a2cddba4..c4bec739ebd 100644 --- a/src/d/d_meter2_info.cpp +++ b/src/d/d_meter2_info.cpp @@ -1,17 +1,172 @@ -// -// Generated By: dol2asm -// Translation Unit: d/d_meter2_info -// - #include "d/d_meter2_info.h" #include "JSystem/J2DGraph/J2DTextBox.h" #include "JSystem/JUtility/JUTFont.h" +#include "JSystem/JMessage/JMessage.h" #include "d/actor/d_a_npc.h" #include "d/d_meter2.h" #include "d/d_meter_map.h" #include "d/d_msg_object.h" +#include "d/d_msg_class.h" #include "d/d_item_data.h" +enum ITEMICON_RES_FILE_ID { + ITEMICON_BTI_ARI_MESU_00=0x3, + ITEMICON_BTI_ARI_OSU_00=0x4, + ITEMICON_BTI_BATTA_MESU_00=0x5, + ITEMICON_BTI_BATTA_OSU_00=0x6, + ITEMICON_BTI_CHOCHO_MESU_00=0x7, + ITEMICON_BTI_CHOCHO_OSU_00=0x8, + ITEMICON_BTI_DANGOMUSHI_MESU_00=0x9, + ITEMICON_BTI_DANGOMUSHI_OSU_00=0xA, + ITEMICON_BTI_IM_BOM_MUSHI_48=0xB, + ITEMICON_BTI_IM_BOM_NORMAL_48=0xC, + ITEMICON_BTI_IM_BOM_SUICHU_48=0xD, + ITEMICON_BTI_IM_BOTTLE=0xE, + ITEMICON_BTI_IM_BOTTLE_HATCHINOKO=0xF, + ITEMICON_BTI_IM_BOTTLE_MIMIZU=0x10, + ITEMICON_BTI_IM_BOTTLE_NAKAMI=0x11, + ITEMICON_BTI_IM_BOTTLE_NAKAMI_HALF=0x12, + ITEMICON_BTI_IM_BOTTLE_NAKAMI_NAKAMI_SOUP=0x13, + ITEMICON_BTI_IM_BOTTLE_POU=0x14, + ITEMICON_BTI_IM_CHEESE_48=0x15, + ITEMICON_BTI_IM_COPY_ROD_48=0x16, + ITEMICON_BTI_IM_D_MKEY_3PARTS_MIX_48=0x17, + ITEMICON_BTI_IM_FISHING_48=0x18, + ITEMICON_BTI_IM_FISHING_HACHINOKO_48=0x19, + ITEMICON_BTI_IM_FISHING_MIMIZU_48=0x1A, + ITEMICON_BTI_IM_FISHING_SANGO_MIMIKAZARI=0x1B, + ITEMICON_BTI_IM_FISHING_SANGO_MIMIKAZARI_HACHINOKO=0x1C, + ITEMICON_BTI_IM_FISHING_SANGO_MIMIKAZARI_MIMIZU=0x1D, + ITEMICON_BTI_IM_HONNY_48=0x1E, + ITEMICON_BTI_IM_HOOKSHOT_48=0x1F, + ITEMICON_BTI_IM_IRONBALL_48=0x20, + ITEMICON_BTI_IM_ITEM_ICON_BOSS_KEY_48=0x21, + ITEMICON_BTI_IM_KAKIOKI_48=0x22, + ITEMICON_BTI_IM_KANTERA_OFF_48=0x23, + ITEMICON_BTI_IM_KINOBOU_48=0x24, + ITEMICON_BTI_IM_MAGNE_BOOTS_06=0x25, + ITEMICON_BTI_IM_MUSUKO_48=0x26, + ITEMICON_BTI_IM_NAVI_TRY_00_07=0x27, + ITEMICON_BTI_IM_OBACHAN_48=0x28, + ITEMICON_BTI_IM_PUMPKIN_48=0x29, + ITEMICON_BTI_IM_SANGO_MIMIKAZARI_48=0x2A, + ITEMICON_BTI_IM_SPPINER_48=0x2B, + ITEMICON_BTI_IM_W_HOOKSHOT_48=0x2C, + ITEMICON_BTI_IM_ZELDA_ITEM_ICON_RUPY_13=0x2D, + ITEMICON_BTI_IM_ZELDA_ITEM_ICON_RUPY_L_13=0x2E, + ITEMICON_BTI_KABUTO_MESU_00=0x2F, + ITEMICON_BTI_KABUTO_OSU_00=0x30, + ITEMICON_BTI_KAGERO_MESU_00=0x31, + ITEMICON_BTI_KAGERO_OSU_00=0x32, + ITEMICON_BTI_KAMAKIRI_MESU_00=0x33, + ITEMICON_BTI_KAMAKIRI_OSU_00=0x34, + ITEMICON_BTI_KATATUMURI_MESU_00=0x35, + ITEMICON_BTI_KATATUMURI_OSU_00=0x36, + ITEMICON_BTI_KUWAGATA_MESU_00=0x37, + ITEMICON_BTI_KUWAGATA_OSU_00=0x38, + ITEMICON_BTI_LETTER_=0x39, + ITEMICON_BTI_NANAHUSHI_MESU_00=0x3A, + ITEMICON_BTI_NANAHUSHI_OSU_00=0x3B, + ITEMICON_BTI_NI_HAIRIANOTATE_48=0x3C, + ITEMICON_BTI_NI_ITEM_ICON_MAKIMONO=0x3D, + ITEMICON_BTI_NI_ITEM_ICON_POU=0x3E, + ITEMICON_BTI_NI_KEY_SHINSHITU_48=0x3F, + ITEMICON_BTI_NI_KINOTATE_48=0x40, + ITEMICON_BTI_NI_MAGICARMOR_48=0x41, + ITEMICON_BTI_NI_MASTERSWORD_48=0x42, + ITEMICON_BTI_NI_MKEY_PARTS1_GET_47_56=0x43, + ITEMICON_BTI_NI_MKEY_PARTS2_47_56=0x44, + ITEMICON_BTI_NI_MKEY_PARTS2_GET_47_56=0x45, + ITEMICON_BTI_NI_MKEY_PARTS3_GET_47_56=0x46, + ITEMICON_BTI_NI_SAIFU1_48=0x47, + ITEMICON_BTI_NI_SAIFU2_48=0x48, + ITEMICON_BTI_NI_SAIFU3_48=0x49, + ITEMICON_BTI_NI_YADUTU1_48=0x4A, + ITEMICON_BTI_NI_YADUTU2_48=0x4B, + ITEMICON_BTI_NI_YADUTU3_48=0x4C, + ITEMICON_BTI_NI_ZOURANOFUKU_48=0x4D, + ITEMICON_BTI_O_FISHING_LURE=0x4E, + ITEMICON_BTI_O_GD_KOMONSHO=0x4F, + ITEMICON_BTI_O_HEART_KAKERA_48=0x50, + ITEMICON_BTI_O_HEART_UTUWA_48=0x51, + ITEMICON_BTI_O_HIKARI_POD=0x52, + ITEMICON_BTI_ST_ARROWS=0x53, + ITEMICON_BTI_ST_BILL=0x54, + ITEMICON_BTI_ST_BOMPOACH_LV1=0x55, + ITEMICON_BTI_ST_BOMPOACH_LV2=0x56, + ITEMICON_BTI_ST_COPY_ROD_B=0x57, + ITEMICON_BTI_ST_FIGURE=0x58, + ITEMICON_BTI_ST_HAWKEYE=0x59, + ITEMICON_BTI_ST_LEN_LETTER=0x5A, + ITEMICON_BTI_ST_PACHINKO=0x5B, + ITEMICON_BTI_ST_PACHINKO_SEED=0x5C, + ITEMICON_BTI_ST_PENDANT=0x5D, + ITEMICON_BTI_TENTOMUSHI_MESU_00=0x5E, + ITEMICON_BTI_TENTOMUSHI_OSU_00=0x5F, + ITEMICON_BTI_TONBO_MESU_00=0x60, + ITEMICON_BTI_TONBO_OSU_00=0x61, + ITEMICON_BTI_TT_BOOMERANG_05=0x62, + ITEMICON_BTI_TT_BOTTLE_48=0x63, + ITEMICON_BTI_TT_BOTTLE_HALFMILK_48=0x64, + ITEMICON_BTI_TT_BOTTLE_MILK_48=0x65, + ITEMICON_BTI_TT_BOTTLE_OIL_48=0x66, + ITEMICON_BTI_TT_BOTTLE_RECOVERY_48=0x67, + ITEMICON_BTI_TT_BOTTLE_WATER_48=0x68, + ITEMICON_BTI_TT_BOW_06=0x69, + ITEMICON_BTI_TT_HOOK_SHOT_01=0x6A, + ITEMICON_BTI_TT_ITUMONOFUKU_S3TC=0x6B, + ITEMICON_BTI_TT_KANTERA_48=0x6C, + ITEMICON_BTI_TT_KEY_BOSS_48=0x6D, + ITEMICON_BTI_TT_KEY_NORMAL_48=0x6E, + ITEMICON_BTI_TT_KMPS_48=0x6F, + ITEMICON_BTI_TT_KOKIRINOKEN_S3_TC=0x70, + ITEMICON_BTI_TT_MAP_48=0x71, + ITEMICON_BTI_TT_SWORD_48=0x72, + ITEMICON_BTI_TT_WOOD_SHIELD_48=0x73, + ITEMICON_BTI_TTDELUNOTATE_S3_TC=0x74, + ITEMICON_BTI_ZELDA_HEART_PARTS1_GET=0x75, + ITEMICON_BTI_ZELDA_HEART_PARTS2_GET=0x76, + ITEMICON_BTI_ZELDA_HEART_PARTS3_GET=0x77, + ITEMICON_BTI_ZELDA_HEART_PARTS4_GET=0x78, +}; + +enum dMeter2_ItemType { + ItemType_DEFAULT, + ItemType_GREEN_RUPEE, + ItemType_BLUE_RUPEE, + ItemType_YELLOW_RUPEE, + ItemType_RED_RUPEE, + ItemType_PURPLE_RUPEE, + ItemType_ORANGE_RUPEE, + ItemType_SILVER_RUPEE, + ItemType_EMPTY_BOTTLE, + ItemType_RED_BOTTLE, + ItemType_GREEN_BOTTLE, + ItemType_BLUE_BOTTLE, + ItemType_MILK_BOTTLE, + ItemType_HALF_MILK_BOTTLE, + ItemType_OIL_BOTTLE, + ItemType_WATER_BOTTLE, + ItemType_HOT_SPRING, + ItemType_LV1_SOUP, + ItemType_LV2_3_SOUP, + ItemType_UGLY_SOUP, + ItemType_CHUCHU_RED, + ItemType_CHUCHU_BLUE, + ItemType_CHUCHU_GREEN, + ItemType_CHUCHU_YELLOW, + ItemType_CHUCHU_PURPLE, + ItemType_CHUCHU_RARE, + ItemType_CHUCHU_BLACK, + ItemType_POU_FIRE, + ItemType_FAIRY, + ItemType_BEE_CHILD, + ItemType_WORM, + ItemType_DROP_BOTTLE, + ItemType_BOMB_ARROW = 33, + ItemType_HAWK_ARROW, +}; + /* 8021BDDC-8021BE20 21671C 0044+00 1/1 0/0 0/0 .text __ct__13dMeter2Info_cFv */ dMeter2Info_c::dMeter2Info_c() { init(); @@ -33,52 +188,58 @@ void dMeter2Info_c::init() { mMeterItemPanePtr[i] = NULL; } - unk8 = 0; + unk_0x8 = 0; mSub2DStatus = 0; mHorseLifeCount = 0; mMsgKeyWaitTimer = 0; - unk152 = 0; + unk_0x98 = 0; mWindowStatus = 0; - unk186 = 0; + unk_0xba = 0; + + unk_0x54 = 0.0f; + unk_0x58 = 0.0f; + unk_0x5c = 0.0f; + unk_0x60 = 1.0f; + unk_0x64 = 30.0f; + unk_0x68 = 304.0f; + unk_0x6c = 224.0f; - unk84 = 0.0f; - unk88 = 0.0f; - unk92 = 0.0f; - unk96 = 1.0f; - unk100 = 30.0f; - unk104 = 304.0f; - unk108 = 224.0f; m2DWidth = 608.0f; m2DHeight = 448.0f; m2DPosH = 0.0f; m2DPosV = 0.0f; - unk128 = 0.0f; + unk_0x80 = 0.0f; + mTimeMs = 0; mMsgTimeMs = 0; + mNowCount = 0; mMaxCount = 0; + mShopTalkFlag = false; mMapStatus = 0; mMapKeyDirection = 0; mBlinkButton = 0; mOilGaugeBackUp = 0; - mUseButton = -1; - mDirectUseItem = 0; - mGameStatus = 0; - mTouchKeyCheck = 0; - mWindowAccept = -1; + + allUseButton(); + resetDirectUseItem(); + resetGameStatus(); + resetTouchKeyCheck(); + resetWindowAccept(); + mMeterString = 0; - mFloatingFlowID = -1; - mFloatingMessageID = -1; + mFloatingFlowID = 0xFFFF; + mFloatingMessageID = 0xFFFF; mFloatingMessageTimer = 0; mFloatingMessageWakuVisible = 0; + resetWarpStatus(); - mPauseStatus = 0; + resetPauseStatus(); mGameOverType = 0; mInsectSelectType = 0xFF; - cXyz tmp(0.0f, 0.0f, 0.0f); - setWarpInfo("", tmp, 0, 0, 0, 0); + setWarpInfo("", cXyz(0.0f, 0.0f, 0.0f), 0, 0, 0, 0); for (int i = 0; i < 4; i++) { changeWater(i + SLOT_11); @@ -99,18 +260,20 @@ void dMeter2Info_c::init() { mSaveArrowNumMG = 0; mSaveBowItemMG = 0; mSaveBombItemMG = 0; + mRentalBombBagIdx = 0xFF; mMiniGameItemSetFlag = 0; mMiniGameCount = 0; + setSaveStageName(""); - mCollectCursorPosX = 0; - mCollectCursorPosY = 0; + + setCollectCursorPosXY(0, 0); mTableMapRegionNo = 0xFF; mGoldWolfMapType = 0; mScopeZoomPointer = 0; mItemExplainWindowStatus = 0; mLifeGaugeSE = 0; - mMapDrugFlag = 0; + mMapDrugFlag = false; for (int i = 0; i < 3; i++) { if (dComIfGs_isLightDropGetFlag(i)) { @@ -123,41 +286,45 @@ void dMeter2Info_c::init() { /* 8021C0E0-8021C11C 216A20 003C+00 0/0 1/1 2/2 .text setFloatingMessage__13dMeter2Info_cFUssb */ -int dMeter2Info_c::setFloatingMessage(u16 msgID, s16 msgTimer, bool wakuVisible) { +int dMeter2Info_c::setFloatingMessage(u16 i_msgID, s16 i_msgTimer, bool i_wakuVisible) { if (dComIfGp_event_runCheck()) { return 0; } mFloatingFlowID = 0xFFFF; - mFloatingMessageID = msgID; - mFloatingMessageTimer = msgTimer; - mFloatingMessageWakuVisible = wakuVisible; + mFloatingMessageID = i_msgID; + mFloatingMessageTimer = i_msgTimer; + mFloatingMessageWakuVisible = i_wakuVisible; return 1; } /* 8021C11C-8021C1DC 216A5C 00C0+00 0/0 0/0 1/1 .text setFloatingFlow__13dMeter2Info_cFUssb */ -int dMeter2Info_c::setFloatingFlow(u16 flowID, s16 msgTimer, bool wakuVisible) { +int dMeter2Info_c::setFloatingFlow(u16 i_flowID, s16 i_msgTimer, bool i_wakuVisible) { if (dComIfGp_event_runCheck()) { return 0; } - mFloatingFlowID = flowID; + mFloatingFlowID = i_flowID; dMsgFlow_c flow; - flow.init(NULL, flowID, 0, NULL); + flow.init(NULL, i_flowID, 0, NULL); flow.doFlow(NULL, NULL, 0); mFloatingFlowID = 0xFFFF; mFloatingMessageID = flow.getMsgNo(); - mFloatingMessageTimer = msgTimer; - mFloatingMessageWakuVisible = wakuVisible; + mFloatingMessageTimer = i_msgTimer; + mFloatingMessageWakuVisible = i_wakuVisible; return 1; } /* 8021C1DC-8021C1F0 216B1C 0014+00 0/0 4/4 0/0 .text isFloatingMessageVisible__13dMeter2Info_cFv */ bool dMeter2Info_c::isFloatingMessageVisible() { - return mFloatingMessageTimer > 0; + if (mFloatingMessageTimer > 0) { + return true; + } + + return false; } /* 8021C1F0-8021C218 216B30 0028+00 0/0 1/1 0/0 .text decFloatingMessageTimer__13dMeter2Info_cFv @@ -168,15 +335,16 @@ s16 dMeter2Info_c::decFloatingMessageTimer() { } else { mFloatingMessageTimer = 0; } + return mFloatingMessageTimer; } /* 8021C218-8021C238 216B58 0020+00 0/0 3/3 0/0 .text resetFloatingMessage__13dMeter2Info_cFv */ void dMeter2Info_c::resetFloatingMessage() { - mFloatingFlowID = -1; - mFloatingMessageID = -1; + mFloatingFlowID = 0xFFFF; + mFloatingMessageID = 0xFFFF; mFloatingMessageTimer = 0; - mFloatingMessageWakuVisible = 0; + mFloatingMessageWakuVisible = false; } /* 8021C238-8021C250 216B78 0018+00 0/0 2/2 0/0 .text decMsgKeyWaitTimer__13dMeter2Info_cFv */ @@ -188,13 +356,12 @@ void dMeter2Info_c::decMsgKeyWaitTimer() { /* 8021C250-8021C370 216B90 0120+00 0/0 16/16 0/0 .text * getString__13dMeter2Info_cFUlPcP14JMSMesgEntry_c */ -void dMeter2Info_c::getString(u32 stringID, char* outStr, JMSMesgEntry_c* p_msgEntry) { - strcpy(outStr, ""); +void dMeter2Info_c::getString(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry) { + strcpy(o_string, ""); u8* msgRes; if (mMsgResource == NULL) { - JKRArchive* msgDtArc = dComIfGp_getMsgDtArchive(0); - msgRes = (u8*)JKRArchive::getGlbResource('ROOT', "zel_00.bmg", msgDtArc); + msgRes = (u8*)JKRGetTypeResource('ROOT', "zel_00.bmg", dComIfGp_getMsgDtArchive(0)); if (msgRes == NULL) { return; } @@ -202,21 +369,22 @@ void dMeter2Info_c::getString(u32 stringID, char* outStr, JMSMesgEntry_c* p_msgE msgRes = (u8*)mMsgResource; } - u8* inf = msgRes + 0x20; - u32 stringOffset = (*(u32*)(msgRes + 0x24)); - u8* strPtr = inf + stringOffset + 8; + JMSMesgInfo_c* bmg_inf = (JMSMesgInfo_c*)(msgRes + sizeof(bmg_header_t)); + u8* bmg_data = (u8*)bmg_inf + bmg_inf->header.size + sizeof(bmg_section_t); // pointer to start of message data - u16 i; + char* string_ptr = NULL; + for (u16 i = 0; i < bmg_inf->entry_num; i++) { + u8* entry = ((u8*)bmg_inf + (i * sizeof(JMSMesgEntry_c))); - for (i = 0; i < *(u16*)(inf + 8); i++) { - u8* entry = (inf + (i * 0x14)); + // check if i_stringID equals the message entry "Message ID" + if (i_stringID == *(u16*)(entry + 0x14)) { + string_ptr = (char*)(bmg_data + *(u32*)(entry + 0x10)); // use entry "String Offset" to get string pointer + strcpy(o_string, string_ptr); - if (stringID == *(u16*)(entry + 0x14)) { - strcpy(outStr, (char*)(strPtr + *(u32*)(entry + 0x10))); - if (p_msgEntry == NULL) { - return; + if (i_msgEntry != NULL) { + memcpy(i_msgEntry, entry + 0x10, sizeof(JMSMesgEntry_c)); } - memcpy(p_msgEntry, entry + 0x10, 0x14); + return; } } @@ -228,68 +396,189 @@ void dMeter2Info_c::getString(u32 stringID, char* outStr, JMSMesgEntry_c* p_msgE /* 8021C370-8021C544 216CB0 01D4+00 0/0 1/1 0/0 .text * getStringKana__13dMeter2Info_cFUlPcP14JMSMesgEntry_c */ -void dMeter2Info_c::getStringKana(u32 param_0, char* param_1, JMSMesgEntry_c* param_2) { - // NONMATCHING +// NONMATCHING - regalloc +void dMeter2Info_c::getStringKana(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry) { + strcpy(o_string, ""); + + u8* msgRes; + if (mMsgResource == NULL) { + msgRes = (u8*)JKRGetTypeResource('ROOT', "zel_00.bmg", dComIfGp_getMsgDtArchive(0)); + if (msgRes == NULL) { + return; + } + } else { + msgRes = (u8*)mMsgResource; + } + + JMSMesgInfo_c* bmg_inf = (JMSMesgInfo_c*)(msgRes + sizeof(bmg_header_t)); + u8* bmg_data = (u8*)bmg_inf + bmg_inf->header.size; + u8* string_data = bmg_data + sizeof(bmg_section_t); + + char* string_ptr = NULL; + for (u16 i = 0; i < bmg_inf->entry_num; i++) { + u8* entry = ((u8*)bmg_inf + (i * sizeof(JMSMesgEntry_c))); + + // check if i_stringID equals the message entry "Message ID" + if (i_stringID == *(u16*)(entry + 0x14)) { + string_ptr = (char*)(string_data + *(u32*)(entry + 0x10)); // use entry "String Offset" to get string pointer + + int var_r29 = 0; + int sp14 = 0; + int sp10 = 0; + while (var_r29 < 0x200) { + if ((u8)string_ptr[var_r29] == 0x1A) { + if ((u8)string_ptr[var_r29 + 2] == 0xFF && (u8)string_ptr[var_r29 + 3] == 0 && (u8)string_ptr[var_r29 + 4] == 2) { + sp10 = string_ptr[var_r29 + 1] - 6; + sp14 = string_ptr[var_r29 + 5] * 2; + + for (int spC = 0; spC < sp10; spC++) { + *o_string = string_ptr[var_r29 + spC + 6]; + o_string++; + } + } + + var_r29 += string_ptr[var_r29 + 1]; + continue; + } + + if (sp14 > 0) { + sp14--; + } else { + *o_string = string_ptr[var_r29]; + o_string++; + } + + if (string_ptr[var_r29] == '\0') { + break; + } + + var_r29++; + } + + if (i_msgEntry != NULL) { + memcpy(i_msgEntry, entry + 0x10, sizeof(JMSMesgEntry_c)); + } + + return; + } + } + + if (mMsgResource == NULL) { + dComIfGp_getMsgDtArchive(0)->removeResourceAll(); + } } /* 8021C544-8021C6A4 216E84 0160+00 0/0 32/32 1/1 .text * getStringKanji__13dMeter2Info_cFUlPcP14JMSMesgEntry_c */ -void dMeter2Info_c::getStringKanji(u32 param_0, char* param_1, JMSMesgEntry_c* param_2) { - // NONMATCHING +// NONMATCHING - couple wrong instructions +void dMeter2Info_c::getStringKanji(u32 i_stringID, char* o_string, JMSMesgEntry_c* i_msgEntry) { + strcpy(o_string, ""); + + u8* msgRes; + if (mMsgResource == NULL) { + msgRes = (u8*)JKRGetTypeResource('ROOT', "zel_00.bmg", dComIfGp_getMsgDtArchive(0)); + if (msgRes == NULL) { + return; + } + } else { + msgRes = (u8*)mMsgResource; + } + + JMSMesgInfo_c* bmg_inf = (JMSMesgInfo_c*)(msgRes + sizeof(bmg_header_t)); + u8* bmg_data = (u8*)bmg_inf + bmg_inf->header.size; + u8* string_data = bmg_data + sizeof(bmg_section_t); + + char* string_ptr = NULL; + for (u16 i = 0; i < bmg_inf->entry_num; i++) { + // check if i_stringID equals the message entry "Message ID" + if (i_stringID == *(u16*)(((u8*)bmg_inf + (i * 0x14)) + 0x14)) { + string_ptr = (char*)(string_data + *(u32*)(((u8*)bmg_inf + (i * 0x14)) + 0x10)); // use entry "String Offset" to get string pointer + + int var_r29 = 0; + while (var_r29 < 0x200) { + if ((u8)string_ptr[var_r29] == 0x1A) { + var_r29 += string_ptr[var_r29 + 1]; + continue; + } + + *o_string = string_ptr[var_r29]; + o_string++; + + if (string_ptr[var_r29] == '\0') { + break; + } + + var_r29++; + } + + if (i_msgEntry != NULL) { + memcpy(i_msgEntry, ((u8*)bmg_inf + (i * 0x14)) + 0x10, 0x14); + } + + return; + } + } + + if (mMsgResource == NULL) { + dComIfGp_getMsgDtArchive(0)->removeResourceAll(); + } } /* 8021C6A4-8021C7F4 216FE4 0150+00 0/0 1/1 0/0 .text * getStringLength__13dMeter2Info_cFP10J2DTextBoxPc */ -// NONMATCHING *str type issue -f32 dMeter2Info_c::getStringLength(J2DTextBox* p_textBox, char* str) { - f32 strWidth = 0.0f; - f32 strLength = strWidth; +f32 dMeter2Info_c::getStringLength(J2DTextBox* i_textbox, char* i_string) { + f32 str_width = 0.0f; + f32 str_len = 0.0f; - JUTFont* font = p_textBox->getFont(); - f32 charSpace = p_textBox->getCharSpace(); + JUTFont* font = i_textbox->getFont(); + char* string = i_string; + + f32 charSpace = i_textbox->getCharSpace(); J2DTextBox::TFontSize fontSize; - p_textBox->getFontSize(fontSize); + i_textbox->getFontSize(fontSize); - for (; *str != 0; str++) { - if (*str == '\n') { - if (strLength < strWidth) { - strLength = strWidth; + for (; *string != 0; string++) { + if (*string == '\n') { + if (str_len < str_width) { + str_len = str_width; } - strWidth = 0.0f; + str_width = 0.0f; } else { - strWidth += charSpace + - (fontSize.mSizeX * ((f32)font->getWidth(*str) / (f32)font->getCellWidth())); + int c = (u8)*string; + str_width += charSpace + (fontSize.mSizeX * ((f32)font->getWidth(c) / (f32)font->getCellWidth())); } } - if (strLength < strWidth) { - strLength = strWidth; + if (str_len < str_width) { + str_len = str_width; } - return strLength; + return str_len; } /* 8021C7FC-8021C934 21713C 0138+00 0/0 3/3 0/0 .text * getStringLength__13dMeter2Info_cFP7JUTFontffPc */ -// NONMATCHING getWidth argument type issue -f32 dMeter2Info_c::getStringLength(JUTFont* param_1, f32 param_2, f32 param_3, char* param_4) { - f32 fVar1 = 0.0f; - f32 dVar8 = 0.0f; - for (char* ptr = param_4; *ptr != '\0'; ptr++) { - if (*ptr == 10) { - if (dVar8 < fVar1) { - dVar8 = fVar1; +f32 dMeter2Info_c::getStringLength(JUTFont* i_font, f32 param_2, f32 param_3, char* i_string) { + f32 str_width = 0.0f; + f32 str_len = 0.0f; + + for (char* string = i_string; *string != '\0'; string++) { + if (*string == '\n') { + if (str_len < str_width) { + str_len = str_width; } - fVar1 = 0.0f; + str_width = 0.0f; } else { - fVar1 += param_3 + - param_2 * ((f32)param_1->getWidth(*ptr) / (f32)param_1->getCellWidth()); + int c = (u8)*string; + str_width += param_3 + param_2 * ((f32)i_font->getWidth(c) / (f32)i_font->getCellWidth()); } } - if (dVar8 < fVar1) { - dVar8 = fVar1; + + if (str_len < str_width) { + str_len = str_width; } - return dVar8; + + return str_len; } /* 8021C934-8021C950 217274 001C+00 0/0 2/2 0/0 .text onDirectUseItem__13dMeter2Info_cFi @@ -336,6 +625,7 @@ void dMeter2Info_c::resetWarpStatus() { if (mWarpStatus == 2) { dComIfGs_resetLastWarpAcceptStage(); } + mWarpStatus = 0; } @@ -351,34 +641,32 @@ void dMeter2Info_c::warpInProc() { /* 8021CA70-8021CC00 2173B0 0190+00 0/0 1/1 0/0 .text warpOutProc__13dMeter2Info_cFv */ void dMeter2Info_c::warpOutProc() { - stage_stag_info_class* stag_info = dComIfGp_getStageStagInfo(); - s32 saveTbl = dStage_stagInfo_GetSaveTbl(stag_info); - dComIfGs_setLastWarpAcceptStage(saveTbl); + dComIfGs_setLastWarpAcceptStage(dStage_stagInfo_GetSaveTbl(dComIfGp_getStageStagInfo())); - cXyz warpPos(dComIfGs_getRestartRoomPos()); - csXyz warpAngle(0, dComIfGs_getRestartRoomAngleY(), 0); + cXyz pos(dComIfGs_getRestartRoomPos()); + csXyz angle(0, dComIfGs_getRestartRoomAngleY(), 0); - s8 warpRoomNo = dComIfGs_getRestartRoomNo(); - if (!strcmp(dComIfGp_getStartStageName(), "D_MN01")) { + s8 room_no = dComIfGs_getRestartRoomNo(); + if (strcmp(dComIfGp_getStartStageName(), "D_MN01") == 0) { s32 index = -1; - if (warpRoomNo == 0) { + if (room_no == 0) { index = 1; - } else if (warpRoomNo == 5) { + } else if (room_no == 5) { index = 2; - } else if (warpRoomNo == 6) { + } else if (room_no == 6) { index = 2; - } else if (warpRoomNo == 9) { + } else if (room_no == 9) { index = 4; } if (index != -1) { - daNpcF_getPlayerInfoFromPlayerList(index, warpRoomNo, warpPos, warpAngle); + daNpcF_getPlayerInfoFromPlayerList(index, room_no, pos, angle); } - } else if (!strcmp(dComIfGp_getStartStageName(), "D_MN07") && warpRoomNo == 0) { - daNpcF_getPlayerInfoFromPlayerList(5, warpRoomNo, warpPos, warpAngle); + } else if (!strcmp(dComIfGp_getStartStageName(), "D_MN07") && room_no == 0) { + daNpcF_getPlayerInfoFromPlayerList(5, room_no, pos, angle); } - dComIfGs_setWarpItemData(dComIfGp_getStartStageName(), warpPos, warpAngle.y, warpRoomNo, 0, 1); + dComIfGs_setWarpItemData(dComIfGp_getStartStageName(), pos, angle.y, room_no, 0, 1); dComIfGs_setItem(SLOT_18, fpcNm_ITEM_DUNGEON_BACK); } @@ -391,209 +679,259 @@ void dMeter2Info_c::resetMeterString() { /* 8021CC0C-8021CC80 21754C 0074+00 1/1 1/1 0/0 .text * setWarpInfo__13dMeter2Info_cFPCcRC4cXyzsUcUcUc */ void dMeter2Info_c::setWarpInfo(const char* i_stageName, const cXyz& i_position, s16 i_angle, - u8 i_roomNo, u8 p5, u8 i_warpPlayerNo) { + u8 i_roomNo, u8 param_4, u8 i_warpPlayerNo) { strcpy(mWarpInfo.mStageName, i_stageName); mWarpInfo.mPosition = i_position; - mWarpInfo.mAngle = i_angle; - mWarpInfo.mRoomNo = i_roomNo; - mWarpInfo.unk79 = p5; - mWarpInfo.mWarpPlayerNo = i_warpPlayerNo; + mWarpInfo.mAngle = (s16)i_angle; + mWarpInfo.mRoomNo = (u8)i_roomNo; + mWarpInfo.unk_0x17 = (u8)param_4; + mWarpInfo.mPlayerNo = (u8)i_warpPlayerNo; } /* 8021CC80-8021CF08 2175C0 0288+00 2/2 0/0 0/0 .text getItemType__13dMeter2Info_cFUc */ -u8 dMeter2Info_c::getItemType(u8 itemNo) { - switch (itemNo) { - case 1: - return 1; - case 2: - return 2; - case 3: - return 3; - case 4: - return 4; - case 5: - case 0xED: - return 5; - case 6: - return 6; - case 7: - return 7; - case 0x60: - return 8; - case 0x61: - case 0x69: - return 9; - case 0x62: - return 10; - case 0x63: - return 11; - case 0x64: - return 12; - case 0x65: - return 13; - case 0x66: - case 0x68: - case 0x9D: - return 14; - case 0x67: - return 15; - case 0x6B: - case 0x6D: - return 0x10; - case 0x7D: - return 0x11; - case 0x7E: - case 0x7F: - return 0x12; - case 0x6A: - return 0x13; - case 0x78: - return 0x14; - case 0x79: - return 0x15; - case 0x7A: - return 0x16; - case 0x7B: - return 0x17; - case 0x7C: - return 0x18; - case 0x77: - return 0x19; - case 0x9F: - return 0x1A; - case 0xEF: - case 0xF0: - case 0xF1: - case 0xF2: - return 0x1B; - case 0x6C: - return 0x1C; - case 0x76: - case 0x9E: - return 0x1D; - case 0x74: - return 0x1E; - case 0x73: - case 0x75: - return 0x1F; - case 0x59: - return 33; - case 0x5A: - return 34; +u8 dMeter2Info_c::getItemType(u8 i_itemNo) { + u8 type; + switch (i_itemNo) { + case fpcNm_ITEM_GREEN_RUPEE: + type = ItemType_GREEN_RUPEE; + break; + case fpcNm_ITEM_BLUE_RUPEE: + type = ItemType_BLUE_RUPEE; + break; + case fpcNm_ITEM_YELLOW_RUPEE: + type = ItemType_YELLOW_RUPEE; + break; + case fpcNm_ITEM_RED_RUPEE: + type = ItemType_RED_RUPEE; + break; + case fpcNm_ITEM_PURPLE_RUPEE: + case fpcNm_ITEM_LINKS_SAVINGS: + type = ItemType_PURPLE_RUPEE; + break; + case fpcNm_ITEM_ORANGE_RUPEE: + type = ItemType_ORANGE_RUPEE; + break; + case fpcNm_ITEM_SILVER_RUPEE: + type = ItemType_SILVER_RUPEE; + break; + case fpcNm_ITEM_EMPTY_BOTTLE: + type = ItemType_EMPTY_BOTTLE; + break; + case fpcNm_ITEM_RED_BOTTLE: + case fpcNm_ITEM_RED_BOTTLE_2: + type = ItemType_RED_BOTTLE; + break; + case fpcNm_ITEM_GREEN_BOTTLE: + type = ItemType_GREEN_BOTTLE; + break; + case fpcNm_ITEM_BLUE_BOTTLE: + type = ItemType_BLUE_BOTTLE; + break; + case fpcNm_ITEM_MILK_BOTTLE: + type = ItemType_MILK_BOTTLE; + break; + case fpcNm_ITEM_HALF_MILK_BOTTLE: + type = ItemType_HALF_MILK_BOTTLE; + break; + case fpcNm_ITEM_OIL_BOTTLE: + case fpcNm_ITEM_OIL_BOTTLE_2: + case fpcNm_ITEM_OIL_BOTTLE3: + type = ItemType_OIL_BOTTLE; + break; + case fpcNm_ITEM_WATER_BOTTLE: + type = ItemType_WATER_BOTTLE; + break; + case fpcNm_ITEM_HOT_SPRING: + case fpcNm_ITEM_HOT_SPRING_2: + type = ItemType_HOT_SPRING; + break; + case fpcNm_ITEM_LV1_SOUP: + type = ItemType_LV1_SOUP; + break; + case fpcNm_ITEM_LV2_SOUP: + case fpcNm_ITEM_LV3_SOUP: + type = ItemType_LV2_3_SOUP; + break; + case fpcNm_ITEM_UGLY_SOUP: + type = ItemType_UGLY_SOUP; + break; + case fpcNm_ITEM_CHUCHU_RED: + type = ItemType_CHUCHU_RED; + break; + case fpcNm_ITEM_CHUCHU_BLUE: + type = ItemType_CHUCHU_BLUE; + break; + case fpcNm_ITEM_CHUCHU_GREEN: + type = ItemType_CHUCHU_GREEN; + break; + case fpcNm_ITEM_CHUCHU_YELLOW: + type = ItemType_CHUCHU_YELLOW; + break; + case fpcNm_ITEM_CHUCHU_PURPLE: + type = ItemType_CHUCHU_PURPLE; + break; + case fpcNm_ITEM_CHUCHU_RARE: + type = ItemType_CHUCHU_RARE; + break; + case fpcNm_ITEM_CHUCHU_BLACK: + type = ItemType_CHUCHU_BLACK; + break; + case fpcNm_ITEM_POU_FIRE1: + case fpcNm_ITEM_POU_FIRE2: + case fpcNm_ITEM_POU_FIRE3: + case fpcNm_ITEM_POU_FIRE4: + type = ItemType_POU_FIRE; + break; + case fpcNm_ITEM_FAIRY: + type = ItemType_FAIRY; + break; + case fpcNm_ITEM_BEE_CHILD: + case fpcNm_ITEM_SHOP_BEE_CHILD: + type = ItemType_BEE_CHILD; + break; + case fpcNm_ITEM_WORM: + type = ItemType_WORM; + break; + case fpcNm_ITEM_FAIRY_DROP: + case fpcNm_ITEM_DROP_BOTTLE: + type = ItemType_DROP_BOTTLE; + break; + case fpcNm_ITEM_BOMB_ARROW: + type = ItemType_BOMB_ARROW; + break; + case fpcNm_ITEM_HAWK_ARROW: + type = ItemType_HAWK_ARROW; + break; default: - return 0; + type = 0; + break; } + + return type; } /* 8021CF08-8021D36C 217848 0464+00 0/0 9/9 0/0 .text * readItemTexture__13dMeter2Info_cFUcPvP10J2DPicturePvP10J2DPicturePvP10J2DPicturePvP10J2DPicturei */ -// NONMATCHING regalloc -int dMeter2Info_c::readItemTexture(u8 itemNo, void* param_1, J2DPicture* param_2, void* param_3, - J2DPicture* param_4, void* param_5, J2DPicture* param_6, - void* param_7, J2DPicture* param_8, int param_9) { - u8 itemType = getItemType(itemNo); - int ret = 0; +int dMeter2Info_c::readItemTexture(u8 i_itemNo, void* i_texBuf1, J2DPicture* i_pic1, void* i_texBuf2, + J2DPicture* i_pic2, void* i_texBuf3, J2DPicture* i_pic3, + void* i_texBuf4, J2DPicture* i_pic4, int param_9) { + u8 itemType = getItemType(i_itemNo); + int tex_num = 0; - if (param_1 != NULL) { - if ((itemNo == fpcNm_ITEM_KANTERA && dComIfGs_getOil() == 0) || itemNo == fpcNm_ITEM_KANTERA2) { - dComIfGp_getItemIconArchive()->readIdxResource(param_1, 0xC00, 0x23); - } else if (itemNo == fpcNm_ITEM_COPY_ROD && !daPy_getPlayerActorClass()->checkCopyRodTopUse() && - param_9 == -1) - { - dComIfGp_getItemIconArchive()->readIdxResource(param_1, 0xC00, 0x57); - } else if ((itemType == 0x1B || itemType == 0x1C || itemType == 0x1D || itemType == 0x1E) && - param_5 == NULL) - { - dComIfGp_getItemIconArchive()->readIdxResource(param_1, 0xC00, get2ndTexture(itemType)); - } else if (param_9 >= 0) { - dComIfGp_getItemIconArchive()->readIdxResource(param_1, 0xC00, param_9); + if (i_texBuf1 != NULL) { + if ((i_itemNo == fpcNm_ITEM_KANTERA && dComIfGs_getOil() == 0) || i_itemNo == fpcNm_ITEM_KANTERA2) { + u32 size = JKRReadIdxResource(i_texBuf1, 0xC00, ITEMICON_BTI_IM_KANTERA_OFF_48, dComIfGp_getItemIconArchive()); + JUT_ASSERT(1166, size != 0); + } else if (i_itemNo == fpcNm_ITEM_COPY_ROD && !daPy_getPlayerActorClass()->checkCopyRodTopUse() && param_9 == -1) { + u32 size = JKRReadIdxResource(i_texBuf1, 0xC00, ITEMICON_BTI_ST_COPY_ROD_B, dComIfGp_getItemIconArchive()); + JUT_ASSERT(1173, size != 0); + } else if ((itemType == ItemType_POU_FIRE || itemType == ItemType_FAIRY || itemType == ItemType_BEE_CHILD || itemType == ItemType_WORM) && i_texBuf3 == NULL) { + u32 size = JKRReadIdxResource(i_texBuf1, 0xC00, get2ndTexture(itemType), dComIfGp_getItemIconArchive()); + JUT_ASSERT(1222, size != 0); } else { - dComIfGp_getItemIconArchive()->readIdxResource(param_1, 0xC00, - dItem_data::getTexture(itemNo)); - } - - DCStoreRangeNoSync(param_1, 0xC00); - if (param_2 != NULL) { - if ((itemType == 0x1B || itemType == 0x1C || itemType == 0x1D || itemType == 0x1E) && - param_5 == NULL) - { - set2ndColor(itemType, param_2); + u32 size; + if (param_9 >= 0) { + size = JKRReadIdxResource(i_texBuf1, 0xC00, param_9, dComIfGp_getItemIconArchive()); } else { - set1stColor(itemType, param_2); + size = JKRReadIdxResource(i_texBuf1, 0xC00, dItem_data::getTexture(i_itemNo), dComIfGp_getItemIconArchive()); } - param_2->changeTexture((ResTIMG*)param_1, 0); + + JUT_ASSERT(1238, size != 0); } - ret = 1; - if (param_3 != NULL && get2ndTexture(itemType) > 0) { - if ((itemType == 0x1B || itemType == 0x1C || itemType == 0x1D || itemType == 0x1E) && - param_5 == NULL) - { - dComIfGp_getItemIconArchive()->readIdxResource(param_3, 0xC00, - get3rdTexture(itemType)); - DCStoreRangeNoSync(param_3, 0xC00); - if (param_4 != NULL) { - set3rdColor(itemType, param_4); - param_4->changeTexture((ResTIMG*)param_3, 0); - } - ret = 2; + DCStoreRangeNoSync(i_texBuf1, 0xC00); + if (i_pic1 != NULL) { + if ((itemType == ItemType_POU_FIRE || itemType == ItemType_FAIRY || itemType == ItemType_BEE_CHILD || itemType == ItemType_WORM) && i_texBuf3 == NULL) { + set2ndColor(itemType, i_pic1); } else { - dComIfGp_getItemIconArchive()->readIdxResource(param_3, 0xC00, - get2ndTexture(itemType)); - DCStoreRangeNoSync(param_3, 0xC00); - if (param_4 != NULL) { - set2ndColor(itemType, param_4); - param_4->changeTexture((ResTIMG*)param_3, 0); + set1stColor(itemType, i_pic1); + } + + const ResTIMG* img = i_pic1->changeTexture((ResTIMG*)i_texBuf1, 0); + JUT_ASSERT(1284, img != 0); + } + + tex_num++; + + if (i_texBuf2 != NULL && get2ndTexture(itemType) > 0) { + if ((itemType == ItemType_POU_FIRE || itemType == ItemType_FAIRY || itemType == ItemType_BEE_CHILD || itemType == ItemType_WORM) && i_texBuf3 == NULL) { + u32 size = JKRReadIdxResource(i_texBuf2, 0xC00, get3rdTexture(itemType), dComIfGp_getItemIconArchive()); + JUT_ASSERT(1327, size != 0); + + DCStoreRangeNoSync(i_texBuf2, 0xC00); + if (i_pic2 != NULL) { + set3rdColor(itemType, i_pic2); + const ResTIMG* img = i_pic2->changeTexture((ResTIMG*)i_texBuf2, 0); + JUT_ASSERT(1333, img != 0); } - ret = 2; - if (param_5 != NULL && get3rdTexture(itemType) > 0) { - dComIfGp_getItemIconArchive()->readIdxResource(param_5, 0xC00, - get3rdTexture(itemType)); - DCStoreRangeNoSync(param_5, 0xC00); - if (param_6 != NULL) { - set3rdColor(itemType, param_6); - param_6->changeTexture((ResTIMG*)param_5, 0); + tex_num++; + } else { + u32 size = JKRReadIdxResource(i_texBuf2, 0xC00, get2ndTexture(itemType), dComIfGp_getItemIconArchive()); + JUT_ASSERT(1342, size != 0); + + DCStoreRangeNoSync(i_texBuf2, 0xC00); + if (i_pic2 != NULL) { + set2ndColor(itemType, i_pic2); + const ResTIMG* img = i_pic2->changeTexture((ResTIMG*)i_texBuf2, 0); + JUT_ASSERT(1348, img != 0); + } + + tex_num++; + + if (i_texBuf3 != NULL && get3rdTexture(itemType) > 0) { + u32 size = JKRReadIdxResource(i_texBuf3, 0xC00, get3rdTexture(itemType), dComIfGp_getItemIconArchive()); + JUT_ASSERT(1358, size != 0); + + DCStoreRangeNoSync(i_texBuf3, 0xC00); + if (i_pic3 != NULL) { + set3rdColor(itemType, i_pic3); + const ResTIMG* img = i_pic3->changeTexture((ResTIMG*)i_texBuf3, 0); + JUT_ASSERT(1364, img != 0); } - ret = 3; - if (param_7 != NULL && get4thTexture(itemType) > 0) { - dComIfGp_getItemIconArchive()->readIdxResource(param_7, 0xC00, - get4thTexture(itemType)); - DCStoreRangeNoSync(param_7, 0xC00); - if (param_8 != NULL) { - set4thColor(itemType, param_8); - param_8->changeTexture((ResTIMG*)param_7, 0); + tex_num++; + + if (i_texBuf4 != NULL && get4thTexture(itemType) > 0) { + u32 size = JKRReadIdxResource(i_texBuf4, 0xC00, get4thTexture(itemType), dComIfGp_getItemIconArchive()); + JUT_ASSERT(1374, size != 0); + + DCStoreRangeNoSync(i_texBuf4, 0xC00); + if (i_pic4 != NULL) { + set4thColor(itemType, i_pic4); + const ResTIMG* img = i_pic4->changeTexture((ResTIMG*)i_texBuf4, 0); + JUT_ASSERT(1380, img != 0); } - ret = 4; + + tex_num++; } } } } } - return ret; + return tex_num; } /* 8021D36C-8021D44C 217CAC 00E0+00 0/0 2/2 0/0 .text * setItemColor__13dMeter2Info_cFUcP10J2DPictureP10J2DPictureP10J2DPictureP10J2DPicture */ -void dMeter2Info_c::setItemColor(u8 param_1, J2DPicture* param_2, J2DPicture* param_3, - J2DPicture* param_4, J2DPicture* param_5) { - u8 itemType = getItemType(param_1); - if (param_2 != NULL) { - set1stColor(itemType, param_2); - if (param_3 != NULL) { - if ((itemType == 27 || itemType == 28 || itemType == 29 || itemType == 30) && - param_4 == NULL) +void dMeter2Info_c::setItemColor(u8 i_itemNo, J2DPicture* i_pic1, J2DPicture* i_pic2, + J2DPicture* i_pic3, J2DPicture* i_pic4) { + u8 itemType = getItemType(i_itemNo); + if (i_pic1 != NULL) { + set1stColor(itemType, i_pic1); + if (i_pic2 != NULL) { + if ((itemType == ItemType_POU_FIRE || itemType == ItemType_FAIRY || itemType == ItemType_BEE_CHILD || itemType == ItemType_WORM) && + i_pic3 == NULL) { - set3rdColor(itemType, param_3); + set3rdColor(itemType, i_pic2); } else { - set2ndColor(itemType, param_3); - if (param_4 != NULL) { - set3rdColor(itemType, param_4); - if (param_5 != NULL) { - set4thColor(itemType, param_5); + set2ndColor(itemType, i_pic2); + if (i_pic3 != NULL) { + set3rdColor(itemType, i_pic3); + if (i_pic4 != NULL) { + set4thColor(itemType, i_pic4); } } } @@ -603,74 +941,74 @@ void dMeter2Info_c::setItemColor(u8 param_1, J2DPicture* param_2, J2DPicture* pa /* 8021D44C-8021D4B8 217D8C 006C+00 2/1 0/0 0/0 .text get2ndTexture__13dMeter2Info_cFUc */ -s16 dMeter2Info_c::get2ndTexture(u8 itemType) { - switch (itemType) { - case fpcNm_ITEM_GREEN_RUPEE: - case fpcNm_ITEM_BLUE_RUPEE: - case fpcNm_ITEM_YELLOW_RUPEE: - case fpcNm_ITEM_RED_RUPEE: - case fpcNm_ITEM_PURPLE_RUPEE: - case fpcNm_ITEM_ORANGE_RUPEE: - case fpcNm_ITEM_SILVER_RUPEE: - return 0x2e; - case fpcNm_ITEM_S_MAGIC: - case fpcNm_ITEM_L_MAGIC: - case fpcNm_ITEM_BOMB_5: - case fpcNm_ITEM_BOMB_10: - case fpcNm_ITEM_BOMB_20: - case fpcNm_ITEM_BOMB_30: - case fpcNm_ITEM_ARROW_10: - case fpcNm_ITEM_ARROW_20: - case fpcNm_ITEM_ARROW_30: - case fpcNm_ITEM_ARROW_1: - case fpcNm_ITEM_PACHINKO_SHOT: - case fpcNm_ITEM_NOENTRY_19: - case fpcNm_ITEM_NOENTRY_20: - case fpcNm_ITEM_NOENTRY_21: - case fpcNm_ITEM_WATER_BOMB_5: - case fpcNm_ITEM_WATER_BOMB_10: - case fpcNm_ITEM_WATER_BOMB_20: - case fpcNm_ITEM_WATER_BOMB_30: - case fpcNm_ITEM_BOMB_INSECT_5: - case fpcNm_ITEM_TRIPLE_HEART: - return 0xe; - case fpcNm_ITEM_BOMB_INSECT_10: - return 0x14; - case fpcNm_ITEM_BOMB_INSECT_20: - return 0x27; - case fpcNm_ITEM_BOMB_INSECT_30: - return 0xf; - case fpcNm_ITEM_RECOVERY_FAILY: - return 0x10; - case fpcNm_ITEM_KAKERA_HEART: - case fpcNm_ITEM_UTAWA_HEART: - case fpcNm_ITEM_MAP: - return 0x69; - case fpcNm_ITEM_COMPUS: - return 0x2a; +s16 dMeter2Info_c::get2ndTexture(u8 i_itemType) { + switch (i_itemType) { + case ItemType_GREEN_RUPEE: + case ItemType_BLUE_RUPEE: + case ItemType_YELLOW_RUPEE: + case ItemType_RED_RUPEE: + case ItemType_PURPLE_RUPEE: + case ItemType_ORANGE_RUPEE: + case ItemType_SILVER_RUPEE: + return ITEMICON_BTI_IM_ZELDA_ITEM_ICON_RUPY_L_13; + case ItemType_EMPTY_BOTTLE: + case ItemType_RED_BOTTLE: + case ItemType_GREEN_BOTTLE: + case ItemType_BLUE_BOTTLE: + case ItemType_MILK_BOTTLE: + case ItemType_HALF_MILK_BOTTLE: + case ItemType_OIL_BOTTLE: + case ItemType_WATER_BOTTLE: + case ItemType_HOT_SPRING: + case ItemType_LV1_SOUP: + case ItemType_LV2_3_SOUP: + case ItemType_UGLY_SOUP: + case ItemType_CHUCHU_RED: + case ItemType_CHUCHU_BLUE: + case ItemType_CHUCHU_GREEN: + case ItemType_CHUCHU_YELLOW: + case ItemType_CHUCHU_PURPLE: + case ItemType_CHUCHU_RARE: + case ItemType_CHUCHU_BLACK: + case ItemType_DROP_BOTTLE: + return ITEMICON_BTI_IM_BOTTLE; + case ItemType_POU_FIRE: + return ITEMICON_BTI_IM_BOTTLE_POU; + case ItemType_FAIRY: + return ITEMICON_BTI_IM_NAVI_TRY_00_07; + case ItemType_BEE_CHILD: + return ITEMICON_BTI_IM_BOTTLE_HATCHINOKO; + case ItemType_WORM: + return ITEMICON_BTI_IM_BOTTLE_MIMIZU; + case ItemType_BOMB_ARROW: + case ItemType_HAWK_ARROW: + case 35: + return ITEMICON_BTI_TT_BOW_06; + case 36: + return ITEMICON_BTI_IM_SANGO_MIMIKAZARI_48; default: - case fpcNm_ITEM_SMALL_KEY: + case 32: return -1; } } /* 8021D4B8-8021D4FC 217DF8 0044+00 1/1 0/0 0/0 .text get3rdTexture__13dMeter2Info_cFUc */ -s16 dMeter2Info_c::get3rdTexture(u8 itemType) { - switch (itemType) { - case fpcNm_ITEM_GREEN_RUPEE: - case fpcNm_ITEM_BLUE_RUPEE: - case fpcNm_ITEM_YELLOW_RUPEE: - case fpcNm_ITEM_RED_RUPEE: - case fpcNm_ITEM_PURPLE_RUPEE: - case fpcNm_ITEM_ORANGE_RUPEE: - case fpcNm_ITEM_SILVER_RUPEE: - return 0x2e; - case fpcNm_ITEM_BOMB_INSECT_10: - case fpcNm_ITEM_BOMB_INSECT_20: - case fpcNm_ITEM_BOMB_INSECT_30: - case fpcNm_ITEM_RECOVERY_FAILY: - return 0x0e; +s16 dMeter2Info_c::get3rdTexture(u8 i_itemType) { + switch (i_itemType) { + case ItemType_GREEN_RUPEE: + case ItemType_BLUE_RUPEE: + case ItemType_YELLOW_RUPEE: + case ItemType_RED_RUPEE: + case ItemType_PURPLE_RUPEE: + case ItemType_ORANGE_RUPEE: + case ItemType_SILVER_RUPEE: + return ITEMICON_BTI_IM_ZELDA_ITEM_ICON_RUPY_L_13; + case ItemType_POU_FIRE: + case ItemType_FAIRY: + case ItemType_BEE_CHILD: + case ItemType_WORM: + return ITEMICON_BTI_IM_BOTTLE; default: return -1; } @@ -678,16 +1016,16 @@ s16 dMeter2Info_c::get3rdTexture(u8 itemType) { /* 8021D4FC-8021D524 217E3C 0028+00 1/1 0/0 0/0 .text get4thTexture__13dMeter2Info_cFUc */ -s16 dMeter2Info_c::get4thTexture(u8 itemType) { - switch (itemType) { - case fpcNm_ITEM_GREEN_RUPEE: - case fpcNm_ITEM_BLUE_RUPEE: - case fpcNm_ITEM_YELLOW_RUPEE: - case fpcNm_ITEM_RED_RUPEE: - case fpcNm_ITEM_PURPLE_RUPEE: - case fpcNm_ITEM_ORANGE_RUPEE: - case fpcNm_ITEM_SILVER_RUPEE: - return 0x2e; +s16 dMeter2Info_c::get4thTexture(u8 i_itemType) { + switch (i_itemType) { + case ItemType_GREEN_RUPEE: + case ItemType_BLUE_RUPEE: + case ItemType_YELLOW_RUPEE: + case ItemType_RED_RUPEE: + case ItemType_PURPLE_RUPEE: + case ItemType_ORANGE_RUPEE: + case ItemType_SILVER_RUPEE: + return ITEMICON_BTI_IM_ZELDA_ITEM_ICON_RUPY_L_13; default: return -1; } @@ -695,7 +1033,7 @@ s16 dMeter2Info_c::get4thTexture(u8 itemType) { /* 8021D524-8021D644 217E64 0120+00 2/2 0/0 0/0 .text set1stColor__13dMeter2Info_cFUcP10J2DPicture */ -void dMeter2Info_c::set1stColor(u8 param_1, J2DPicture* param_2) { +void dMeter2Info_c::set1stColor(u8 i_itemType, J2DPicture* i_pic) { static GXColor const black_color[37] = { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x60, 0x00, 0x00}, {0x00, 0x00, 0xC0, 0x00}, {0xA0, 0x60, 0x00, 0x00}, {0xA0, 0x00, 0x00, 0x00}, {0x40, 0x00, 0x60, 0x00}, @@ -792,17 +1130,17 @@ void dMeter2Info_c::set1stColor(u8 param_1, J2DPicture* param_2) { {0xFF, 0xFF, 0xFF, 0xFF}, }; - param_2->setBlackWhite(*(JUtility::TColor*)&black_color[param_1], - *(JUtility::TColor*)&white_color[param_1]); - param_2->setCornerColor(*(JUtility::TColor*)&vertex_color_lu[param_1], - *(JUtility::TColor*)&vertex_color_ru[param_1], - *(JUtility::TColor*)&vertex_color_ld[param_1], - *(JUtility::TColor*)&vertex_color_rd[param_1]); + i_pic->setBlackWhite(*(JUtility::TColor*)&black_color[i_itemType], + *(JUtility::TColor*)&white_color[i_itemType]); + i_pic->setCornerColor(*(JUtility::TColor*)&vertex_color_lu[i_itemType], + *(JUtility::TColor*)&vertex_color_ru[i_itemType], + *(JUtility::TColor*)&vertex_color_ld[i_itemType], + *(JUtility::TColor*)&vertex_color_rd[i_itemType]); } /* 8021D644-8021D764 217F84 0120+00 2/2 0/0 0/0 .text set2ndColor__13dMeter2Info_cFUcP10J2DPicture */ -void dMeter2Info_c::set2ndColor(u8 param_1, J2DPicture* param_2) { +void dMeter2Info_c::set2ndColor(u8 i_itemType, J2DPicture* i_pic) { static GXColor const black_color[37] = { {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}, @@ -899,33 +1237,33 @@ void dMeter2Info_c::set2ndColor(u8 param_1, J2DPicture* param_2) { {0xFF, 0xFF, 0xFF, 0xFF}, }; - param_2->setBlackWhite(*(JUtility::TColor*)&black_color[param_1], - *(JUtility::TColor*)&white_color[param_1]); - param_2->setCornerColor(*(JUtility::TColor*)&vertex_color_lu[param_1], - *(JUtility::TColor*)&vertex_color_ru[param_1], - *(JUtility::TColor*)&vertex_color_ld[param_1], - *(JUtility::TColor*)&vertex_color_rd[param_1]); + i_pic->setBlackWhite(*(JUtility::TColor*)&black_color[i_itemType], + *(JUtility::TColor*)&white_color[i_itemType]); + i_pic->setCornerColor(*(JUtility::TColor*)&vertex_color_lu[i_itemType], + *(JUtility::TColor*)&vertex_color_ru[i_itemType], + *(JUtility::TColor*)&vertex_color_ld[i_itemType], + *(JUtility::TColor*)&vertex_color_rd[i_itemType]); } /* 8021D764-8021DB64 2180A4 0400+00 2/2 0/0 0/0 .text set3rdColor__13dMeter2Info_cFUcP10J2DPicture */ -void dMeter2Info_c::set3rdColor(u8 param_1, J2DPicture* param_2) { - if (param_1 == 27) { - param_2->setBlackWhite(JUtility::TColor(0, 0, 0, 0), +void dMeter2Info_c::set3rdColor(u8 i_itemType, J2DPicture* i_pic) { + if (i_itemType == ItemType_POU_FIRE) { + i_pic->setBlackWhite(JUtility::TColor(0, 0, 0, 0), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); - param_2->setCornerColor( + i_pic->setCornerColor( JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); - } else if (param_1 == 28 || param_1 == 29 || param_1 == 30) { - param_2->setBlackWhite(JUtility::TColor(0, 0, 0, 0), + } else if (i_itemType == ItemType_FAIRY || i_itemType == ItemType_BEE_CHILD || i_itemType == ItemType_WORM) { + i_pic->setBlackWhite(JUtility::TColor(0, 0, 0, 0), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); - param_2->setCornerColor( + i_pic->setCornerColor( JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xcd, 0xff, 0xff, 0xff)); } else { - param_2->setBlackWhite(JUtility::TColor(0, 0, 0, 0), + i_pic->setBlackWhite(JUtility::TColor(0, 0, 0, 0), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); - param_2->setCornerColor( + i_pic->setCornerColor( JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); } @@ -933,16 +1271,18 @@ void dMeter2Info_c::set3rdColor(u8 param_1, J2DPicture* param_2) { /* 8021DB64-8021DCC4 2184A4 0160+00 2/2 0/0 0/0 .text set4thColor__13dMeter2Info_cFUcP10J2DPicture */ -void dMeter2Info_c::set4thColor(u8 param_1, J2DPicture* param_2) { - param_2->setBlackWhite(JUtility::TColor(0, 0, 0, 0), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); - param_2->setCornerColor( +void dMeter2Info_c::set4thColor(u8 i_itemType, J2DPicture* i_pic) { + i_pic->setBlackWhite(JUtility::TColor(0, 0, 0, 0), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); + i_pic->setCornerColor( JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff), JUtility::TColor(0xff, 0xff, 0xff, 0xff)); } /* 8021DCC4-8021DCE0 218604 001C+00 0/0 2/2 0/0 .text setHotSpringTimer__13dMeter2Info_cFUc */ -void dMeter2Info_c::setHotSpringTimer(u8 slotNo) { - int i_bottleIdx = slotNo - 11; +void dMeter2Info_c::setHotSpringTimer(u8 i_slotNo) { + int i_bottleIdx = i_slotNo - 11; + JUT_ASSERT(2699, i_bottleIdx >= 0 && i_bottleIdx <= dSv_player_item_c::BOTTLE_MAX); + mHotSpringTimer[i_bottleIdx] = 900; } @@ -961,6 +1301,8 @@ void dMeter2Info_c::decHotSpringTimer() { /* 8021DD5C-8021DE18 21869C 00BC+00 2/2 1/1 0/0 .text changeWater__13dMeter2Info_cFUc */ void dMeter2Info_c::changeWater(u8 i_slotNo) { int i_bottleIdx = i_slotNo - SLOT_11; + JUT_ASSERT(2739, i_bottleIdx >= 0 && i_bottleIdx <= dSv_player_item_c::BOTTLE_MAX); + mHotSpringTimer[i_bottleIdx] = 0; if (dComIfGs_getItem(i_slotNo, true) == fpcNm_ITEM_HOT_SPRING) { @@ -976,15 +1318,14 @@ void dMeter2Info_c::changeWater(u8 i_slotNo) { /* 8021DE18-8021E0C4 218758 02AC+00 0/0 3/3 3/3 .text setMiniGameItem__13dMeter2Info_cFUc */ -void dMeter2Info_c::setMiniGameItem(u8 minigameFlag) { - bool mgItemSet = false; - +void dMeter2Info_c::setMiniGameItem(u8 i_minigameFlag) { + bool item_set = false; if (mMiniGameItemSetFlag != 0) { - mgItemSet = true; + item_set = true; } if (mRentalBombBagIdx == 0xFF) { - bool setRentBagIdx = false; + u8 setRentBagIdx = false; for (int bagIdx = 0; bagIdx < 3; bagIdx++) { if (!setRentBagIdx && dComIfGs_getItem((u8)(bagIdx + SLOT_15), true) == fpcNm_ITEM_NONE) { @@ -992,12 +1333,13 @@ void dMeter2Info_c::setMiniGameItem(u8 minigameFlag) { setRentBagIdx = true; } } + if (!setRentBagIdx) { mRentalBombBagIdx = 2; } } - mMiniGameItemSetFlag = minigameFlag; + mMiniGameItemSetFlag = i_minigameFlag; for (int i = 0; i < 2; i++) { mSaveMixItemIdx[i] = dComIfGs_getMixItemIndex(i); @@ -1009,7 +1351,7 @@ void dMeter2Info_c::setMiniGameItem(u8 minigameFlag) { mSaveBowItem = dComIfGs_getItem(SLOT_4, false); mSaveBombItem = dComIfGs_getItem((u8)(mRentalBombBagIdx + SLOT_15), false); - if (mgItemSet) { + if (item_set) { for (int i = 0; i < 2; i++) { dComIfGs_setMixItemIndex(i, mSaveMixItemIdxMG[i]); dComIfGs_setSelectItemIndex(i, mSaveSelItemIdxMG[i]); @@ -1034,17 +1376,16 @@ void dMeter2Info_c::setMiniGameItem(u8 minigameFlag) { dComIfGs_setSelectItemIndex(SELECT_ITEM_X, (u8)(mRentalBombBagIdx + SLOT_15)); } - if (!mgItemSet) { + if (!item_set) { dComIfGs_setBombNum(mRentalBombBagIdx, 30); - u8 arrow_max = dComIfGs_getArrowMax(); - dComIfGs_setArrowNum(arrow_max); + dComIfGs_setArrowNum(dComIfGs_getArrowMax()); } } /* 8021E0C4-8021E268 218A04 01A4+00 0/0 3/3 4/4 .text resetMiniGameItem__13dMeter2Info_cFb */ -void dMeter2Info_c::resetMiniGameItem(bool saveMGItem) { +void dMeter2Info_c::resetMiniGameItem(bool i_saveItem) { if (mMiniGameItemSetFlag != 0) { - if (saveMGItem) { + if (i_saveItem) { for (int i = 0; i < 2; i++) { mSaveMixItemIdxMG[i] = dComIfGs_getMixItemIndex(i); mSaveSelItemIdxMG[i] = dComIfGs_getSelectItemIndex(i); @@ -1070,7 +1411,7 @@ void dMeter2Info_c::resetMiniGameItem(bool saveMGItem) { dComIfGs_setBombNum(mRentalBombBagIdx, mSaveBombNum); dComIfGs_setArrowNum(mSaveArrowNum); - if (!saveMGItem) { + if (!i_saveItem) { mMiniGameItemSetFlag = 0; mRentalBombBagIdx = 0xFF; } @@ -1078,14 +1419,15 @@ void dMeter2Info_c::resetMiniGameItem(bool saveMGItem) { } /* 8021E268-8021E290 218BA8 0028+00 0/0 0/0 5/5 .text setMiniGameCount__13dMeter2Info_cFSc */ -void dMeter2Info_c::setMiniGameCount(s8 count) { - if (count < -99) { - count = -99; +void dMeter2Info_c::setMiniGameCount(s8 i_count) { + if (i_count < -99) { + i_count = -99; } - if (count > 99) { - count = 99; + if (i_count > 99) { + i_count = 99; } - mMiniGameCount = count; + + mMiniGameCount = i_count; } /* 8021E290-8021E2B4 218BD0 0024+00 1/1 2/2 0/0 .text setSaveStageName__13dMeter2Info_cFPCc */ @@ -1099,7 +1441,7 @@ s16 dMeter2Info_getNowLifeGauge() { } /* 8021E2C8-8021E2DC 218C08 0014+00 0/0 11/11 3/3 .text dMeter2Info_getNumberTextureName__Fi */ -const char* dMeter2Info_getNumberTextureName(int nameIdx) { +const char* dMeter2Info_getNumberTextureName(int i_num) { static const char* tex_name[10] = { "im_font_number_32_32_ganshinkyo_0_02.bti", "im_font_number_32_32_ganshinkyo_1_02.bti", "im_font_number_32_32_ganshinkyo_2_02.bti", "im_font_number_32_32_ganshinkyo_3_02.bti", @@ -1108,28 +1450,50 @@ const char* dMeter2Info_getNumberTextureName(int nameIdx) { "im_font_number_32_32_ganshinkyo_8_02.bti", "im_font_number_32_32_ganshinkyo_9_02.bti", }; - return tex_name[nameIdx]; + JUT_ASSERT(2986, i_num >= 0 && i_num <= 9); + return tex_name[i_num]; } const char* dMeter2Info_getPlusTextureName() { - static const char* tex_name; - static s8 initTexName; - - if (!initTexName) { - tex_name = "im_plus_metal_24x24_00.bti"; - initTexName = true; - } + static const char* tex_name = "im_plus_metal_24x24_00.bti"; return tex_name; } /* 8021E308-8021E4B0 218C48 01A8+00 0/0 3/3 0/0 .text dMeter2Info_getPixel__FffffffPC7ResTIMG */ -bool dMeter2Info_getPixel(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4, - f32 param_5, ResTIMG const* param_6) { - // NONMATCHING +// NONMATCHING +bool dMeter2Info_getPixel(f32 i_posX, f32 i_posY, f32 param_2, f32 param_3, f32 i_sizeX, + f32 i_sizeY, ResTIMG const* i_resTimg) { + f32 temp_f31 = i_posX - param_2; + f32 temp_f30 = i_posY - param_3; + + if (temp_f31 < 0.0f || temp_f31 >= (u32)i_sizeX || temp_f30 < 0.0f || temp_f30 >= (u32)i_sizeY) { + return 0; + } + + JUT_ASSERT(3060, i_resTimg->format == GX_TF_C8 && i_resTimg->indexTexture && i_resTimg->colorFormat == GX_TL_RGB5A3); + + u32 timg_width = i_resTimg->width; + u32 s = (temp_f31 * (f32)timg_width) / i_sizeX; + u32 t = (temp_f30 * (f32)i_resTimg->height) / i_sizeY; + + JUT_ASSERT(3065, s < i_resTimg->width && t < i_resTimg->height); + + u32 sp1C = ((s & 7) + ((t & 0xFFFFFFFC) * ((timg_width + 7) & 0xFFFFFFF8))) + ((s & 0xFFFFFFF8) << 2) + ((t & 3) << 3); + u8* pixel = (u8*)((u32)i_resTimg + (i_resTimg->imageOffset + sp1C)); + + JUT_ASSERT(3074, *pixel < i_resTimg->numColors); + + u16* palette_p = (u16*)((u32)i_resTimg + i_resTimg->paletteOffset); + u16 var_r24 = (u16)palette_p[*pixel]; + if (var_r24 & 0x8000) { + return 1; + } + + return var_r24 & 0x7000; } /* 8021E4B0-8021E530 218DF0 0080+00 0/0 2/2 1/1 .text dMeter2Info_setCloth__FUcb */ -void dMeter2Info_setCloth(u8 i_clothId, bool param_1) { +void dMeter2Info_setCloth(u8 i_clothId, bool i_offItemBit) { switch (i_clothId) { case fpcNm_ITEM_WEAR_CASUAL: case fpcNm_ITEM_WEAR_KOKIRI: @@ -1137,20 +1501,21 @@ void dMeter2Info_setCloth(u8 i_clothId, bool param_1) { case fpcNm_ITEM_WEAR_ZORA: break; default: + OS_REPORT("cloth item id error!! ==> %d\n", i_clothId); i_clothId = fpcNm_ITEM_WEAR_CASUAL; - param_1 = false; + i_offItemBit = false; } - if (param_1 && dComIfGs_getSelectEquipClothes() != fpcNm_ITEM_NONE) { - u8 equip_cloth = dComIfGs_getSelectEquipClothes(); - dComIfGs_offItemFirstBit(equip_cloth); + if (i_offItemBit && dComIfGs_getSelectEquipClothes() != fpcNm_ITEM_NONE) { + dComIfGs_offItemFirstBit(dComIfGs_getSelectEquipClothes()); } + dComIfGs_setSelectEquipClothes(i_clothId); dComIfGp_setSelectEquipClothes(i_clothId); } /* 8021E530-8021E5D4 218E70 00A4+00 0/0 3/3 3/3 .text dMeter2Info_setSword__FUcb */ -void dMeter2Info_setSword(u8 i_itemId, bool param_1) { +void dMeter2Info_setSword(u8 i_itemId, bool i_offItemBit) { switch (i_itemId) { case fpcNm_ITEM_NONE: case fpcNm_ITEM_WOOD_STICK: @@ -1159,20 +1524,21 @@ void dMeter2Info_setSword(u8 i_itemId, bool param_1) { case fpcNm_ITEM_LIGHT_SWORD: break; default: + OS_REPORT("sword item id error!! ==> %d\n", i_itemId); i_itemId = fpcNm_ITEM_NONE; - param_1 = false; + i_offItemBit = false; } - if (param_1 && dComIfGs_getSelectEquipSword() != 0xFF) { - u8 tmp = dComIfGs_getSelectEquipSword(); - dComIfGs_offItemFirstBit(tmp); + if (i_offItemBit && dComIfGs_getSelectEquipSword() != 0xFF) { + dComIfGs_offItemFirstBit(dComIfGs_getSelectEquipSword()); } + dComIfGs_setSelectEquipSword(i_itemId); dComIfGp_setSelectEquipSword(i_itemId); } /* 8021E5D4-8021E660 218F14 008C+00 0/0 3/3 0/0 .text dMeter2Info_setShield__FUcb */ -void dMeter2Info_setShield(u8 i_itemId, bool param_1) { +void dMeter2Info_setShield(u8 i_itemId, bool i_offItemBit) { switch (i_itemId) { case fpcNm_ITEM_NONE: case fpcNm_ITEM_WOOD_SHIELD: @@ -1180,14 +1546,15 @@ void dMeter2Info_setShield(u8 i_itemId, bool param_1) { case fpcNm_ITEM_HYLIA_SHIELD: break; default: + OS_REPORT("shield item id error!! ==> %d\n", i_itemId); i_itemId = fpcNm_ITEM_NONE; - param_1 = false; + i_offItemBit = false; } - if (param_1 && dComIfGs_getSelectEquipShield() != 0xFF) { - u8 tmp = dComIfGs_getSelectEquipShield(); - dComIfGs_offItemFirstBit(tmp); + if (i_offItemBit && dComIfGs_getSelectEquipShield() != 0xFF) { + dComIfGs_offItemFirstBit(dComIfGs_getSelectEquipShield()); } + dComIfGs_setSelectEquipShield(i_itemId); dComIfGp_setSelectEquipShield(i_itemId); } @@ -1205,11 +1572,10 @@ bool dMeter2Info_isMapOpenCheck() { /* 8021E688-8021E6E4 218FC8 005C+00 0/0 2/2 0/0 .text dMeter2Info_isItemOpenCheck__Fv */ bool dMeter2Info_isItemOpenCheck() { - if (daPy_getPlayerActorClass()->checkCanoeSlider() || - daPy_getPlayerActorClass()->getSumouMode() || dMeter2Info_isSub2DStatus(1)) - { + if (daPy_getPlayerActorClass()->checkCanoeSlider() || daPy_getPlayerActorClass()->getSumouMode() || dMeter2Info_isSub2DStatus(1)) { return false; } + return true; } @@ -1259,6 +1625,7 @@ u8 dMeter2Info_getRecieveLetterNum() { letterNum++; } } + return letterNum; } @@ -1274,6 +1641,7 @@ u8 dMeter2Info_getNewLetterNum() { } } } + return letterNum; } @@ -1297,6 +1665,7 @@ int dMeter2Info_setNewLetterSender() { } } } + return 0; } @@ -1304,23 +1673,29 @@ int dMeter2Info_setNewLetterSender() { int dMeter2Info_recieveLetter() { int rv = FALSE; u8 letterNum = dMeter2Info_getRecieveLetterNum(); + for (int i = 0; i < 64; i++) { if (!dComIfGs_isLetterGetFlag(i) && dMenu_Letter::getLetterName(i) != 0) { u16 eventFlag = dMenu_Letter::getLetterEventFlag(i); if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[eventFlag])) { dComIfGs_onLetterGetFlag(i); + if (dComIfGs_getGetNumber(letterNum) == 0) { dComIfGs_setGetNumber(letterNum, i + 1); } else { for (int j = 0; j < 0x40; j++) { OS_REPORT("letter info =====> %d, %d\n", j, dComIfGs_getGetNumber(j) - 1); } + + JUT_ASSERT(3552, 0); } + letterNum++; rv = TRUE; } } } + return rv; } @@ -1330,5 +1705,3 @@ void dMeter2Info_set2DVibration() {} /* 8021E9D4-8021E9D8 219314 0004+00 0/0 12/12 0/0 .text dMeter2Info_set2DVibrationM__Fv */ void dMeter2Info_set2DVibrationM() {} - -/* 80399168-80399168 0257C8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ diff --git a/src/d/d_msg_object.cpp b/src/d/d_msg_object.cpp index 6c29328a200..afe4f472ef7 100644 --- a/src/d/d_msg_object.cpp +++ b/src/d/d_msg_object.cpp @@ -620,9 +620,9 @@ void dMsgObject_c::setMessageIndex(u32 param_1, u32 param_2, bool param_3) { field_0x172 = 0; mpRefer->setPageNum(field_0x172); - JMSMesgHeader_c* pMsg = (JMSMesgHeader_c*)((char*)mpMsgDt + 0x20); - u8* iVar2 = (u8*)pMsg + pMsg->sectionSize; - dComIfGp_setMesgCameraAttrInfo(pMsg->entries[getMessageIndex(revoIndex)].field_0x0f); + JMSMesgInfo_c* pMsg = (JMSMesgInfo_c*)((char*)mpMsgDt + 0x20); + u8* iVar2 = (u8*)pMsg + pMsg->header.size; + dComIfGp_setMesgCameraAttrInfo(pMsg->entries[getMessageIndex(revoIndex)].camera_id); if (field_0x15c == 1000) { mpRefer->setSelMsgPtr(NULL); } else { @@ -630,7 +630,7 @@ void dMsgObject_c::setMessageIndex(u32 param_1, u32 param_2, bool param_3) { if (msgIndex == 0x264) { mpRefer->setSelMsgPtr(NULL); } else { - mpRefer->setSelMsgPtr(((char*)iVar2 + pMsg->entries[msgIndex].mStringOffset + 8)); + mpRefer->setSelMsgPtr(((char*)iVar2 + pMsg->entries[msgIndex].string_offset + 8)); } } if (param_3) { @@ -659,10 +659,10 @@ void dMsgObject_c::setMessageIndexDemo(u32 param_1, bool param_2) { changeGroup(groupID); field_0x172 = 0; mpRefer->setPageNum(field_0x172); - JMSMesgHeader_c* info_header_p = (JMSMesgHeader_c*)((char*)mpMsgDt + 0x20); + JMSMesgInfo_c* info_header_p = (JMSMesgInfo_c*)((char*)mpMsgDt + 0x20); int ind = getMessageIndex(revoMsgIndex); JMSMesgEntry_c* info_entries = (JMSMesgEntry_c*)((char*)info_header_p + 0x10); - dComIfGp_setMesgCameraAttrInfo(info_entries[ind].field_0x0f); + dComIfGp_setMesgCameraAttrInfo(info_entries[ind].camera_id); mpRefer->setSelMsgPtr(NULL); if (param_2) { mpCtrl->setMessageID(mMessageID, 0, NULL); @@ -673,11 +673,11 @@ void dMsgObject_c::setMessageIndexDemo(u32 param_1, bool param_2) { */ u32 dMsgObject_c::getMessageIndex(u32 param_0) { u32 i = 0; - JMSMesgHeader_c* pMsg = (JMSMesgHeader_c*)((char*)mpMsgDt + 0x20); + JMSMesgInfo_c* pMsg = (JMSMesgInfo_c*)((char*)mpMsgDt + 0x20); u32 msgIndexCount = *((u16*)((char*)mpMsgDt + 0x28)); int rv; for (; i < msgIndexCount; i++) { - if (pMsg->entries[i].mStringId == param_0) { + if (pMsg->entries[i].message_id == param_0) { rv = i; break; } @@ -695,19 +695,19 @@ u32 dMsgObject_c::getRevoMessageIndex(u32 param_1) { return param_1; } u32 msgIndexCount; - JMSMesgHeader_c* pMsg; + JMSMesgInfo_c* pMsg; int i = 0; int rv; s16 groupID = getMessageGroup(param_1); JUT_ASSERT(1916, groupID==s_groupID || groupID == 0) changeGroup(groupID); - pMsg = (JMSMesgHeader_c*)((char*)mpMsgDt + 0x20); + pMsg = (JMSMesgInfo_c*)((char*)mpMsgDt + 0x20); msgIndexCount = *((u16*)((char*)mpMsgDt + 0x28)); for (; i < msgIndexCount; i++) { - if (pMsg->entries[i].mStringId == param_1) { - s8* ptr = (s8*)pMsg + pMsg->sectionSize + pMsg->entries[i].mStringOffset + 8; + if (pMsg->entries[i].message_id == param_1) { + s8* ptr = (s8*)pMsg + pMsg->header.size + pMsg->entries[i].string_offset + 8; if (ptr[0] == 26 && ptr[2] == 3 && (s8)ptr[4] == 0) { - rv = pMsg->entries[*(int*)(ptr + 5)].mStringId; + rv = pMsg->entries[*(int*)(ptr + 5)].message_id; } else { rv = param_1; } @@ -725,11 +725,11 @@ u32 dMsgObject_c::getRevoMessageIndex(u32 param_1) { /* 802340D4-80234128 22EA14 0054+00 3/3 0/0 0/0 .text getMessageIndexAlways__12dMsgObject_cFUl */ u32 dMsgObject_c::getMessageIndexAlways(u32 param_0) { u32 i = 0; - JMSMesgHeader_c* pMsg = (JMSMesgHeader_c*)((char*)mpMsgRes + 0x20); + JMSMesgInfo_c* pMsg = (JMSMesgInfo_c*)((char*)mpMsgRes + 0x20); u32 msgIndexCount = *((u16*)((char*)mpMsgRes + 0x28)); int rv; for (; i < msgIndexCount; i++) { - if (pMsg->entries[i].mStringId == param_0) { + if (pMsg->entries[i].message_id == param_0) { rv = i; break; } @@ -743,7 +743,7 @@ u32 dMsgObject_c::getMessageIndexAlways(u32 param_0) { /* 80234128-8023413C 22EA68 0014+00 1/1 0/0 0/0 .text getMessageIDAlways__12dMsgObject_cFUl */ u32 dMsgObject_c::getMessageIDAlways(u32 param_0) { - return ((JMSMesgHeader_c*)((u8*)mpMsgRes + 0x20))->entries[param_0].mStringId; + return ((JMSMesgInfo_c*)((u8*)mpMsgRes + 0x20))->entries[param_0].message_id; } /* 8023413C-80234150 22EA7C 0014+00 4/4 0/0 0/0 .text getMessageGroup__12dMsgObject_cFUl @@ -1859,22 +1859,22 @@ bool dMsgObject_c::isTalkMessage() { /* 802372CC-80237334 231C0C 0068+00 0/0 5/5 0/0 .text getSmellName__12dMsgObject_cFv */ const char* dMsgObject_c::getSmellName() { - JMSMesgHeader_c* info_header_p = (JMSMesgHeader_c*)((char*)mpMsgRes + 0x20); - char* data_ptr = (char*)info_header_p + info_header_p->sectionSize; + JMSMesgInfo_c* info_header_p = (JMSMesgInfo_c*)((char*)mpMsgRes + 0x20); + char* data_ptr = (char*)info_header_p + info_header_p->header.size; JMSMesgEntry_c* info_entries = (JMSMesgEntry_c*)((char*)info_header_p + 0x10); JMSMesgEntry_c* msg_entry = &info_entries[(u16)getMessageIndex(getSmellTypeMessageID())]; - return data_ptr + msg_entry->mStringOffset + 8; + return data_ptr + msg_entry->string_offset + 8; } /* 80237334-8023738C 231C74 0058+00 0/0 5/5 0/0 .text getPortalName__12dMsgObject_cFv */ const char* dMsgObject_c::getPortalName() { - JMSMesgHeader_c* info_header_p = (JMSMesgHeader_c*)((char*)mpMsgRes + 0x20); - char* data_ptr = (char*)info_header_p + info_header_p->sectionSize; + JMSMesgInfo_c* info_header_p = (JMSMesgInfo_c*)((char*)mpMsgRes + 0x20); + char* data_ptr = (char*)info_header_p + info_header_p->header.size; JMSMesgEntry_c* info_entries = (JMSMesgEntry_c*)((char*)info_header_p + 0x10); JMSMesgEntry_c* msg_entry = &info_entries[getMessageIndex(getPortalMessageID())]; - return data_ptr + msg_entry->mStringOffset + 8; + return data_ptr + msg_entry->string_offset + 8; } /* 8023738C-8023741C 231CCC 0090+00 0/0 5/5 0/0 .text getBombName__12dMsgObject_cFv */ @@ -1888,32 +1888,32 @@ const char* dMsgObject_c::getBombName() { i_cursorPos = i_selectPos; } JUT_ASSERT(4083, i_cursorPos >= 0 && i_cursorPos < dSv_player_item_c::BOMB_BAG_MAX); - JMSMesgHeader_c* info_header_p = (JMSMesgHeader_c*)((char*)mpMsgRes + 0x20); - char* data_ptr = (char*)info_header_p + info_header_p->sectionSize; + JMSMesgInfo_c* info_header_p = (JMSMesgInfo_c*)((char*)mpMsgRes + 0x20); + char* data_ptr = (char*)info_header_p + info_header_p->header.size; JMSMesgEntry_c* info_entries = (JMSMesgEntry_c*)((char*)info_header_p + 0x10); JMSMesgEntry_c* msg_entry = &info_entries[getMessageIndexAlways(getBombMessageIDLocal(i_cursorPos) + 0x165)]; - return data_ptr + msg_entry->mStringOffset + 8; + return data_ptr + msg_entry->string_offset + 8; } /* 8023741C-80237478 231D5C 005C+00 0/0 5/5 0/0 .text getInsectName__12dMsgObject_cFv */ const char* dMsgObject_c::getInsectName() { - JMSMesgHeader_c* info_header_p = (JMSMesgHeader_c*)((char*)mpMsgRes + 0x20); - char* data_ptr = (char*)info_header_p + info_header_p->sectionSize; + JMSMesgInfo_c* info_header_p = (JMSMesgInfo_c*)((char*)mpMsgRes + 0x20); + char* data_ptr = (char*)info_header_p + info_header_p->header.size; JMSMesgEntry_c* info_entries = (JMSMesgEntry_c*)((char*)info_header_p + 0x10); JMSMesgEntry_c* msg_entry = &info_entries[getMessageIndexAlways(getInsectItemNoLocal() + 0x165)]; - return data_ptr + msg_entry->mStringOffset + 8; + return data_ptr + msg_entry->string_offset + 8; } /* 80237478-802374D0 231DB8 0058+00 0/0 5/5 0/0 .text getLetterName__12dMsgObject_cFv */ const char* dMsgObject_c::getLetterName() { - JMSMesgHeader_c* info_header_p = (JMSMesgHeader_c*)((char*)mpMsgRes + 0x20); - char* data_ptr = (char*)info_header_p + info_header_p->sectionSize; + JMSMesgInfo_c* info_header_p = (JMSMesgInfo_c*)((char*)mpMsgRes + 0x20); + char* data_ptr = (char*)info_header_p + info_header_p->header.size; JMSMesgEntry_c* info_entries = (JMSMesgEntry_c*)((char*)info_header_p + 0x10); JMSMesgEntry_c* msg_entry = &info_entries[getMessageIndexAlways(getLetterNameIDLocal())]; - return data_ptr + msg_entry->mStringOffset + 8; + return data_ptr + msg_entry->string_offset + 8; } /* 802374D0-80237520 231E10 0050+00 1/1 5/5 0/0 .text getSelectBombNum__12dMsgObject_cFv diff --git a/src/d/d_msg_unit.cpp b/src/d/d_msg_unit.cpp index b429956f201..26383285bcd 100644 --- a/src/d/d_msg_unit.cpp +++ b/src/d/d_msg_unit.cpp @@ -9,6 +9,22 @@ #include "d/d_kankyo.h" #include "d/d_meter2_info.h" +// temporary until a better solution is found +typedef struct dMsgUnit_inf1_entry { + u32 dat1EntryOffset; + u16 startFrame; + u16 endFrame; +} dMsgUnit_inf1_entry; + +typedef struct dMsgUnit_inf1_section_t { + /* 0x00 */ u32 msgType; // sectionType + /* 0x04 */ u32 size; // total size of the section + /* 0x08 */ u16 entryCount; + /* 0x0A */ u16 entryLength; + /* 0x0C */ u16 msgArchiveId; + /* 0x0E */ dMsgUnit_inf1_entry entries[0]; +} dMsgUnit_inf1_section_t; + /* 80238C94-80238CA4 2335D4 0010+00 1/1 0/0 0/0 .text __ct__10dMsgUnit_cFv */ dMsgUnit_c::dMsgUnit_c() {} @@ -57,20 +73,20 @@ void dMsgUnit_c::setTag(int param_1, int param_2, char* param_3, bool param_4) { if (!stack9) { bmg_header_t* iVar9 = (bmg_header_t*)dMeter2Info_getMsgUnitResource(); - inf1_section_t* inf1 = NULL; + dMsgUnit_inf1_section_t* inf1 = NULL; const void* dat1 = NULL; str1_section_t* str1 = NULL; int local_114 = sizeof(bmg_header_t); u32 size = iVar9->size; bmg_section_t* piVar12 = (bmg_section_t*)(((u8*)iVar9) + local_114); for (; local_114 < size; local_114 += piVar12->size) { - switch(piVar12->msgType) { + switch(piVar12->magic) { case 'FLW1': break; case 'FLI1': break; case 'INF1': - inf1 = (inf1_section_t*)piVar12; + inf1 = (dMsgUnit_inf1_section_t*)piVar12; break; case 'DAT1': dat1 = piVar12; @@ -86,7 +102,7 @@ void dMsgUnit_c::setTag(int param_1, int param_2, char* param_3, bool param_4) { // but the normal build doesn't really work with that. Same for inf1->entries. #ifdef DEBUG - inf1_entry_t* entry = &inf1->entries[param_1]; + dMsgUnit_inf1_entry* entry = &inf1->entries[param_1]; u32 dat1EntryOffset = entry->dat1EntryOffset; u16 startFrame = entry->startFrame; u16 endFrame = entry->endFrame;