From c15878c0e9dd5692c4a27e2ee10278fed56ef2d6 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Thu, 8 Oct 2026 18:45:17 +0000 Subject: [PATCH] decomp: SDChannelSelect collectTitles functions exact; link iplSDChannelSelect (worker 654f9547) --- config/43U/symbols.txt | 10 ++--- configure.py | 2 +- include/math/iplInterporation.h | 39 ------------------- .../sdChannelSelect/iplSDChannelSelect.h | 12 +++--- include/system/iplChannelManager.h | 3 ++ .../sdChannelSelect/iplSDChannelSelect.cpp | 27 +++++-------- tools/decomp-assist/opus-sdcs.attempts.md | 37 ++++++++++++++++++ 7 files changed, 62 insertions(+), 68 deletions(-) create mode 100644 tools/decomp-assist/opus-sdcs.attempts.md diff --git a/config/43U/symbols.txt b/config/43U/symbols.txt index affe0fd5..0d6a0a5c 100644 --- a/config/43U/symbols.txt +++ b/config/43U/symbols.txt @@ -4617,11 +4617,11 @@ updateDialogAnimation__Q33ipl5scene15SDChannelSelectFv = .text:0x813DCAC4; // ty setDialogMessage__Q33ipl5scene15SDChannelSelectFUlUl = .text:0x813DCEF0; // type:function size:0x24 isCurrentTitleUsageEnough__Q33ipl5scene15SDChannelSelectCFPCl = .text:0x813DCF14; // type:function size:0xCC getCurrentTitleUsage__Q33ipl5scene15SDChannelSelectCFPlPl = .text:0x813DCFE0; // type:function size:0xCC -collectTitlesByUsage__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD0AC; // type:function size:0x194 -collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD240; // type:function size:0x198 -collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD3D8; // type:function size:0x1F8 -collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD5D0; // type:function size:0x5A4 -collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUli = .text:0x813DDB74; // type:function size:0x40 +collectTitlesByUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD0AC; // type:function size:0x194 +collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD240; // type:function size:0x198 +collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD3D8; // type:function size:0x1F8 +collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD5D0; // type:function size:0x5A4 +collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUli = .text:0x813DDB74; // type:function size:0x40 findAdjacentChannel__Q33ipl5scene15SDChannelSelectCFiPiPi = .text:0x813DDBB4; // type:function size:0xB4 setCurrentPageAndRefresh__Q33ipl5scene15SDChannelSelectFiiPQ33ipl5scene12SDChannelObj = .text:0x813DDC68; // type:function size:0x18 handleFourPageDialog__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDC80; // type:function size:0x58 diff --git a/configure.py b/configure.py index 0f8b0d6a..a1de7533 100644 --- a/configure.py +++ b/configure.py @@ -849,7 +849,7 @@ config.libs = [ ] ), IPLSection("sdChannelSelect", [ - Object(NonMatching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"), + Object(Matching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"), Object(Matching, "scene/sdChannelSelect/iplSDChannelObj.cpp"), ] ), diff --git a/include/math/iplInterporation.h b/include/math/iplInterporation.h index bc2aa686..150ae8af 100644 --- a/include/math/iplInterporation.h +++ b/include/math/iplInterporation.h @@ -296,45 +296,6 @@ namespace ipl { }; #endif -#ifdef IPL_SD_CHANNEL_SELECT_CPP -} // namespace math -} // namespace ipl -#include "math/iplMathTypes.h" -namespace ipl { - namespace math { - template <> - class HermiteIntp : public utility::FrameController { - public: - HermiteIntp() {} - virtual ~HermiteIntp(); - void init(const VEC3& start, const VEC3& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f); - VEC3 get() const { - f32 frame = mFrame; - f32 inverseDuration = 1.0f / mMaxFrame; - VEC3 result = - (mStart * (1.0f + (inverseDuration * (inverseDuration * - (inverseDuration * (frame * (2.0f * frame * frame)))) - - inverseDuration * (inverseDuration * (3.0f * frame * frame))))) - - (mEnd * (inverseDuration * (inverseDuration * - (inverseDuration * (frame * (2.0f * frame * frame)))) - - inverseDuration * (inverseDuration * (3.0f * frame * frame)))); - f32 frameSquared = frame * frame; - f32 cubic = inverseDuration * (inverseDuration * (frame * frameSquared)); - f32 tangent = mStartTangent * (frame + (cubic - - inverseDuration * (2.0f * frame * frame))) + - mEndTangent * (cubic - inverseDuration * frameSquared); - result.x += tangent; - result.y += tangent; - result.z += tangent; - return result; - } - protected: - VEC3 mStart; - VEC3 mEnd; - f32 mStartTangent; - f32 mEndTangent; - }; -#endif } // namespace math } // namespace ipl diff --git a/include/scene/sdChannelSelect/iplSDChannelSelect.h b/include/scene/sdChannelSelect/iplSDChannelSelect.h index 578caf82..52b2b00c 100644 --- a/include/scene/sdChannelSelect/iplSDChannelSelect.h +++ b/include/scene/sdChannelSelect/iplSDChannelSelect.h @@ -177,7 +177,7 @@ namespace ipl { const controller::Interface* controller); BOOL onEventDerived(const char* paneName, u32 event, controller::Interface* controller); - bool collectTitlesByUsage(const s32* firstUsage, const s32* secondUsage, + bool collectTitlesByUsage(s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount); @@ -221,7 +221,7 @@ namespace ipl { int getCenterChannelIndex(const char* paneName) const; nw4r::lyt::Pane* getCenterChannelPane(int index) const; nw4r::lyt::Pane* getChannelPane(int index) const; - static math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index); + static nw4r::math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index); void calcPageAnimations(); void processNormalInput(); void updateArrowVisibility(); @@ -232,16 +232,16 @@ namespace ipl { void setChannelScissor(const SDChannelObj* channel) const; bool isCurrentTitleUsageEnough(const s32* usage) const; void getCurrentTitleUsage(s32* bytes, s32* blocks) const; - bool collectTitlesByChannelOrder(const s32* firstUsage, const s32* secondUsage, + bool collectTitlesByChannelOrder(s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount); - bool collectTitlesFromNandUsage(const s32* firstUsage, const s32* secondUsage, + bool collectTitlesFromNandUsage(s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount); - bool collectTitlesBySpecialChannels(const s32* firstUsage, const s32* secondUsage, + bool collectTitlesBySpecialChannels(s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount); - bool collectTitlesForMode(const s32* firstUsage, const s32* secondUsage, + bool collectTitlesForMode(s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount, int searchMode); bool findAdjacentChannel(int direction, int* page, int* index) const; diff --git a/include/system/iplChannelManager.h b/include/system/iplChannelManager.h index fcae3c14..1d5fb7b8 100644 --- a/include/system/iplChannelManager.h +++ b/include/system/iplChannelManager.h @@ -277,6 +277,9 @@ namespace ipl { /* SEntry */ bool hasLoadedBnr(int page, int index) const { return mChannels[page][index].loadedBnr; } int getSceneID(int page, int index) const { return mChannels[page][index].loadedBnr ? mChannels[page][index].info.sceneID : 0; } + ESTitleId getEntryTitleID(int page, int index) const { + return mChannels[page][index].loadedBnr ? ES_TITLE_ID(mChannels[page][index].info.titleType, mChannels[page][index].info.titleCode) : 0; + } /* SMetaBlockHeader */ u32 getIconRSOIdx(int page, int index) const { diff --git a/src/scene/sdChannelSelect/iplSDChannelSelect.cpp b/src/scene/sdChannelSelect/iplSDChannelSelect.cpp index 27cbf1dc..0675d6c6 100644 --- a/src/scene/sdChannelSelect/iplSDChannelSelect.cpp +++ b/src/scene/sdChannelSelect/iplSDChannelSelect.cpp @@ -1325,7 +1325,7 @@ namespace ipl { } bool SDChannelSelect::collectTitlesByUsage( - const s32* firstUsage, const s32* secondUsage, ESTitleId* titleIds, + s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount) { s32 bytes; s32 blocks; @@ -1360,7 +1360,7 @@ namespace ipl { } bool SDChannelSelect::collectTitlesFromNandUsage( - const s32* firstUsage, const s32* secondUsage, + s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount) { s32 bytes; s32 blocks; @@ -1399,7 +1399,7 @@ namespace ipl { } bool SDChannelSelect::collectTitlesByChannelOrder( - const s32* firstUsage, const s32* secondUsage, ESTitleId* titleIds, + s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount) { static const int channelOrder[MAX_CHANNEL_INDEX] = { 11, 7, 3, 10, 6, 2, 9, 5, 1, 8, 4, 0, @@ -1409,17 +1409,10 @@ namespace ipl { getCurrentTitleUsage(&bytes, &blocks); *titleCount = 0; - ESTitleId titleId; for (int page = MAX_CHANNEL_PAGE - 1; page >= 0; --page) { for (int order = 0; order < MAX_CHANNEL_INDEX; ++order) { - int channelIndex = channelOrder[order]; - const channel::SEntry& channelInfo = - System::getChannelManager()->mChannels[page][channelIndex]; - if (channelInfo.loadedBnr) { - titleId = ES_TITLE_ID(channelInfo.info.titleType, channelInfo.info.titleCode); - } else { - titleId = 0; - } + ESTitleId titleId = + System::getChannelManager()->getEntryTitleID(page, channelOrder[order]); if (titleId == 0 || titleId == 0x48415A41) { continue; } @@ -1451,7 +1444,7 @@ namespace ipl { } bool SDChannelSelect::collectTitlesBySpecialChannels( - const s32* firstUsage, const s32* secondUsage, ESTitleId* titleIds, + s32* firstUsage, s32* secondUsage, ESTitleId* titleIds, char* titleNames, u32* titleCount) { s32 bytes; s32 blocks; @@ -1581,7 +1574,7 @@ namespace ipl { } bool SDChannelSelect::collectTitlesForMode( - const s32* requiredBytes, const s32* requiredBlocks, + s32* requiredBytes, s32* requiredBlocks, ESTitleId* titleIds, char* titleNames, u32* titleCount, int searchMode) { switch (searchMode) { case 0: @@ -1908,7 +1901,7 @@ namespace ipl { pageText->SetString(pageNumber, 0); nw4r::lyt::Pane* clockPane = mpLayout->FindPaneByName(mscClockPaneNames[page]); nw4r::math::MTX34 paneMatrix = clockPane->GetGlobalMtx(); - nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f); + math::VEC3 position(0.0f, 0.0f, 0.0f); PSMTXMultVec(paneMatrix, position, position); mpDialogLayout->GetRootPane()->SetTranslate(position); mpDialogLayout->calcMtx(); @@ -2705,8 +2698,8 @@ namespace ipl { return mpLayout->FindPaneByName(mscChannelPaneNames[2][index]); } - math::VEC3 SDChannelSelect::getChannelPanePosition(SDChannelSelect* scene, int index) { - math::VEC3 position(0.0f, 0.0f, 0.0f); + nw4r::math::VEC3 SDChannelSelect::getChannelPanePosition(SDChannelSelect* scene, int index) { + nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f); MTXMultVec(scene->getCenterChannelPane(index)->GetGlobalMtx(), position, position); return position; } diff --git a/tools/decomp-assist/opus-sdcs.attempts.md b/tools/decomp-assist/opus-sdcs.attempts.md new file mode 100644 index 00000000..6ef4a681 --- /dev/null +++ b/tools/decomp-assist/opus-sdcs.attempts.md @@ -0,0 +1,37 @@ +# opus-sdcs: iplSDChannelSelect collectTitles* (2026-10-08) + +Start: ByUsage 4/101, FromNandUsage 4/102, ByChannelOrder 7/126, BySpecialChannels 16/361. + +Shared diff: `lwz secondUsage[0]` scheduled above `stw ++*titleCount` in ours, after it in target. +- `*titleCount += 1`, `(*titleCount)++`, `titleCount[0]++`, `= *titleCount + 1`: no change (4). +- `!(a < b || c < d)`, nested ifs: no change. static inline usage predicate: 40 diffs. +- function-scoped IRO 0 / IRO 1: no change. +- casts `(s32*)secondUsage`, `const_cast`, `(s32*)(u32)`, local non-const copy (also under IRO 0): no change. +- mwdbg on a standalone repro: the load is hoisted before regalloc; loads through a pointer-to-const + PARAMETER are treated as unaffected by any store (casts do not remove it). Only a non-const + `s32*` parameter keeps source order: repro then matched the target byte for byte. +- The `PClPClPUxPcPUl` mangling was decomp-assigned (symbols.txt names were invented), so the + params become `s32*` and the 5 symbols are renamed to `FPlPlPUxPcPUl`. + => ByUsage 0, FromNandUsage 0, BySpecialChannels 0, ByChannelOrder 3. + +ByChannelOrder residual: `mulli r0/add r3,r17,r3` vs target `mulli r4/add r0,r17,r3`. +- if/else vs ternary, `getChannel`, `hasLoadedBnr`, row pointer, ref/ptr locals, idx/manager locals + in either order, inverted branch: 3-8 diffs. +- regsim: declaration order cannot reach (0/2), IRO temps @162/@164 for mgr/sum get low vreg numbers. +- inline Manager member with getTitleID's body (`getEntryTitleID(page, channelOrder[order])`): exact. + +Result: 129/129 exact, gate PASS. + +## Link (configure.py -> Matching) +First link: DOL SHA1 798af348..., .data 0x20 short and two swapped calls. +- objdiff missed that `draw` calls `ipl::math::VEC3(f,f,f)` and `getChannelPanePosition` calls + `nw4r::math::VEC3(f,f,f)`, because the two weak bodies are identical. Fixed the local in draw + and made getChannelPanePosition return `nw4r::math::VEC3` (NRVO builds it in the return slot, + and callers only read .x/.y). +- Target .data has 0x20 zero bytes (deduped weak vtables) before the anonymous handler vtables. + iplChannelSelect emits `HermiteIntp` and `Interporation` weak vtables at the same + spot. Dropped the SD-only full `HermiteIntp` specialization in iplInterporation.h so the + generic template (with the SD `get()` already there) is used: .data 0xab0, as in the target. +- Removing the unreferenced handleDeleteComplete/handleStorageCheckComplete: no DOL change (they + get dead-stripped), so I reverted it. +Result: DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d, gate PASS, linked code 33828. -- 2.49.1