From 219b9a2d97396035fa66a41da53f527c0065688f Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 2 Oct 2026 19:39:09 +0000 Subject: [PATCH] link(iplChannelSelect: native weak vtable / Hermite emission) (link1) (worker bf02f407) --- README.md | 4 +- configure.py | 2 +- include/math/iplInterporation.h | 26 +++++++++++ include/utility/iplFrameController.h | 4 ++ src/scene/channelSelect/iplChannelSelect.cpp | 5 +- tools/decomp-assist/link1.attempts.md | 48 ++++++++++++++++++++ 6 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 tools/decomp-assist/link1.attempts.md diff --git a/README.md b/README.md index 347138f8..821b9404 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ Progress | Decompiled | Matched | Linked | Data | |:---:|:---:|:---:|:---:| -| 99.59% | 90.81% | 71.43% | 99.37% | +| 99.59% | 90.92% | 73.37% | 99.37% | -units 956/1027 complete, functions 12365/12563 matched. +units 960/1027 complete, functions 12368/12563 matched. decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data diff --git a/configure.py b/configure.py index b73149df..4f895f76 100644 --- a/configure.py +++ b/configure.py @@ -766,7 +766,7 @@ config.libs = [ ] ), IPLSection("channelSelect", [ - Object(Equivalent, "scene/channelSelect/iplChannelSelect.cpp"), + Object(Matching, "scene/channelSelect/iplChannelSelect.cpp"), Object(Matching, "scene/channelSelect/iplClock.cpp"), Object(Equivalent, "scene/channelSelect/iplChannelObj.cpp"), ] diff --git a/include/math/iplInterporation.h b/include/math/iplInterporation.h index 3f0be62a..f19128bd 100644 --- a/include/math/iplInterporation.h +++ b/include/math/iplInterporation.h @@ -266,6 +266,32 @@ namespace ipl { }; #endif +#ifdef IPL_CHANNEL_SELECT_CPP + template <> + class HermiteIntp : public utility::FrameController { + public: + HermiteIntp() {} + virtual ~HermiteIntp() {} + + void init(const f32& start, const f32& end, f32 maxFrame, f32 startTangent, + f32 endTangent, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f) { + mStart = start; + mEnd = end; + utility::FrameController::init(playback, maxFrame, 0.0f, speed); + mStartTangent = startTangent; + mEndTangent = endTangent; + } + + inline f32 get() const; + + protected: + f32 mStart; + f32 mEnd; + f32 mStartTangent; + f32 mEndTangent; + }; +#endif + #ifdef IPL_SD_CHANNEL_SELECT_CPP } // namespace math } // namespace ipl diff --git a/include/utility/iplFrameController.h b/include/utility/iplFrameController.h index 75c6340e..d1e39708 100644 --- a/include/utility/iplFrameController.h +++ b/include/utility/iplFrameController.h @@ -27,7 +27,11 @@ namespace ipl { void init(int type, f32 maxFrame, f32 minFrame, f32 speed = 1.0f); void initFrame(); +#ifdef IPL_CHANNEL_SELECT_CPP + virtual inline void calc(); +#else virtual void calc(); // 0x0C +#endif void setMaxFrame(f32 value) { mMaxFrame = value; } f32 getMaxFrame() const { return mMaxFrame; } diff --git a/src/scene/channelSelect/iplChannelSelect.cpp b/src/scene/channelSelect/iplChannelSelect.cpp index c37cd44b..7fea514a 100644 --- a/src/scene/channelSelect/iplChannelSelect.cpp +++ b/src/scene/channelSelect/iplChannelSelect.cpp @@ -1,3 +1,5 @@ +#define IPL_CHANNEL_SELECT_CPP + #include #include "iplSceneUI.h" @@ -43,8 +45,7 @@ namespace ipl { return r; } - template <> - f32 HermiteIntp::get() const { + inline f32 HermiteIntp::get() const { f32 var_f27 = mFrame; f32 var_f28 = 1.0f / mMaxFrame; f32 r = (mStart * (1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) - diff --git a/tools/decomp-assist/link1.attempts.md b/tools/decomp-assist/link1.attempts.md new file mode 100644 index 00000000..6a7e27cb --- /dev/null +++ b/tools/decomp-assist/link1.attempts.md @@ -0,0 +1,48 @@ +# ChannelSelect native linking + +Baseline: HEAD f7b1b9b0, Equivalent, DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. Unit code 25668/25668, data 2336/2336, functions 102/102. Existing untracked fresh1.attempts.md left alone. + +1. Set only ChannelSelect to Matching to locate the first linked-byte divergence. + Matching SHA1 f045a95026c3ca34039d0d9064fad33832ce581a. First DOL mismatch at file 0x5ba, address 0x8133009a in __start; relocation points to data shifted by 0x40. nm and ELF comparison show the first text layout change at createChannelThumbnails, as recorded in the exact symbol table below. Extra weak Interporation destructor is 0x40 bytes, plus its vtable; neither exists in the target symbols. .text grows 0x40. Pool identical, 98 strings. + /tmp/link1.baseline.elf: createChannelThumbnails__Q33ipl5scene13ChannelSelectFv 0x813abcc4 size 0x5c. + /tmp/link1.matching.main.elf: createChannelThumbnails__Q33ipl5scene13ChannelSelectFv 0x813abd04 size 0x5c. + /tmp/link1.matching.main.elf: __dt__Q33ipl4math16InterporationFv 0x813abcc4 size 0x40. + +2. Model the scalar Hermite specialization as a direct FrameController subclass, with its destructor declared out of line, matching the existing scalar specialization used by ChannelTitle and the target ownership at 0x81363c10. Scope the new specialization to IPL_CHANNEL_SELECT_CPP. Preserve inline init and get calculations. This avoids instantiating a nonexistent Interporation destructor or vtable. + Result: all 102 functions and data still 100%; other unit reports unchanged. DOL SHA1 acdfd504572753800958ecd275825fdc19bb92c1. Text now correct but .data is 32 bytes short: scalar table and base table reservations were removed. Real data/vtable pointers up through ChannelSelect table still identical. + +3. Keep the original Hermite primary template and specialize only scalar Interporation as a novtable base, retaining its real start/end fields and methods. The target inlined constructor stores only the derived vtable; the extra base destructor had no target owner. Test whether suppressing base vtable use lets the linker discard this extra destructor while retaining ordinary compiler-emitted data reservations. + Result: SHA1 f7cdb8937b2638367aa0479f20a880cd063d06bb. Removing the scalar base vtable use strips the 64-byte extra destructor, but removes a 16-byte data reservation; createDiskLayout remains instruction exact. + +4. Restore a direct scalar Hermite specialization, now with an inline empty destructor as in the target scalar destructor. Declare FrameController::calc inline only in this TU to test normal weak base-vtable emission. This preserves the ordinary scalar and FrameController vtables without defining or retaining any fake object. Target scalar construction only sets the derived table, destructor is empty; the target data has 32 bytes of discarded weak tables after the ChannelSelect vtable and before the GUI table reservations. + Result: DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d with ChannelSelect Matching. Scalar and FrameController weak tables are compiler-emitted and deduplicated against their existing earlier owners; no Interporation symbol remains. All 102 objdiff functions exact, code 25668/25668, data 2336/2336. Every other unit report is byte-for-byte equal as JSON to the initial live baseline. pool_diff identical, 98 strings; createDiskLayout 168/168 instructions, diffs 0; VEC3 Hermite destructor 16/16 instructions, diffs 0. + +Validation: running the full clean gate, full build/43U/ok, and independent checks of all 102 function instruction streams. Inline FrameController declaration keeps the implementation in its existing owning TU and requests normal weak-vtable emission here. No forced sections, data padding, new assembly, label aliases, or force-active changes. + +Final clean gate output: + +```text +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[src/scene/channelSelect/iplChannelSelect] pool: IDENTICAL +[src/scene/channelSelect/iplChannelSelect] objdiff: code 25668/25668 data 2336/2336 functions 102/102 fuzzy 100.0000 linked code 25668 +[src/scene/channelSelect/iplChannelSelect] instruction-exact functions: 102/102 +[src/scene/channelSelect/iplChannelSelect] section .data size 2144 match 100.0 +[src/scene/channelSelect/iplChannelSelect] section .rodata size 16 match 100.0 +[src/scene/channelSelect/iplChannelSelect] section .sbss size 8 match 100.0 +[src/scene/channelSelect/iplChannelSelect] section .sdata size 80 match 100.0 +[src/scene/channelSelect/iplChannelSelect] section .sdata2 size 88 match 100.0 +[src/scene/channelSelect/iplChannelSelect] section .text size 25668 match 100.0 +[src/scene/channelSelect/iplChannelSelect] baseline: code 25668/25668 data 2336 functions 102 fuzzy 100.0000 +regressions vs baseline: 0 +global matched_code_percent: 90.80962 -> 90.80962 +global fuzzy_match_percent: 99.58569 -> 99.58569 +global complete_code_percent: 72.50912 -> 73.36610 +global matched_data_percent: 99.36639 -> 99.36639 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +note: config touched: configure.py (orchestrator reviews every config/symbols change) +GATE PASS +``` + +Explicit ninja build/43U/ok passes. Regenerated live report: all other unit records unchanged from the initial snapshot. All 102 ctxdiff.py runs report identical instruction counts and diffs 0; no open function remains. DOL bytes identical to orig/43U/00000008.app, SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. Functions 102/102 -> 102/102, code 25668/25668 -> 25668/25668, data 2336/2336 -> 2336/2336, linked code 0 -> 25668. -- 2.49.1