From ea7c107eb784bc05c446956ec72b5aaee7b2e21c Mon Sep 17 00:00:00 2001 From: Briggs Baltzell Date: Wed, 11 Mar 2026 22:54:58 -0500 Subject: [PATCH] d_menu_cloth matching (#937) * Add `l_matDL` symbols and assets to config files for all regions for d_menu_cloth * Extend `daCLOTH_HIO_c` with `JORReflexible` and add static instance `l_HIO` in `d_menu_cloth` * Refactor `d_menu_cloth.h` to improve naming consistency for member variables. * Initialize `dMCloth_c` member variables and create HIO child in constructor * Include `l_matDL` in `d_menu_cloth` and call it in `dMCloth_c::draw`. * Add private member variables to `daCLOTH_HIO_c` in `d_menu_cloth.h` * Add virtual destructor to `daCLOTH_HIO_c` in `d_menu_cloth.h` * Swap `daCLOTH_HIO_c` and `daCLOTH_ChildHIO_c` class definitions and adjust member variables in `d_menu_cloth.h`. * Remove non-matching comments from `daCLOTH_ChildHIO_c` constructor and destructor in `d_menu_cloth.cpp`. * Initialize `daCLOTH_HIO_c` member variables and update `daCLOTH_ChildHIO_c` access modifiers in `d_menu_cloth`. * Remove unused member variables from `daCLOTH_HIO_c` and `daCLOTH_ChildHIO_c` in `d_menu_cloth.h`. * Match dMCloth_c::dMCloth_c * Match `dMCloth_c::init`. * Match `dMCloth_c` destructor. * Refactor `dMCloth_c` to use `mCurArr` for indexing and update structure definitions in `d_menu_cloth`. * Define `ARR_SIZE` constant and replace hardcoded array sizes in `d_menu_cloth`. * Match dMCloth_c::TevSetting * Match dMCloth_c::TevSettingMenu * Match `dMCloth_c::TevSettingMenu` and `dMCloth_c::TevSettingFileSelect`. * Match `dMCloth_c::lightSet1` * Start matching `dMCloth_c::cloth_init` and update structure definitions to use `INNER_SIZE` constant, optimize initialization logic, and replace redundant assignments with consolidated methods. * Match `dMCloth_c::setNrmVtx` implementation and update header declaration. * Match `daCLOTH_HIO_c` destructor implementation. * Match `dMenu_ClothCreate`, `dMenu_ClothDelete`, `dMenu_ClothExecute`, `dMenu_ClothDraw`, and `dMenu_ClothIsDelete` implementations and update related structure definitions. * Update `g_fopAc_Method` reference to `g_fopMsg_Method` in cloth menu structure. * Match `dMCloth_c::cloth_move` implementation and update type definitions for `field_0xa` and `field_0x34` to `s16`. * Start matching `dMCloth_c::cloth_move_sin` and `dMCloth_c::cloth_move_simple` implementations. * Match `dMCloth_c::ShadowTevSetting` implementation. * Match `dMCloth_c::ShadowTevSettingMenu` and `dMCloth_c::ShadowTevSettingFileSelect` implementations. * Match `dMCloth_c::alpha_out` implementation. * Match `dMCloth_c::plot` implementation and minor formatting fix in `dMCloth_c::ShadowTevSettingMenu`. * Refactor `d_menu_cloth` to replace s16 color fields with `GXColorS10` and `GXColor` structures. Update all related logic and structure definitions accordingly. * Match `dMCloth_c::draw` implementation, refactor initialization of `field_0x10`, and update associated structure definitions. * Match `dMCloth_c::plot_shadow` implementation and update parameter names in `plot` and `plot_shadow` declarations. * Update `d_menu_cloth` to use `msg_method_class` and `msg_process_profile_definition`. Refactor structure definitions and add TODO comment for size clarification. * Add member comments in `dMenu_ClothMethodTable` * Refactor `d_menu_cloth` to improve pointer arithmetic in `plot` loop and add missing implementations for `getOffsetVec` and `getShadowPos`. * Refactor `dMCloth_c::plot` to improve naming consistency for loop variables and pointer arithmetic. * Refactor `d_menu_cloth` to replace repeated member accesses with `HIO_CHILD` macro for improved readability and maintainability. * Rename fields in `d_menu_cloth` * Add clarifying comments in `dMenu_ClothMethodTable` about function order and usage * Use `TRUE` and `FALSE` macros instead of literal values in `d_menu_cloth` methods for consistency. * Replace numeric cloth type values with `MenuClothType` enum for improved readability and maintainability in `d_menu_cloth`. * Refactor `dMCloth_c::cloth_init`: replace raw pointer arithmetic with `set` calls for improved clarity and maintainability. * Refactor `MENU_CLOTH_TYPE_2` logic: replace hardcoded rotation calculation with `cM_deg2s` for clarity and maintainability. * Change `wavePreSteps` type from `u16` to `s16` in `d_menu_cloth` for alignment with signed calculations. * Replace hardcoded angle conversion with `cM_deg2s` in `MENU_CLOTH_TYPE_0` logic for improved clarity and maintainability. * Change `mWaveProgress` type from `u16` to `s16` in `d_menu_cloth` for consistency with signed calculations. * Match `cloth_init` in `d_menu_cloth` * Fix `INNER_SIZE` iteration in `d_menu_cloth` to properly handle loop bounds. * Update vertex attribute formats in `d_menu_cloth` for improved correctness. * Add inline utility function `GXColor4x8` to `GX.h` for streamlined color input handling * Refactor triangle strip generation in `d_menu_cloth` for improved readability and maintainability. * Refactor vertex and texture coordinate handling in `dMCloth_c::plot_shadow` for improved clarity and correctness. * Refactor vertex handling in `d_menu_cloth` to group vertex and texture operations for improved readability and structure. * Add `GXNormal1x16` and `GXColor3x8` inline utility functions to `GX.h` for simplified normal and color input handling. * Update vertex format in `d_menu_cloth` to use `GXPosition1x16` and `GXNormal1x16` for improved attribute handling. * Add `dMs_clothOnly_create` and `dMs_clothOnly_delete` implementations in `d_menu_window` * Implement `dMs_cloth_create` and `dMs_cloth_delete` functions in `d_menu_window` and update related structure definitions. * Replace hardcoded cloth type with `MENU_CLOTH_TYPE_2` constant in `d_menu_window`. * Refactor `MENU_CLOTH_TYPE` enum names for clarity and update all references across `d_menu_cloth`, `d_s_name`, and `d_menu_window`. * Refactor `mChildren` array indexing in `daCLOTH_HIO_c` constructor to use `MENU_CLOTH_TYPE` constants for improved readability and maintainability. * Refactor `color1` and `color2` fields to `clothColor` and `shadowColor` for improved clarity in `d_menu_cloth` structure and related logic. * Simplify alpha blending logic by removing redundant variables in `d_menu_cloth`. * Refactor `mColor1`/`mColor2` to `mClothColor`/`mShadowColor` for improved clarity in `d_menu_cloth` and update all related logic. * Add temporary `dummy0` function in `d_menu_window` for placeholder debug strings. * Refactor position array access in `d_menu_cloth` to use `getPos()` result for better clarity and maintainability. * Change `waveFreqX` and `waveFreqY` types from `u16` to `s16` in `d_menu_cloth` structure for consistency. * Add demo version-specific mipmap handling logic in `d_menu_cloth` initialization. * Remove demo version-specific mipmap handling logic in `d_menu_cloth` initialization. * Match `cloth_move_sin` and `cloth_move_simple`. * Refactor loop variable initialization in `d_menu_cloth` for improved clarity. * Refactor variable names in alpha calculation for improved clarity in `d_menu_cloth`. * Inline vertex index calculations in `d_menu_cloth` to simplify code and reduce redundant variables. * Match `plot` and `plot_shadow`. * Refactor `lightDistance` variable in `d_menu_cloth` for improved clarity. * Inline empty destructor for `daCLOTH_HIO_c` in `d_menu_cloth` to simplify code. * Match `plot` and `plot_shadow` in demo build. * Update vertex attribute formats and streamline vertex function calls in `d_cloth_packet`. * Match `cloth_init` for JP version * Match `init` for JP version * Match `draw` for JP version * Add TODO note to identify superclass for correct size in `menu_cloth_class`. * Match `d_menu_cloth` for specific regions: GZLJ01, GZLE01, GZLP01. * Adjust `plot_shadow` parameters in `d_menu_cloth` for consistent shadow scaling. * Add dummy functions to ensure correct float order in `d_menu_cloth`. * Use version-specific scale values for `MENU_CLOTH_TYPE_DEFAULT` in `d_menu_cloth`. * Normalize hex color and value formatting in `d_menu_cloth`. * Add `STATIC_ASSERT` checks for struct size validation in `d_menu_cloth`. * Rename ambiguous `field` members to `padding` in `d_menu_cloth` and update struct size. * Replace `menu_cloth_class` size calculation with `sizeof(dMCloth_c)` in `d_menu_cloth`. * Revert "Replace `menu_cloth_class` size calculation with `sizeof(dMCloth_c)` in `d_menu_cloth`." This reverts commit 3920b07e1ab3a757b87d490bc0861d346ac8c742. * Revert "Rename ambiguous `field` members to `padding` in `d_menu_cloth` and update struct size." This reverts commit 153ee490bfab1a5a18d6237a9aaf3318a1ebf4c3. * Rename placeholder fields to `padding_*` in `d_menu_cloth` for clarity. * Update `menu_cloth_class` size handling with `STATIC_ASSERT` and padding. * Clarify comment for `dMenu_ClothMethodTable` initialization. * Replace hardcoded offsets with calculated `INNER_SIZE`-based sizes in `d_menu_cloth`. * Remove stray comments in `setClothType` definition and invocation. * Annotate `mStatus` with offset comment in `dDlst_MENU_CAPTURE_c`. * Replace `g_dComIfG_gameInfo.play` calls with `dComIfGp_` equivalents in `d_menu_window`. --- config/D44J01/config.yml | 4 + config/GZLE01/config.yml | 4 + config/GZLJ01/config.yml | 4 + config/GZLP01/config.yml | 4 + configure.py | 2 +- include/d/d_menu_cloth.h | 111 +++-- include/d/d_menu_window.h | 7 +- include/dolphin/gx/GX.h | 17 + src/d/d_cloth_packet.cpp | 15 +- src/d/d_menu_cloth.cpp | 920 ++++++++++++++++++++++++++++++++++++-- src/d/d_menu_window.cpp | 115 ++++- src/d/d_s_name.cpp | 2 +- 12 files changed, 1124 insertions(+), 81 deletions(-) diff --git a/config/D44J01/config.yml b/config/D44J01/config.yml index afb7cd053..431939631 100644 --- a/config/D44J01/config.yml +++ b/config/D44J01/config.yml @@ -3258,3 +3258,7 @@ extract: - symbol: l_alpha_matDL!.data:0x8036ADE0 binary: assets/l_alpha_matDL__d_cloth_packet.bin header: assets/l_alpha_matDL__d_cloth_packet.h + +- symbol: l_matDL!.data:0x80385FC0 + binary: assets/l_matDL__d_menu_cloth.bin + header: assets/l_matDL__d_menu_cloth.h diff --git a/config/GZLE01/config.yml b/config/GZLE01/config.yml index 2361a311f..9218a8570 100644 --- a/config/GZLE01/config.yml +++ b/config/GZLE01/config.yml @@ -2807,3 +2807,7 @@ extract: - symbol: l_alpha_matDL!.data:0x80376e60 binary: assets/l_alpha_matDL__d_cloth_packet.bin header: assets/l_alpha_matDL__d_cloth_packet.h + +- symbol: l_matDL!.data:0x80391DE0 + binary: assets/l_matDL__d_menu_cloth.bin + header: assets/l_matDL__d_menu_cloth.h diff --git a/config/GZLJ01/config.yml b/config/GZLJ01/config.yml index cfbb00d26..80fb81101 100644 --- a/config/GZLJ01/config.yml +++ b/config/GZLJ01/config.yml @@ -2391,3 +2391,7 @@ extract: - symbol: l_alpha_matDL!.data:0x8036A300 binary: assets/l_alpha_matDL__d_cloth_packet.bin header: assets/l_alpha_matDL__d_cloth_packet.h + +- symbol: l_matDL!.data:0x80385480 + binary: assets/l_matDL__d_menu_cloth.bin + header: assets/l_matDL__d_menu_cloth.h diff --git a/config/GZLP01/config.yml b/config/GZLP01/config.yml index 2761c626a..93e896dfa 100644 --- a/config/GZLP01/config.yml +++ b/config/GZLP01/config.yml @@ -2403,3 +2403,7 @@ extract: - symbol: l_alpha_matDL!.data:0x8037DB40 binary: assets/l_alpha_matDL__d_cloth_packet.bin header: assets/l_alpha_matDL__d_cloth_packet.h + +- symbol: l_matDL!.data:0x80398AC0 + binary: assets/l_matDL__d_menu_cloth.bin + header: assets/l_matDL__d_menu_cloth.h diff --git a/configure.py b/configure.py index b05bf13a7..4a2b7e82d 100755 --- a/configure.py +++ b/configure.py @@ -607,7 +607,7 @@ config.libs = [ Object(Matching, "d/d_ky_thunder.cpp"), Object(Matching, "d/d_letter.cpp"), Object(Matching, "d/d_level_se.cpp"), - Object(NonMatching, "d/d_menu_cloth.cpp"), + Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/d_menu_cloth.cpp"), Object(NonMatching, "d/d_menu_collect.cpp"), Object(NonMatching, "d/d_menu_dmap.cpp"), Object(NonMatching, "d/d_menu_fmap.cpp"), diff --git a/include/d/d_menu_cloth.h b/include/d/d_menu_cloth.h index 018fd1e3c..9768521d1 100644 --- a/include/d/d_menu_cloth.h +++ b/include/d/d_menu_cloth.h @@ -7,27 +7,34 @@ class JKRArchive; +enum { + MENU_CLOTH_TYPE_DEFAULT = 0, + MENU_CLOTH_TYPE_FILE_SELECT = 1, + MENU_CLOTH_TYPE_CLOTH_ONLY = 2, +}; +typedef u8 MenuClothType; + class dMCloth_c { public: dMCloth_c(); virtual ~dMCloth_c(); - void getBackNrm() {} - void getNrm() {} - void getOffsetVec() {} - void getPos() {} - void getShadowPos() {} - void getTexObj() {} - void setArchive(JKRArchive* arc) { field_0x44 = arc; } - void setClothType(u8 type) { field_0x913d = type; } // ? + cXyz* getPos() { return mPosArr[mCurArr]; } + cXyz* getNrm() { return mNrmArr[mCurArr]; } + cXyz* getBackNrm() { return mBackNrmArr; } + cXyz* getOffsetVec() { return mOffsetVecArr; } + cXyz* getShadowPos() { return mShadowPosArr; } + GXTexObj* getTexObj() { return &mTexObj; } + void setArchive(JKRArchive* arc) { mpArc = arc; } + void setClothType(MenuClothType type) { mClothType = type; } void lightSet1(cXyz); void cloth_init(); void init(); void setBackNrm(); - void setNrmVtx(cXyz*, int, int); - void plot(float, float, float, float); - void plot_shadow(float, float, float, float); + void setNrmVtx(cXyz* pDst, int x, int y); + void plot(float xMin, float yMin, float xMax, float yMax); + void plot_shadow(float xMin, float yMin, float xMax, float yMax); void alpha_out(); void TevSettingMenu(); void TevSettingFileSelect(); @@ -40,28 +47,78 @@ public: void cloth_move_simple(); void cloth_move(); - /* 0x0004 */ u8 field_0x4[0x44 - 0x04]; - /* 0x0044 */ JKRArchive* field_0x44; - /* 0x0048 */ cXyz field_0x48[882]; - /* 0x29A0 */ cXyz field_0x29a0[882]; - /* 0x52F8 */ cXyz field_0x52f8[441]; - /* 0x67A4 */ cXyz field_0x67a4[441]; - /* 0x7C50 */ cXyz field_0x7c50[441]; - /* 0x90FC */ GXTexObj field_0x90fc; - /* 0x911C */ u8 field_0x911c[0x913D - 0x911C]; - /* 0x913D */ u8 field_0x913d; - /* 0x913E */ u8 field_913e[0x9168 - 0x913E]; +private: + static s16 init_angle_z; + +public: + static const int ARR_SIZE = 441; + static const int INNER_SIZE = 11; + + /* 0x0004 */ u16 unused_0x4; + /* 0x0006 */ u8 padding_0x6[0x08 - 0x06]; + /* 0x0008 */ s16 mWaveProgress; + /* 0x000A */ s16 mFadeInCounter; + /* 0x000C */ u8 mAlphaOut; + /* 0x000D */ u8 mCurrentAlpha; + /* 0x000E */ u8 padding_0xe[0x44 - 0x0E]; + /* 0x0044 */ JKRArchive* mpArc; + /* 0x0048 */ cXyz mPosArr[2][ARR_SIZE]; + /* 0x29A0 */ cXyz mNrmArr[2][ARR_SIZE]; + /* 0x52F8 */ cXyz mBackNrmArr[ARR_SIZE]; + /* 0x67A4 */ cXyz mOffsetVecArr[ARR_SIZE]; + /* 0x7C50 */ cXyz mShadowPosArr[ARR_SIZE]; + /* 0x90FC */ GXTexObj mTexObj; + /* 0x911C */ u8 padding_0x911c[0x913C - 0x911C]; + /* 0x913C */ u8 mCurArr; + /* 0x913D */ MenuClothType mClothType; + /* 0x913E */ u8 padding_0x913e[0x9140 - 0x913E]; + /* 0x9140 */ cXyz mScale; + /* 0x914C */ u8 padding_0x914C[0x9158 - 0x914C]; + /* 0x9158 */ csXyz mRot; + /* 0x915E */ GXColor mClothColor; + /* 0x9162 */ GXColor mShadowColor; }; -class daCLOTH_HIO_c { -public: - daCLOTH_HIO_c(); -}; +STATIC_ASSERT(sizeof(dMCloth_c) == 0x9168); class daCLOTH_ChildHIO_c { public: daCLOTH_ChildHIO_c(); - ~daCLOTH_ChildHIO_c(); + virtual ~daCLOTH_ChildHIO_c(); + +public: + /* 0x0004 */ cXyz scale; + /* 0x0010 */ cXyz pos; + /* 0x001c */ csXyz rot; + /* 0x0022 */ GXColorS10 clothColor; + /* 0x002a */ GXColorS10 shadowColor; + /* 0x0032 */ s16 startAlpha; + /* 0x0034 */ s16 fadeInLength; + /* 0x0036 */ s16 waveProgressStep; + /* 0x0038 */ s16 waveFreqX; + /* 0x003a */ s16 waveFreqY; + /* 0x003c */ f32 waveAmpX; + /* 0x0040 */ f32 waveAmpY; + /* 0x0044 */ f32 waveAmpZ; + /* 0x0048 */ s16 lightPitch; + /* 0x004a */ s16 lightYaw; + /* 0x004c */ f32 lightDistance; + /* 0x0050 */ s16 wavePreSteps; + /* 0x0054 */ f32 maxStep; }; +STATIC_ASSERT(sizeof(daCLOTH_ChildHIO_c) == 0x58); + +class daCLOTH_HIO_c : public JORReflexible { +public: + daCLOTH_HIO_c(); + virtual ~daCLOTH_HIO_c() {} + +public: + /* 0x0004 */ s8 mNo; + /* 0x0008 */ daCLOTH_ChildHIO_c mChildren[3]; +}; + +STATIC_ASSERT(sizeof(daCLOTH_HIO_c) == 0x110); + #endif /* D_MENU_CLOTH_H */ diff --git a/include/d/d_menu_window.h b/include/d/d_menu_window.h index 5b1393c29..619a20a21 100644 --- a/include/d/d_menu_window.h +++ b/include/d/d_menu_window.h @@ -3,9 +3,13 @@ #include "dolphin/types.h" +class JKRExpHeap; + class sub_ms_screen_class { public: - + u8 field_0x00[0xFC - 0x00]; + JKRHeap* parentHeap_0xfc; + JKRHeap* childHeap; }; class dMw_HIO_c { @@ -18,5 +22,4 @@ public: dMw_DHIO_c(); }; - #endif /* D_MENU_WINDOW_H */ diff --git a/include/dolphin/gx/GX.h b/include/dolphin/gx/GX.h index dbd7f0345..e8b76454d 100644 --- a/include/dolphin/gx/GX.h +++ b/include/dolphin/gx/GX.h @@ -188,10 +188,27 @@ inline void GXNormal1x8(u8 x) { GXFIFO.u8 = x; } +inline void GXNormal1x16(u16 x) { + GXFIFO.u16 = x; +} + inline void GXColor1x16(u16 x) { GXFIFO.u16 = x; } +inline void GXColor3x8(u8 r, u8 g, u8 b) { + GXFIFO.u8 = r; + GXFIFO.u8 = g; + GXFIFO.u8 = b; +} + +inline void GXColor4x8(u8 r, u8 g, u8 b, u8 a) { + GXFIFO.u8 = r; + GXFIFO.u8 = g; + GXFIFO.u8 = b; + GXFIFO.u8 = a; +} + inline void GXTexCoord1x16(u16 x) { GXFIFO.u16 = x; } diff --git a/src/d/d_cloth_packet.cpp b/src/d/d_cloth_packet.cpp index ccac2aa29..19b3c2ec4 100644 --- a/src/d/d_cloth_packet.cpp +++ b/src/d/d_cloth_packet.cpp @@ -188,9 +188,9 @@ void dCloth_packet_c::draw() { GXSetVtxDesc(GX_VA_POS, GX_INDEX8); GXSetVtxDesc(GX_VA_NRM, GX_INDEX8); GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); - GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0); - GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_CLR_RGB, GX_F32, 0); - GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); #if VERSION == VERSION_DEMO { @@ -488,11 +488,12 @@ void dCloth_packet_c::plot() { float yPos = 0.0f; for (int y = 0; y < mHoistGridSize; y++) { GXPosition1x8(x + y * mFlyGridSize); - GXPosition1x8(x + y * mFlyGridSize); - GXPosition2f32(xPos, yPos); + GXNormal1x8(x + y * mFlyGridSize); + GXTexCoord2f32(xPos, yPos); + GXPosition1x8(xNext + y * mFlyGridSize); - GXPosition1x8(xNext + y * mFlyGridSize); - GXPosition2f32(xPos + xStep, yPos); + GXNormal1x8(xNext + y * mFlyGridSize); + GXTexCoord2f32(xPos + xStep, yPos); yPos += yStep; } diff --git a/src/d/d_menu_cloth.cpp b/src/d/d_menu_cloth.cpp index 96e645be6..40084ef58 100644 --- a/src/d/d_menu_cloth.cpp +++ b/src/d/d_menu_cloth.cpp @@ -5,143 +5,989 @@ #include "d/dolzel.h" // IWYU pragma: keep #include "d/d_menu_cloth.h" +#include "d/d_procname.h" +#include "d/d_priority.h" + +#include "assets/l_matDL__d_menu_cloth.h" + +static daCLOTH_HIO_c l_HIO; + +s16 dMCloth_c::init_angle_z = 0; + +#define HIO_CHILD (l_HIO.mChildren[mClothType]) /* 8019940C-8019966C .text __ct__13daCLOTH_HIO_cFv */ daCLOTH_HIO_c::daCLOTH_HIO_c() { - /* Nonmatching */ + mNo = -1; + + // Default + { + const f32 scale = VERSION_SELECT(1.75f, 1.75f, 1.78f, 1.78f); + mChildren[MENU_CLOTH_TYPE_DEFAULT].scale.set(scale, scale, 1.0f); + mChildren[MENU_CLOTH_TYPE_DEFAULT].rot.setall(0); + mChildren[MENU_CLOTH_TYPE_DEFAULT].pos.set(360.0f, 40.0f, -2400.0f); + + // Middle green + mChildren[MENU_CLOTH_TYPE_DEFAULT].clothColor.r = 0x78; + mChildren[MENU_CLOTH_TYPE_DEFAULT].clothColor.g = 0xA5; + mChildren[MENU_CLOTH_TYPE_DEFAULT].clothColor.b = 0x37; + mChildren[MENU_CLOTH_TYPE_DEFAULT].clothColor.a = 0xDC; + + // Dark green + mChildren[MENU_CLOTH_TYPE_DEFAULT].shadowColor.r = 0x23; + mChildren[MENU_CLOTH_TYPE_DEFAULT].shadowColor.g = 0x5F; + mChildren[MENU_CLOTH_TYPE_DEFAULT].shadowColor.b = 0x19; + mChildren[MENU_CLOTH_TYPE_DEFAULT].shadowColor.a = 0x20; + + mChildren[MENU_CLOTH_TYPE_DEFAULT].startAlpha = 0; + mChildren[MENU_CLOTH_TYPE_DEFAULT].fadeInLength = 7; + + mChildren[MENU_CLOTH_TYPE_DEFAULT].waveProgressStep = -1000; + mChildren[MENU_CLOTH_TYPE_DEFAULT].waveFreqX = 9000; + mChildren[MENU_CLOTH_TYPE_DEFAULT].waveFreqY = 0x800; + mChildren[MENU_CLOTH_TYPE_DEFAULT].waveAmpX = 5.0; + mChildren[MENU_CLOTH_TYPE_DEFAULT].waveAmpY = 5.0; + mChildren[MENU_CLOTH_TYPE_DEFAULT].waveAmpZ = 250.0; + + mChildren[MENU_CLOTH_TYPE_DEFAULT].lightDistance = 1000.0; + mChildren[MENU_CLOTH_TYPE_DEFAULT].lightPitch = 0; + mChildren[MENU_CLOTH_TYPE_DEFAULT].lightYaw = 0; + + mChildren[MENU_CLOTH_TYPE_DEFAULT].wavePreSteps = 2; + mChildren[MENU_CLOTH_TYPE_DEFAULT].maxStep = 290.0f; + } + + // File Select + { + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].scale.set(1.27f, 0.93f, 1.0f); + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].rot.setall(0); + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].pos.set(350.0f, -15.0f, -2400.0f); + + // Beige + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].clothColor.r = 0xBE; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].clothColor.g = 0xB4; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].clothColor.b = 0x64; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].clothColor.a = 0xAA; + + // Dark brown + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].shadowColor.r = 0x8C; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].shadowColor.g = 0x50; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].shadowColor.b = 0x14; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].shadowColor.a = 0x20; + + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].startAlpha = 0; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].fadeInLength = 7; + + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].waveProgressStep = -1000; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].waveFreqX = 9000; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].waveFreqY = 0x800; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].waveAmpX = 5.0; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].waveAmpY = 5.0; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].waveAmpZ = 250.0; + + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].lightDistance = 1000.0; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].lightPitch = 0; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].lightYaw = 0; + + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].wavePreSteps = 2; + mChildren[MENU_CLOTH_TYPE_FILE_SELECT].maxStep = 290.0; + } + + // Cloth Only + { + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].scale.set(1.7f, 1.7f, 1.0f); + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].rot.set(0, 0, 0x4000); + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].pos.set(360.0f, 40.0f, -2400.0f); + + // Beige + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].clothColor.r = 0xBE; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].clothColor.g = 0xB4; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].clothColor.b = 0x64; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].clothColor.a = 0xDC; + + // Dark brown + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].shadowColor.r = 0x8C; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].shadowColor.g = 0x50; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].shadowColor.b = 0x14; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].shadowColor.a = 0x20; + + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].startAlpha = 0; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].fadeInLength = 7; + + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].waveProgressStep = -1000; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].waveFreqX = 9000; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].waveFreqY = 0x800; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].waveAmpX = 5.0; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].waveAmpY = 5.0; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].waveAmpZ = 250.0; + + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].lightDistance = 1000.0; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].lightPitch = 0; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].lightYaw = 0; + + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].wavePreSteps = 2; + mChildren[MENU_CLOTH_TYPE_CLOTH_ONLY].maxStep = 290.0; + } } /* 8019966C-801996B4 .text __dt__18daCLOTH_ChildHIO_cFv */ daCLOTH_ChildHIO_c::~daCLOTH_ChildHIO_c() { - /* Nonmatching */ } /* 801996B4-801996C4 .text __ct__18daCLOTH_ChildHIO_cFv */ daCLOTH_ChildHIO_c::daCLOTH_ChildHIO_c() { - /* Nonmatching */ } /* 801996C4-8019977C .text lightSet1__9dMCloth_cF4cXyz */ void dMCloth_c::lightSet1(cXyz) { - /* Nonmatching */ + GXLightObj light; + const f32 lightDistance = HIO_CHILD.lightDistance; + GXInitLightPos( + &light, + -lightDistance * cM_ssin(HIO_CHILD.lightYaw) * cM_scos(HIO_CHILD.lightPitch), + -lightDistance * cM_ssin(HIO_CHILD.lightPitch), + -lightDistance * cM_scos(HIO_CHILD.lightYaw) * cM_scos(HIO_CHILD.lightPitch) + ); + GXInitLightColor(&light, (GXColor){0xFF, 0xFF, 0xFF, 0x00}); + GXLoadLightObjImm(&light, GX_LIGHT0); +} + +// This is to get the floats in the right order. +void dummy0() { + vf32 a; + a = 0.0f; + a = 90.0f; } /* 8019977C-80199CD0 .text cloth_init__9dMCloth_cFv */ void dMCloth_c::cloth_init() { - /* Nonmatching */ + cXyz* pPosArr = getPos(); + cXyz* pNrm = getNrm(); + cXyz* pOffArr = getOffsetVec(); + + for (int y = 0; y < INNER_SIZE; y++) { + int x = 0; + s16 yAngle = -y * 3500; + for (; x < INNER_SIZE; x++) { + pPosArr[x + y * INNER_SIZE].x = cM_ssin(x * 3276.8f) * 954.9299f + -1500.0f + x * 10.0f * cM_ssin(yAngle); + pPosArr[x + y * INNER_SIZE].y = y * 300.0f + -1500.0f; + pPosArr[x + y * INNER_SIZE].z = (1.0f - cM_scos(x * 3276.8f)) * 716.1974f + -3400.0f + x * -5.0f * cM_scos(yAngle); + + pOffArr[x + y * INNER_SIZE].set(cM_scos(x * 3276.8f - 1000.0f) * -320.0f, 0.0f, cM_ssin(x * 3276.8f - 1000.0f) * -270.0f); + } + } + + for (int y = 0; y < INNER_SIZE; y++) { + for (int x = 0; x < INNER_SIZE; x++) { + setNrmVtx(pNrm, x, y); + pNrm++; + } + } + + setBackNrm(); + + mWaveProgress = 0; + mFadeInCounter = 0; + + cloth_move(); + + mAlphaOut = 0; + mCurrentAlpha = HIO_CHILD.clothColor.a; + mWaveProgress += HIO_CHILD.waveProgressStep; + + DCStoreRangeNoSync(mPosArr[mCurArr], INNER_SIZE * INNER_SIZE * sizeof(cXyz)); + DCStoreRangeNoSync(mNrmArr[mCurArr], INNER_SIZE * INNER_SIZE * sizeof(cXyz)); +#if VERSION > VERSION_JPN + DCStoreRangeNoSync(mBackNrmArr, INNER_SIZE * INNER_SIZE * sizeof(cXyz)); +#endif + + mClothColor.r = (u8)HIO_CHILD.clothColor.r; + mClothColor.g = (u8)HIO_CHILD.clothColor.g; + mClothColor.b = (u8)HIO_CHILD.clothColor.b; + mClothColor.a = (u8)HIO_CHILD.clothColor.a; + + mShadowColor.r = (u8)HIO_CHILD.shadowColor.r; + mShadowColor.g = (u8)HIO_CHILD.shadowColor.g; + mShadowColor.b = (u8)HIO_CHILD.shadowColor.b; + mShadowColor.a = (u8)HIO_CHILD.shadowColor.a; + + switch (mClothType) { + case MENU_CLOTH_TYPE_DEFAULT: { + init_angle_z += cM_deg2s(cM_rndFX(45.0f) + 90.0f); + +#if VERSION > VERSION_JPN + mScale = HIO_CHILD.scale; +#else + mScale.set(1.75f, 1.75f, 1.0f); +#endif + + mRot.set(0, 0, init_angle_z); + s32 n = HIO_CHILD.wavePreSteps; + while (n--) { + cloth_move_sin(); + } + } break; + case MENU_CLOTH_TYPE_FILE_SELECT: { + mScale.set(1.27f, 0.93f, 1.0f); + mRot.setall(0); + } break; + case MENU_CLOTH_TYPE_CLOTH_ONLY: { + mScale = HIO_CHILD.scale; + mRot = HIO_CHILD.rot; + mRot.z += cM_deg2s(cM_rndFX(20.0f)); + s32 n = HIO_CHILD.wavePreSteps; + while (n--) { + cloth_move_sin(); + } + } break; + } +} + +// This is to get the floats in the right order. +void dummy1() { + vf32 a = 305.0f; } /* 80199CD0-80199E1C .text init__9dMCloth_cFv */ void dMCloth_c::init() { - /* Nonmatching */ + cloth_init(); + + ResTIMG* image = (ResTIMG*)JKRArchive::getGlbResource('TIMG', "cloth_piece01.bti", mpArc); + JUT_ASSERT(VERSION_SELECT(528, 526, 530, 530), image != NULL); + +#if VERSION == VERSION_DEMO + BOOL mipmap = image->mipmapCount > 1; +#endif + + GXInitTexObj( + &mTexObj, + (u8*)image + image->imageOffset, + image->width, + image->height, + GXTexFmt(image->format), + GXTexWrapMode(image->wrapS), + GXTexWrapMode(image->wrapT), +#if VERSION == VERSION_DEMO + mipmap +#else + image->mipmapCount > 1 +#endif + ); + + GXInitTexObjLOD( + &mTexObj, + GXTexFilter(image->minFilter), + GXTexFilter(image->magFilter), + image->minLOD * 0.125f, + image->maxLOD * 0.125f, + image->LODBias * 0.01f, + image->biasClamp, + image->doEdgeLOD, + GXAnisotropy(image->maxAnisotropy) + ); } /* 80199E1C-80199F48 .text __ct__9dMCloth_cFv */ dMCloth_c::dMCloth_c() { - /* Nonmatching */ + mCurArr = 0; + unused_0x4 = 0; + mClothType = MENU_CLOTH_TYPE_DEFAULT; + if (l_HIO.mNo < 0) { + l_HIO.mNo = mDoHIO_createChild("メニューの布", &l_HIO); // Menu cloth + } } /* 80199F48-8019A058 .text __dt__9dMCloth_cFv */ dMCloth_c::~dMCloth_c() { - /* Nonmatching */ + if (l_HIO.mNo >= 0) { + mDoHIO_deleteChild(l_HIO.mNo); + l_HIO.mNo = -1; + } + + mpArc->removeResourceAll(); } /* 8019A058-8019A0AC .text setBackNrm__9dMCloth_cFv */ void dMCloth_c::setBackNrm() { - /* Nonmatching */ + cXyz* pNrm = getNrm(); + cXyz* pBackNrm = getBackNrm(); + + for (int i = 0; i < ARR_SIZE; i++) { + pBackNrm->set(-pNrm->x, -pNrm->y, -pNrm->z); + pNrm++; + pBackNrm++; + } } /* 8019A0AC-8019A480 .text setNrmVtx__9dMCloth_cFP4cXyzii */ -void dMCloth_c::setNrmVtx(cXyz*, int, int) { - /* Nonmatching */ +void dMCloth_c::setNrmVtx(cXyz* pDst, int x, int y) { + cXyz x_diff; + cXyz y_diff; + cXyz norm; + cXyz total; + cXyz pos; + + cXyz* pPos = getPos(); + pos = pPos[(x + y * INNER_SIZE)]; + total.setall(0.0f); + + if (x != 0) { + x_diff = pPos[x - 1 + y * INNER_SIZE] - pos; + if (y != 0) { + y_diff = pPos[x + (y - 1) * INNER_SIZE] - pos; + norm = x_diff.outprod(y_diff); + norm = norm.normZP(); + total += norm; + } + if (y != INNER_SIZE - 1) { + y_diff = pPos[x + (y + 1) * INNER_SIZE] - pos; + norm = y_diff.outprod(x_diff); + norm = norm.normZP(); + total += norm; + } + } + if (x != INNER_SIZE - 1) { + x_diff = pPos[x + 1 + y * INNER_SIZE] - pos; + if (y != 0) { + y_diff = pPos[x + (y - 1) * INNER_SIZE] - pos; + norm = y_diff.outprod(x_diff); + norm = norm.normZP(); + total += norm; + } + if (y != INNER_SIZE - 1) { + y_diff = pPos[x + (y + 1) * INNER_SIZE] - pos; + norm = x_diff.outprod(y_diff); + norm = norm.normZP(); + total += norm; + } + } + + MtxPush(); + + mDoMtx_YrotM(*calc_mtx, cM_ssin(x * -800) * 900.0f); + MtxPosition(&total, pDst); + if (!pDst->normalizeRS()) { + pDst->set(0.0f, 0.0f, 1.0f); + } + + MtxPull(); } /* 8019A480-8019A65C .text plot__9dMCloth_cFffff */ -void dMCloth_c::plot(float, float, float, float) { - /* Nonmatching */ +void dMCloth_c::plot(float xMin, float yMin, float xMax, float yMax) { + f32 xPos = 0.0f; + const f32 xStep = (xMax - xMin) * (1.0f / (f32)(INNER_SIZE - 1)); + const f32 yStep = (yMax - yMin) * (1.0f / (f32)(INNER_SIZE - 1)); + + for (int xNext = 1, x = 0; x < INNER_SIZE - 1; x++, xNext++) { + GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, INNER_SIZE * 2); + f32 yPos = yMax; + for (int y = 0; y < INNER_SIZE; y++) { + switch (mClothType) { + case MENU_CLOTH_TYPE_DEFAULT: + case MENU_CLOTH_TYPE_CLOTH_ONLY: { + // Vertex 1 + { + GXPosition1x16(x + y * INNER_SIZE); + GXNormal1x16(x + y * INNER_SIZE); + GXTexCoord2f32(xPos, yPos); + } + + // Vertex 2 + { + GXPosition1x16(xNext + y * INNER_SIZE); + GXNormal1x16(xNext + y * INNER_SIZE); + GXTexCoord2f32(xPos + xStep, yPos); + } + } break; + + case MENU_CLOTH_TYPE_FILE_SELECT: { + u8 alpha0, alpha1; + { + const int fromRight = 10 - x; + const int fromRightNext = 10 - xNext; + const int fromBottomRight = fromRight + y; + const int fromBottomRightNext = fromRightNext + y; + alpha0 = cLib_maxLimit(fromBottomRight * 25, 0xFF); + alpha1 = cLib_maxLimit(fromBottomRightNext * 25, 0xFF); + } + + // Vertex 1 + { + GXPosition1x16(x + y * INNER_SIZE); + GXNormal1x16(x + y * INNER_SIZE); + +#if VERSION == VERSION_DEMO + const u8 b = mClothColor.b; + const u8 g = mClothColor.g; + const u8 r = mClothColor.r; +#else + const u8 r = mClothColor.r; + const u8 b = mClothColor.b; + const u8 g = mClothColor.g; +#endif + + GXColor4x8(r, g, b, alpha0); + GXTexCoord2f32(xPos, yPos); + } + + // Vertex 2 + { + GXPosition1x16(xNext + y * INNER_SIZE); + GXNormal1x16(xNext + y * INNER_SIZE); + +#if VERSION == VERSION_DEMO + const u8 b = mClothColor.b; + const u8 g = mClothColor.g; + const u8 r = mClothColor.r; +#else + const u8 r = mClothColor.r; + const u8 b = mClothColor.b; + const u8 g = mClothColor.g; +#endif + + GXColor4x8(r, g, b, alpha1); + GXTexCoord2f32(xPos + xStep, yPos); + } + } break; + } + + yPos -= yStep; + } + + xPos += xStep; + } } /* 8019A65C-8019A838 .text plot_shadow__9dMCloth_cFffff */ -void dMCloth_c::plot_shadow(float, float, float, float) { - /* Nonmatching */ +void dMCloth_c::plot_shadow(float xMin, float yMin, float xMax, float yMax) { + f32 xPos = 0.0f; + const f32 xStep = (xMax - xMin) * (1.0f / (f32)(INNER_SIZE - 1)); + const f32 yStep = (yMax - yMin) * (1.0f / (f32)(INNER_SIZE - 1)); + + for (int xNext = 1, x = 0; x < INNER_SIZE - 1; x++, xNext++) { + GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, INNER_SIZE * 2); + f32 yPos = yMax; + for (int y = 0; y < INNER_SIZE; y++) { + switch (mClothType) { + case MENU_CLOTH_TYPE_DEFAULT: + case MENU_CLOTH_TYPE_CLOTH_ONLY: { + // Vertex 1 + { + GXPosition1x16(x + y * INNER_SIZE); + GXNormal1x16(x + y * INNER_SIZE); + GXTexCoord2f32(xPos, yPos); + } + + // Vertex 2 + { + GXPosition1x16(xNext + y * INNER_SIZE); + GXNormal1x16(xNext + y * INNER_SIZE); + GXTexCoord2f32(xPos + xStep, yPos); + } + } break; + + case MENU_CLOTH_TYPE_FILE_SELECT: { + u8 alpha0, alpha1; + { + const int fromRight = 10 - x; + const int fromRightNext = 10 - xNext; + const int fromBottomRight = fromRight + y; + const int fromBottomRightNext = fromRightNext + y; + alpha0 = cLib_maxLimit(fromBottomRight * 25, 0xFF); + alpha1 = cLib_maxLimit(fromBottomRightNext * 25, 0xFF); + } + + // Vertex 1 + { + GXPosition1x16(x + y * INNER_SIZE); + GXNormal1x16(x + y * INNER_SIZE); + +#if VERSION == VERSION_DEMO + const u8 b = mShadowColor.b; + const u8 g = mShadowColor.g; + const u8 r = mShadowColor.r; +#else + const u8 r = mShadowColor.r; + const u8 b = mShadowColor.b; + const u8 g = mShadowColor.g; +#endif + + GXColor4x8(r, g, b, alpha0); + GXTexCoord2f32(xPos, yPos); + } + + // Vertex 2 + { + GXPosition1x16(xNext + y * INNER_SIZE); + GXNormal1x16(xNext + y * INNER_SIZE); + +#if VERSION == VERSION_DEMO + const u8 b = mShadowColor.b; + const u8 g = mShadowColor.g; + const u8 r = mShadowColor.r; +#else + const u8 r = mShadowColor.r; + const u8 b = mShadowColor.b; + const u8 g = mShadowColor.g; +#endif + + GXColor4x8(r, g, b, alpha1); + GXTexCoord2f32(xPos + xStep, yPos); + } + } break; + } + + yPos -= yStep; + } + + xPos += xStep; + } } /* 8019A838-8019A844 .text alpha_out__9dMCloth_cFv */ void dMCloth_c::alpha_out() { - /* Nonmatching */ + mAlphaOut = 1; } /* 8019A844-8019A9C4 .text TevSettingMenu__9dMCloth_cFv */ void dMCloth_c::TevSettingMenu() { - /* Nonmatching */ + GXSetChanCtrl(GX_COLOR0, true, GX_SRC_REG, GX_SRC_REG, 1, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(1); + GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY); + GXSetNumTevStages(2); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP1, GX_TEV_SWAP0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C1, GX_CC_C0, GX_CC_TEXC, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); + GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV); + GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); } /* 8019A9C4-8019AB64 .text TevSettingFileSelect__9dMCloth_cFv */ void dMCloth_c::TevSettingFileSelect() { - /* Nonmatching */ + GXSetChanCtrl(GX_COLOR0, true, GX_SRC_REG, GX_SRC_REG, 1, GX_DF_CLAMP, GX_AF_NONE); + GXSetChanCtrl(GX_ALPHA0, false, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(1); + GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY); + GXSetNumTevStages(2); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP1, GX_TEV_SWAP0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C1, GX_CC_C0, GX_CC_TEXC, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_A0, GX_CA_RASA, GX_CA_ZERO); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV); + GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV); + GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); } /* 8019AB64-8019ABB4 .text TevSetting__9dMCloth_cFv */ void dMCloth_c::TevSetting() { - /* Nonmatching */ + switch (mClothType) { + case MENU_CLOTH_TYPE_DEFAULT: + case MENU_CLOTH_TYPE_CLOTH_ONLY: + TevSettingMenu(); + break; + case MENU_CLOTH_TYPE_FILE_SELECT: + TevSettingFileSelect(); + break; + } } /* 8019ABB4-8019AC8C .text ShadowTevSettingMenu__9dMCloth_cFv */ void dMCloth_c::ShadowTevSettingMenu() { - /* Nonmatching */ + GXSetChanCtrl(GX_COLOR0, true, GX_SRC_REG, GX_SRC_REG, 1, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(1); + GXSetNumTevStages(1); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP1, GX_TEV_SWAP0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A1); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); } /* 8019AC8C-8019AD84 .text ShadowTevSettingFileSelect__9dMCloth_cFv */ void dMCloth_c::ShadowTevSettingFileSelect() { - /* Nonmatching */ + GXSetChanCtrl(GX_COLOR0, true, GX_SRC_REG, GX_SRC_REG, 1, GX_DF_CLAMP, GX_AF_NONE); + GXSetChanCtrl(GX_ALPHA0, false, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(1); + GXSetNumTevStages(1); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP1, GX_TEV_SWAP0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_A1, GX_CA_RASA, GX_CA_ZERO); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV); } /* 8019AD84-8019ADD4 .text ShadowTevSetting__9dMCloth_cFv */ void dMCloth_c::ShadowTevSetting() { - /* Nonmatching */ + switch (mClothType) { + case MENU_CLOTH_TYPE_DEFAULT: + case MENU_CLOTH_TYPE_CLOTH_ONLY: + ShadowTevSettingMenu(); + break; + case MENU_CLOTH_TYPE_FILE_SELECT: + ShadowTevSettingFileSelect(); + break; + } } /* 8019ADD4-8019B670 .text draw__9dMCloth_cFf8_GXColor8_GXColorUc */ -void dMCloth_c::draw(float, GXColor, GXColor, unsigned char) { - /* Nonmatching */ +void dMCloth_c::draw(float, GXColor clothColor, GXColor shadowColor, unsigned char) { + cXyz* pPos = getPos(); + cXyz* pPos2 = mShadowPosArr; + for (int y = 0; y < INNER_SIZE; y++) { + for (int x = 0; x < INNER_SIZE; x++) { + *pPos2 = *pPos; + pPos2->z = -3300.0f; + pPos2++; + pPos++; + } + } + + DCStoreRangeNoSync(mShadowPosArr, INNER_SIZE * INNER_SIZE * sizeof(cXyz)); + + clothColor = mClothColor; + shadowColor = mShadowColor; + + if (mAlphaOut == 1) { + // Fade out alpha. + clothColor.a = mCurrentAlpha; + if (mCurrentAlpha > 25) { + mCurrentAlpha -= 25; + } else { + mCurrentAlpha = 0; + } + } else { + // Interpolate from startAlpha to final alpha. + f32 f = (f32)mFadeInCounter / HIO_CHILD.fadeInLength; + { + clothColor.a = cLib_minMaxLimit(HIO_CHILD.clothColor.a, 0, 0xFF); + clothColor.a = clothColor.a * f + (1.0f - f) * HIO_CHILD.startAlpha; + } + { + shadowColor.a = cLib_minMaxLimit(HIO_CHILD.shadowColor.a, 0, 0xFF); + shadowColor.a = shadowColor.a * f + (1.0f - f) * HIO_CHILD.startAlpha; + } + } + + j3dSys.reinitGX(); + +#if VERSION > VERSION_JPN + GXSetNumIndStages(0); +#endif + + cXyz lightPos; + lightPos.set(0.0f, 0.0f, 0.0f); + + switch (mClothType) { + case MENU_CLOTH_TYPE_DEFAULT: + case MENU_CLOTH_TYPE_CLOTH_ONLY: { + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_INDEX16); + GXSetVtxDesc(GX_VA_NRM, GX_INDEX16); + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GXSetChanAmbColor(GX_COLOR0, (GXColor){0x00, 0x00, 0x00, 0x00}); + GXSetChanMatColor(GX_COLOR0, (GXColor){0xFF, 0xFF, 0xFF, 0xFF}); + } break; + case MENU_CLOTH_TYPE_FILE_SELECT: { + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_INDEX16); + GXSetVtxDesc(GX_VA_NRM, GX_INDEX16); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GXSetChanAmbColor(GX_COLOR0, (GXColor){0x00, 0x00, 0x00, 0xFF}); + GXSetChanMatColor(GX_COLOR0, (GXColor){0xFF, 0xFF, 0xFF, 0xFF}); + } break; + } + + GXSetTevColor(GX_TEVREG0, clothColor); + GXSetTevColor(GX_TEVREG1, shadowColor); + + GXTexObj tex_obj; + + ResTIMG* i_toonimage = dDlst_list_c::getToonImage(); + + GXInitTexObj( + &tex_obj, + (u8*)i_toonimage + i_toonimage->imageOffset, + i_toonimage->width, + i_toonimage->height, + (GXTexFmt)i_toonimage->format, + (GXTexWrapMode)i_toonimage->wrapS, + (GXTexWrapMode)i_toonimage->wrapT, + i_toonimage->mipmapCount > 1 + ); + + GXInitTexObjLOD( + &tex_obj, + (GXTexFilter)i_toonimage->minFilter, + (GXTexFilter)i_toonimage->magFilter, + i_toonimage->minLOD * 0.125f, + i_toonimage->maxLOD * 0.125f, + i_toonimage->LODBias * 0.01f, + i_toonimage->biasClamp, + i_toonimage->doEdgeLOD, + (GXAnisotropy)i_toonimage->maxAnisotropy + ); + + GXLoadTexObj(&mTexObj, GX_TEXMAP0); + GXLoadTexObj(&tex_obj, GX_TEXMAP1); + + GXSetNumChans(1); + GXCallDisplayList(l_matDL, 0x20); + + lightSet1(lightPos); + + switch (mClothType) { + case MENU_CLOTH_TYPE_FILE_SELECT: + case MENU_CLOTH_TYPE_CLOTH_ONLY: { + mDoMtx_stack_c::transS(HIO_CHILD.pos.x + -275.0f, HIO_CHILD.pos.y - 75.0f, HIO_CHILD.pos.z + -3800.0f); + mDoMtx_stack_c::XrotM(mRot.x); + mDoMtx_stack_c::YrotM(mRot.y); + mDoMtx_stack_c::ZrotM(mRot.z); + mDoMtx_stack_c::scaleM(mScale); + mDoMtx_stack_c::transM(0.0f, 0.0f, 3400.0f); + GXLoadPosMtxImm(mDoMtx_stack_c::get(), GX_PNMTX0); + GXLoadNrmMtxImm(mDoMtx_stack_c::get(), GX_PNMTX0); + GXSetCullMode(GX_CULL_FRONT); + GXSetCurrentMtx(GX_PNMTX0); + GXSetArray(GX_VA_POS, getPos(), sizeof(cXyz)); + GXSetArray(GX_VA_NRM, getNrm(), sizeof(cXyz)); + ShadowTevSetting(); + plot(0.0f, 0.0f, 10.0f, 10.0f); + } break; + } + + mDoMtx_stack_c::transS(HIO_CHILD.pos.x + -350.0f, HIO_CHILD.pos.y, HIO_CHILD.pos.z + -3800.0f); + mDoMtx_stack_c::XrotM(mRot.x); + mDoMtx_stack_c::YrotM(mRot.y); + mDoMtx_stack_c::ZrotM(mRot.z); + mDoMtx_stack_c::scaleM(mScale); + mDoMtx_stack_c::transM(0.0f, 0.0f, 3400.0f); + GXLoadPosMtxImm(mDoMtx_stack_c::get(), GX_PNMTX0); + GXLoadNrmMtxImm(mDoMtx_stack_c::get(), GX_PNMTX0); + GXSetCullMode(GX_CULL_FRONT); + GXSetCurrentMtx(GX_PNMTX0); + GXSetArray(GX_VA_POS, getPos(), sizeof(cXyz)); + GXSetArray(GX_VA_NRM, getNrm(), sizeof(cXyz)); + TevSetting(); + plot(0.0f, 0.0f, 10.0f, 10.0f); + + GXSetCullMode(GX_CULL_BACK); + ShadowTevSetting(); + GXSetArray(GX_VA_POS, mShadowPosArr, sizeof(cXyz)); + plot_shadow(0.0f, 0.0f, 1.0f, 1.0f); + + TevSetting(); + GXSetArray(GX_VA_POS, getPos(), sizeof(cXyz)); + GXSetArray(GX_VA_NRM, getBackNrm(), sizeof(cXyz)); + plot(0.0f, 0.0f, 10.0f, 10.0f); + + j3dSys.reinitGX(); +} + +// This is to get the floats in the right order. +void dummy2() { + vf32 a = 0.5f; } /* 8019B670-8019B9C0 .text cloth_move_sin__9dMCloth_cFv */ void dMCloth_c::cloth_move_sin() { - /* Nonmatching */ + mWaveProgress += HIO_CHILD.waveProgressStep; + + cXyz* pPosArr = getPos(); + + for (int y = 0; y < INNER_SIZE; y++) { + for (int x = 0; x < INNER_SIZE; x++) { + f32 fx = (f32)x; + f32 fy = (f32)y; + + if (x > INNER_SIZE / 2) { + fx = (INNER_SIZE - fx) - 1.0f; + } + if (y > INNER_SIZE / 2) { + fy = (INNER_SIZE - fy) - 1.0f; + } + + if (fx + fy > 4.0f) { + fx = 1.0f; + } else { + fx = (fx + fy) * 0.2f; + } + + cXyz pos; + pos.x = -1500.0f + 305.0f * (f32)x; + pos.y = -1500.0f + 300.0f * (f32)y; + pos.z = -3400.0f; + + pos.x += HIO_CHILD.waveAmpX * fx * cM_ssin(mWaveProgress + x * HIO_CHILD.waveFreqX + y * HIO_CHILD.waveFreqY); + pos.y += HIO_CHILD.waveAmpY * fx * cM_scos(mWaveProgress + x * HIO_CHILD.waveFreqX + y * HIO_CHILD.waveFreqY); + pos.z += HIO_CHILD.waveAmpZ * fx * cM_ssin(mWaveProgress + x * HIO_CHILD.waveFreqX); + + cLib_addCalcPos2(&pPosArr[x + y * INNER_SIZE], pos, 0.5f, HIO_CHILD.maxStep); + } + } + + cXyz* pNrm = getNrm(); + + for (int y = 0; y < INNER_SIZE; y++) { + for (int x = 0; x < INNER_SIZE; x++) { + setNrmVtx(pNrm, x, y); + pNrm++; + } + } + + setBackNrm(); + + DCStoreRangeNoSync(getPos(), INNER_SIZE * INNER_SIZE * sizeof(cXyz)); + DCStoreRangeNoSync(getNrm(), INNER_SIZE * INNER_SIZE * sizeof(cXyz)); + DCStoreRangeNoSync(getBackNrm(), INNER_SIZE * INNER_SIZE * sizeof(cXyz)); } /* 8019B9C0-8019BCF4 .text cloth_move_simple__9dMCloth_cFv */ void dMCloth_c::cloth_move_simple() { - /* Nonmatching */ + cXyz* pPosArr = getPos(); + + for (int y = 0; y < INNER_SIZE; y++) { + for (int x = 0; x < INNER_SIZE; x++) { + f32 fx = (f32)x; + f32 fy = (f32)y; + + if (x > INNER_SIZE / 2) { + fx = (INNER_SIZE - fx) - 1.0f; + } + if (y > INNER_SIZE / 2) { + fy = (INNER_SIZE - fy) - 1.0f; + } + + if (fx + fy > 4.0f) { + fx = 1.0f; + } else { + fx = (fx + fy) * 0.2f; + } + + cXyz pos; + pos.x = -1500.0f + 305.0f * (f32)x; + pos.y = -1500.0f + 300.0f * (f32)y; + pos.z = -3400.0f; + + pos.x += HIO_CHILD.waveAmpX * fx * cM_ssin(mWaveProgress + x * HIO_CHILD.waveFreqX + y * HIO_CHILD.waveFreqY); + pos.y += HIO_CHILD.waveAmpY * fx * cM_scos(mWaveProgress + x * HIO_CHILD.waveFreqX + y * HIO_CHILD.waveFreqY); + pos.z += HIO_CHILD.waveAmpZ * fx * cM_ssin(mWaveProgress + y * HIO_CHILD.waveFreqY); + + cLib_addCalcPos2(&pPosArr[x + y * INNER_SIZE], pos, 0.5f, HIO_CHILD.maxStep); + } + } + + cXyz* pNrm = getNrm(); + + for (int y = 0; y < INNER_SIZE; y++) { + for (int x = 0; x < INNER_SIZE; x++) { + setNrmVtx(pNrm, x, y); + pNrm++; + } + } + + setBackNrm(); + + DCStoreRangeNoSync(getPos(), INNER_SIZE * INNER_SIZE * sizeof(cXyz)); + DCStoreRangeNoSync(getNrm(), INNER_SIZE * INNER_SIZE * sizeof(cXyz)); + DCStoreRangeNoSync(getBackNrm(), INNER_SIZE * INNER_SIZE * sizeof(cXyz)); } /* 8019BCF4-8019BDB8 .text cloth_move__9dMCloth_cFv */ void dMCloth_c::cloth_move() { - /* Nonmatching */ + switch (mClothType) { + case MENU_CLOTH_TYPE_DEFAULT: + case MENU_CLOTH_TYPE_CLOTH_ONLY: { + if (mFadeInCounter < HIO_CHILD.fadeInLength) { + cloth_move_sin(); + mFadeInCounter++; + } else { + cloth_move_simple(); + } + } break; + case MENU_CLOTH_TYPE_FILE_SELECT: { + if (mFadeInCounter < HIO_CHILD.fadeInLength) { + mFadeInCounter++; + } + cloth_move_sin(); + } break; + } } /* 8019BDB8-8019BDC0 .text dMenu_ClothCreate__FPv */ -static void dMenu_ClothCreate(void*) { - /* Nonmatching */ +static cPhs_State dMenu_ClothCreate(void*) { + return cPhs_COMPLEATE_e; } /* 8019BDC0-8019BDC8 .text dMenu_ClothDelete__FPv */ -static void dMenu_ClothDelete(void*) { - /* Nonmatching */ +static BOOL dMenu_ClothDelete(void*) { + return TRUE; } /* 8019BDC8-8019BDD0 .text dMenu_ClothExecute__FPv */ -static void dMenu_ClothExecute(void*) { - /* Nonmatching */ +static BOOL dMenu_ClothExecute(void*) { + return FALSE; } /* 8019BDD0-8019BDD8 .text dMenu_ClothDraw__FPv */ -static void dMenu_ClothDraw(void*) { - /* Nonmatching */ +static BOOL dMenu_ClothDraw(void*) { + return TRUE; } /* 8019BDD8-8019BDE0 .text dMenu_ClothIsDelete__FPv */ -static void dMenu_ClothIsDelete(void*) { - /* Nonmatching */ +static BOOL dMenu_ClothIsDelete(void*) { + return TRUE; } + +class menu_cloth_class : public msg_class { + /* 0x00FC */ dMCloth_c mCloth; + /* 0x9264 */ u8 padding[0x929C - 0x9264]; +}; + +STATIC_ASSERT(sizeof(menu_cloth_class) == 0x929C); + +// BUG: The functions in this table are out of order. +// It doesn't really matter, because they're just empty functions. +static msg_method_class dMenu_ClothMethodTable = { + /* Create */ (process_method_func)dMenu_ClothCreate, + /* Delete */ (process_method_func)dMenu_ClothDelete, + /* Execute */ (process_method_func)dMenu_ClothDraw, + /* IsDelete */ (process_method_func)dMenu_ClothExecute, + /* Draw */ (process_method_func)dMenu_ClothIsDelete, +}; + +msg_process_profile_definition g_profile_Menu_Cloth = { + /* LayerID */ (uint)fpcLy_CURRENT_e, + /* ListID */ 0x000C, + /* ListPrio */ fpcPi_CURRENT_e, + /* ProcName */ PROC_Menu_Cloth, + /* Proc SubMtd */ &g_fpcLf_Method.base, + /* Size */ sizeof(menu_cloth_class), + /* SizeOther */ 0, + /* Parameters */ 0, + /* Leaf SubMtd */ &g_fopMsg_Method, + /* Priority */ PRIO_Menu_Cloth, + /* Msg SubMtd */ &dMenu_ClothMethodTable, +}; diff --git a/src/d/d_menu_window.cpp b/src/d/d_menu_window.cpp index 8a6d88db6..6fcee77e8 100644 --- a/src/d/d_menu_window.cpp +++ b/src/d/d_menu_window.cpp @@ -5,7 +5,61 @@ #include "d/dolzel.h" // IWYU pragma: keep #include "d/d_menu_window.h" + +#include "JSystem/JKernel/JKRExpHeap.h" #include "f_op/f_op_msg.h" +#include "d/d_menu_cloth.h" + +// TODO: Remove me when all the JUT asserts and other strings are filled out. +// This is temporary, just to make the strings match. +void dummy0() { + OSReport("cmap_tri.bti"); + OSReport("cmap_treasure.bti"); + OSReport("cmap_tingle.bti"); + OSReport("cmap_phantomship.bti"); + OSReport("cmap_hint.bti"); + OSReport("f_item_tri.bti"); + OSReport("f_get_rupy.bti"); + OSReport("f_heart_up_02.bti"); + OSReport("f_korog_kare.bti"); + OSReport("f_korog_saki.bti"); + OSReport("d_menu_window.cpp"); + OSReport("i_Ms->name[i] != 0"); + OSReport("Halt"); + OSReport(""); + OSReport("i_Ms->note[i] != 0"); + OSReport("i_Ms->dummy[i] != 0"); + OSReport("i_Ms->buffer_p[i] != 0"); + OSReport("dMi_c != 0"); + OSReport("dMc_c != 0"); + OSReport("dMf_c != 0"); + OSReport("dMs_capture_c != 0"); + OSReport("dMd_c != 0"); + OSReport("dNm_c != 0"); + OSReport("dMs_c != 0"); + OSReport("cloth_c != 0"); + OSReport("dMs_cloth_c != 0"); + OSReport("i_Ms->childHeap != 0"); + OSReport("awake"); + OSReport("majyuu_shinnyuu"); + OSReport("アイテムビット"); + OSReport("ダンジョンビット"); + OSReport("fonttype != 0"); + OSReport("rfonttype != 0"); +} + +class dDlst_MENU_CLOTH_c : public dDlst_base_c {}; + +class dDlst_MENU_CAPTURE_c : public dDlst_base_c { +public: + dDlst_MENU_CAPTURE_c() { mStatus = 0; } + + /* 0x04 */ u8 mStatus; +}; + +static dMCloth_c* cloth_c; +static dDlst_MENU_CLOTH_c* dMs_cloth_c; +static dDlst_MENU_CAPTURE_c* dMs_capture_c; /* 801DB384-801DB50C .text __ct__9dMw_HIO_cFv */ dMw_HIO_c::dMw_HIO_c() { @@ -78,23 +132,72 @@ void dMs_save_delete(sub_ms_screen_class*) { } /* 801DCEA0-801DD090 .text dMs_cloth_create__FP19sub_ms_screen_class */ -void dMs_cloth_create(sub_ms_screen_class*) { - /* Nonmatching */ +void dMs_cloth_create(sub_ms_screen_class* i_Ms) { + dComIfGp_setHeapLockFlag(1); + JKRArchive* arc = dComIfGp_getClothResArchive(); + + cloth_c = new dMCloth_c(); + JUT_ASSERT(2674, cloth_c != NULL); + + cloth_c->setArchive(arc); + cloth_c->init(); + + dMs_cloth_c = new dDlst_MENU_CLOTH_c(); + JUT_ASSERT(2680, dMs_cloth_c != NULL); + + dMs_capture_c = new dDlst_MENU_CAPTURE_c(); + JUT_ASSERT(2683, dMs_capture_c != NULL); + + i_Ms->childHeap = JKRExpHeap::create(0x506A1, i_Ms->parentHeap_0xfc, false); + JUT_ASSERT(2686, i_Ms->childHeap != NULL); } /* 801DD090-801DD154 .text dMs_cloth_delete__FP19sub_ms_screen_class */ -void dMs_cloth_delete(sub_ms_screen_class*) { - /* Nonmatching */ +void dMs_cloth_delete(sub_ms_screen_class* i_Ms) { + if (i_Ms->childHeap) { + i_Ms->childHeap->destroy(); + i_Ms->childHeap = NULL; + } + if (dMs_cloth_c) { + delete dMs_cloth_c; + dMs_cloth_c = NULL; + } + if (cloth_c) { + delete cloth_c; + cloth_c = NULL; + } + if (dMs_capture_c) { + delete dMs_capture_c; + dMs_capture_c = NULL; + } } /* 801DD154-801DD270 .text dMs_clothOnly_create__FP19sub_ms_screen_class */ void dMs_clothOnly_create(sub_ms_screen_class*) { - /* Nonmatching */ + JKRArchive* arc = dComIfGp_getClothResArchive(); + + cloth_c = new dMCloth_c(); + JUT_ASSERT(2744, cloth_c != NULL); + + cloth_c->setArchive(arc); + cloth_c->setClothType(MENU_CLOTH_TYPE_CLOTH_ONLY); + cloth_c->init(); + + dMs_cloth_c = new dDlst_MENU_CLOTH_c(); + JUT_ASSERT(2751, dMs_cloth_c != NULL); } /* 801DD270-801DD308 .text dMs_clothOnly_delete__FP19sub_ms_screen_class */ void dMs_clothOnly_delete(sub_ms_screen_class*) { - /* Nonmatching */ + if (dMs_cloth_c) { + delete dMs_cloth_c; + dMs_cloth_c = NULL; + } + if (cloth_c) { + dComIfGp_getClothResArchive()->removeResourceAll(); + delete cloth_c; + cloth_c = NULL; + } } /* 801DD308-801DD318 .text dMs_onButtonBit__FP19sub_ms_screen_classUc */ diff --git a/src/d/d_s_name.cpp b/src/d/d_s_name.cpp index 8ea232a3b..867b50e17 100644 --- a/src/d/d_s_name.cpp +++ b/src/d/d_s_name.cpp @@ -216,7 +216,7 @@ void dScnName_c::cloth2D_create() { cloth.cloth_c = new dMCloth_c(); JUT_ASSERT(801, cloth.cloth_c != NULL); cloth.cloth_c->setArchive(clothRes); - cloth.cloth_c->setClothType(1); // ? + cloth.cloth_c->setClothType(MENU_CLOTH_TYPE_FILE_SELECT); } static void dummy() {