From 3aa9daf94af1cc73396ededb99c9536eef8467b4 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 17:22:10 -0500 Subject: [PATCH 1/4] decomp: emission gates for iplSDChannelTitle + MemoryCardManager decodes (#972) IPL_SD_CHANNEL_TITLE_CPP gates move inline members to declarations so the TU emits non-inlined calls like retail (same dedup-loss pattern as #834's vtable restoration): iplInterporation::get, math::VEC3 ctor, FaderSceneBase::initCalcNormal/calcCommonAfter, SceneBase::isReady/ isResetProcessDone/getParent/getChild/getNext/getPrev, NANDTask:: isFinished/checkData, Graphics::setOrthoTrans/setOrthoScale, ut::Rect/RuntimeTypeInfo. Verified vs main: iplSDChannelTitle 68/69 fns byte-exact (152B tail residual in iplSDChannelTitle_flushSaveBeforeExit), iplMemoryCardManager 18/26. Units stay NonMatching; documented walls in revisit.attempts.md. Co-authored-by: devin Co-authored-by: coah80 --- include/math/iplInterporation.h | 4 + include/math/iplMathTypes.h | 2 +- include/scene/iplFaderSceneBase.h | 8 ++ include/scene/iplSceneBase.h | 15 ++ include/system/iplNand.h | 5 + include/utility/iplGraphics.h | 5 + libs/NW4R/include/nw4r/ut/Rect.h | 4 +- libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h | 2 +- src/scene/memoryCard/iplMemoryCardManager.cpp | 5 +- .../sdChannelTitle/iplSDChannelTitle.cpp | 14 +- tools/decomp-assist/revisit.attempts.md | 130 ++++++++++++++++++ 11 files changed, 176 insertions(+), 18 deletions(-) create mode 100644 tools/decomp-assist/revisit.attempts.md diff --git a/include/math/iplInterporation.h b/include/math/iplInterporation.h index f19128bd..558a0a3f 100644 --- a/include/math/iplInterporation.h +++ b/include/math/iplInterporation.h @@ -163,6 +163,9 @@ namespace ipl { void init(const f32& start, const f32& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f); +#ifdef IPL_SD_CHANNEL_TITLE_CPP + f32 get() const; +#else f32 get() const { f32 var_f27 = mFrame; f32 var_f28 = 1.0f / mMaxFrame; @@ -181,6 +184,7 @@ namespace ipl { return r; } +#endif protected: f32 mStart; diff --git a/include/math/iplMathTypes.h b/include/math/iplMathTypes.h index fe2ea912..a9dadb38 100644 --- a/include/math/iplMathTypes.h +++ b/include/math/iplMathTypes.h @@ -103,7 +103,7 @@ namespace ipl { y = r.y; z = 0.0f; } -#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP) +#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP) || defined(IPL_SD_CHANNEL_TITLE_CPP) VEC3(f32 fx, f32 fy, f32 fz); #else VEC3(f32 fx, f32 fy, f32 fz) { diff --git a/include/scene/iplFaderSceneBase.h b/include/scene/iplFaderSceneBase.h index d841c0a7..65fc9338 100644 --- a/include/scene/iplFaderSceneBase.h +++ b/include/scene/iplFaderSceneBase.h @@ -31,8 +31,12 @@ namespace ipl { virtual void calc(); +#ifdef IPL_SD_CHANNEL_TITLE_CPP + virtual void initCalcNormal(); +#else virtual void initCalcNormal() { } // 0x4C +#endif virtual void initCalcFadeout() { } // 0x50 @@ -49,8 +53,12 @@ namespace ipl { return FADER_SCN_NEXT; } // 0x60 +#ifdef IPL_SD_CHANNEL_TITLE_CPP + virtual void calcCommonAfter(); +#else virtual void calcCommonAfter() { } // 0x64 +#endif int getSceneFadeState() { return mScnFadeState; diff --git a/include/scene/iplSceneBase.h b/include/scene/iplSceneBase.h index 05ca1e5e..37cd9919 100644 --- a/include/scene/iplSceneBase.h +++ b/include/scene/iplSceneBase.h @@ -62,7 +62,11 @@ namespace ipl { virtual ~Base(); /** @brief If the scene is ready */ +#ifdef IPL_SD_CHANNEL_TITLE_CPP + virtual BOOL isReady() const; +#else virtual BOOL isReady() const { return FALSE; } +#endif /** @brief If the user can power off/reset the system */ #ifdef IPL_SD_CHANNEL_TITLE_CPP @@ -73,7 +77,11 @@ namespace ipl { /** @brief The scene running code when powering off/resetting the system */ virtual void startResetting() {} /** @brief If the scene has finished its powering off/resetting task */ +#ifdef IPL_SD_CHANNEL_TITLE_CPP + virtual BOOL isResetProcessDone(); +#else virtual BOOL isResetProcessDone() { return TRUE; } +#endif /** @brief Prepare to create scene */ virtual void prepare() {} @@ -86,10 +94,17 @@ namespace ipl { /** @brief Destroy the scene and clear from memory */ virtual void destroy() {} +#ifdef IPL_SD_CHANNEL_TITLE_CPP + virtual Base* getParent(); + virtual Base* getChild(); + virtual Base* getNext(); + virtual Base* getPrev(); +#else virtual Base* getParent() { return (Base*)mpParent; } virtual Base* getChild() { return (Base*)mpChild; } virtual Base* getNext() { return (Base*)mpNext; } virtual Base* getPrev() { return (Base*)mpPrev; } +#endif /** @brief Check if scene has been created.*/ bool isSceneCreated() const { return (mScnState & SCN_STATE_CREATED); } diff --git a/include/system/iplNand.h b/include/system/iplNand.h index ea0dc137..d18ce526 100644 --- a/include/system/iplNand.h +++ b/include/system/iplNand.h @@ -65,8 +65,13 @@ namespace ipl { /** @brief Writes the file contents. */ virtual void write(); // 0x10 +#ifdef IPL_SD_CHANNEL_TITLE_CPP + virtual bool isFinished(); + virtual int checkData(); +#else virtual bool isFinished() { return mbDoneTask; } // 0x14 virtual int checkData() { return mResult; } // 0x18 +#endif virtual bool isFatalError(); // 0x1C u8* getBuffer() const { return mpBuffer; } diff --git a/include/utility/iplGraphics.h b/include/utility/iplGraphics.h index d2d26131..9cadb0d8 100644 --- a/include/utility/iplGraphics.h +++ b/include/utility/iplGraphics.h @@ -51,12 +51,17 @@ namespace ipl { mArg.mOrthoScale = scale; } +#ifdef IPL_SD_CHANNEL_TITLE_CPP + static void setOrthoTrans(const math::VEC3& translate); + static void setOrthoScale(const math::VEC2& scale); +#else static void setOrthoTrans(const math::VEC3& translate) { mArg.mOrthoTrans = translate; } static void setOrthoScale(const math::VEC2& scale) NO_INLINE { mArg.mOrthoScale.x = scale.x; mArg.mOrthoScale.y = scale.y; } +#endif private: static Arg mArg; diff --git a/libs/NW4R/include/nw4r/ut/Rect.h b/libs/NW4R/include/nw4r/ut/Rect.h index cf3c7b66..5332a4e1 100644 --- a/libs/NW4R/include/nw4r/ut/Rect.h +++ b/libs/NW4R/include/nw4r/ut/Rect.h @@ -9,7 +9,7 @@ namespace nw4r { namespace ut { class Rect { public: -#ifdef IPL_SOUND_RECT_OUT_OF_LINE +#if defined(IPL_SOUND_RECT_OUT_OF_LINE) || defined(IPL_SD_CHANNEL_TITLE_CPP) Rect(); #else Rect() : left(), top(), right(), bottom() {} @@ -20,7 +20,7 @@ namespace nw4r { Rect(f32 l, f32 t, f32 r, f32 b) : left(l), top(t), right(r), bottom(b) {} #endif -#if !defined(IPL_CONTROLLER_TRIVIAL_RECT_DTOR) && !defined(IPL_MEMORYCARD_BASE_CPP) +#if !defined(IPL_CONTROLLER_TRIVIAL_RECT_DTOR) && !defined(IPL_MEMORYCARD_BASE_CPP) && !defined(IPL_SD_CHANNEL_TITLE_CPP) ~Rect() {} #endif diff --git a/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h b/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h index 74b85650..25e83a47 100644 --- a/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h +++ b/libs/NW4R/include/nw4r/ut/RuntimeTypeInfo.h @@ -37,7 +37,7 @@ namespace nw4r { } // namespace detail template -#if defined(IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST) || defined(IPL_MEMORYCARD_BASE_CPP) +#if defined(IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST) || defined(IPL_MEMORYCARD_BASE_CPP) || defined(IPL_SD_CHANNEL_TITLE_CPP) TDerived DynamicCast(TBase* pPtr); #else inline TDerived DynamicCast(TBase* pPtr) { diff --git a/src/scene/memoryCard/iplMemoryCardManager.cpp b/src/scene/memoryCard/iplMemoryCardManager.cpp index 5b74505d..f07c4fa7 100644 --- a/src/scene/memoryCard/iplMemoryCardManager.cpp +++ b/src/scene/memoryCard/iplMemoryCardManager.cpp @@ -237,10 +237,7 @@ bool MemoryCardManager::isIconValidate(u8 slot, s16 index) { bool MemoryCardManager::isBannerEnable(u8 slot, s16 index) { CardIcons* icons = reinterpret_cast(memorycard::getIconStateArray()); - u32 file = mFile[slot][index].fileNo; - memorycard::IconState* icon = &icons[slot][file]; - u8 enabled = icon->bannerEnable; - return enabled != 0; + return icons[slot][mFile[slot][index].fileNo].bannerEnable != 0; } void MemoryCardManager::update_icon_anm() { diff --git a/src/scene/sdChannelTitle/iplSDChannelTitle.cpp b/src/scene/sdChannelTitle/iplSDChannelTitle.cpp index 1a7dc893..12e54e22 100644 --- a/src/scene/sdChannelTitle/iplSDChannelTitle.cpp +++ b/src/scene/sdChannelTitle/iplSDChannelTitle.cpp @@ -3,6 +3,10 @@ #define IPL_SDMEMORY_DIALOG_STATE_ACCESSOR #define IPL_SDMEMORY_COMPLETION_PCT_ACCESSOR +#define IPL_CHANNEL_TITLE_NOVTABLE +#include "math/iplInterporation.h" +#undef IPL_CHANNEL_TITLE_NOVTABLE + #include "scene/sdChannelTitle/iplSDChannelTitle.h" #include "scene/sdChannelSelect/iplSDChannelSelect.h" #include "system/iplSystem.h" @@ -1554,15 +1558,5 @@ void SDChannelTitle::startResetting() { snd::getSystem()->resetAllSound(); } -extern "C" void iplSDChannelTitle_onTitleButtonEvent(SDTitleButtonEventHandler* handler, u32 component, - u32 event, const controller::Interface* controller) { - handler->onEventDerived(component, event, controller); -} - -extern "C" void iplSDChannelTitle_onTitlePaneEvent(SDTitlePaneEventHandler* handler, u32 component, - u32 event, const controller::Interface* controller) { - handler->onEvent(component, event, const_cast(controller)); -} - } } diff --git a/tools/decomp-assist/revisit.attempts.md b/tools/decomp-assist/revisit.attempts.md new file mode 100644 index 00000000..e30e4701 --- /dev/null +++ b/tools/decomp-assist/revisit.attempts.md @@ -0,0 +1,130 @@ +# revisit leaf — second-pass evidence (agent/w1007/revisit @ origin/main 29fe1efa) + +Scope: iplSDChannelTitle (99.98883), ut_ArchiveFontBase (98.52), lyt_window (99.76), +iplMemoryCardManager (97.88). Post-#834 (linkgap emit gates + .data object names). + +## iplSDChannelTitle — all gates landed + +Per-TU `IPL_SD_CHANNEL_TITLE_CPP` declared-only gates applied to: +RuntimeTypeInfo.h DynamicCast, iplMathTypes.h VEC3 3-arg ctor, GUIManager.h +(EventHandler setManager/setLatestEventCtrlNo/getLatestEventCtrlNo, +Component setTriggerTarget, PaneComponent setPane/getPane), iplGraphics.h +setOrthoTrans/setOrthoScale, iplSceneBase.h isReady/isResetProcessDone/getParent/ +getChild/getNext/getPrev, iplFaderSceneBase.h initCalcNormal/calcCommonAfter, +iplNand.h File::isFinished/checkData, iplInterporation.h HermiteIntp::get +(nested under IPL_CHANNEL_TITLE_NOVTABLE spec), Rect.h 0-arg ctor +(IPL_SOUND_RECT_OUT_OF_LINE gate), iplGuiManager.h ~PaneManager. +Deleted 2 unreferenced extern "C" trampolines (onTitleButtonEvent/onTitlePaneEvent) +orig lacks. Result: all data sections 100%; .text 99.98883. + +### VERIFIED WALL — dtor emission policy (decl-immune) +Residual .text gap = 2 unreferenced weak deleting-dtor bodies +(~FaderSceneBase 88B + ~FrameController 64B) + ~5 dangling no-reloc UNDs +(__vt__LangFile, __vt__SDButtonEventHandlerBase, __vt__FrameController, +mArg/typeInfo syms — symtab noise, no relocs). Orig's TU had these dtors +trivial/implicit: ~SDChannelTitle calls ~Base directly (28 insns), Rect +temporaries carry no dtor calls, so correct forms are `virtual ~X() {}` +inline or NO decl at all. Declaring them out-of-line adds real `bl` calls → +fuzzy dropped 99.98883→99.55799. Implicit/non-virtual variants still emit the +weak bodies AND slightly regress — front-end-level MWCC instantiation drag, +no decl form eliminates it. Remaining fn wall: flushSaveBeforeExit 98.59 — +&smArg materialization register choice (orig r3→scratch r4, mine r4/r5→recv-first); +8+ source forms all shift the home, never to r3. + +## ut_ArchiveFontBase — ConstructOpAnalyzeGLGR 92.09 (956B) + +20 normalized diffs, insns 116-147 of 239 — issue-order inside the +ready-set around the CalcOffsetSheetFlags/CalcSizeFlagSet scratch math. +Orig hoists lhz 0x1c (sheetGlyphCount) / lhz 0x24 (sheetCount) / lhz 0xe +(dataBlockCount) + lwz 0x4c(r20) into the marshal block. +FAILED variants: decl-order swap of the three u16s (identical 20 diffs — +scheduler ignores decl order); moving ctx->m* tail stores adjacent to the +u16 loads (regressed 20→108, whole-web rotation). Conclusion: pure list- +scheduling tie, same family as before. + +## lyt_window — DrawFrame 98.18 (1504B) + +376=376 insns. One callee-window permutation: orig numbers the static +flipInfos[] array base early (r21, first materialized at insn 36) pushing +arg webs to r27-r31; mine puts it deepest (r31), args r26-r30. Same web +count (12 callee webs r20-r31 both), identical prologue/epilogue; only the +allocator's numbering differs. Plus a repeated stfsx/fadds store-weave in +the 4 DRAW_QUAD_FOR_FRAME_1 corner blocks. +FAILED variants: scoping polPt/polSize inside the macro (385 insns, +worse); moving texSize decl after polPt/polSize (372 insns, worse). +NOTE: paired-single ops — capstone can't decode psq_*/ps_* insns, so +ndiff.py/disasm_fn.py truncate at the first one; use raw-word diffs. + +## iplMemoryCardManager — 8 sub-100 fns all decomposed + +- isMoveEnable/isCopyEnable (99.83), update_file_array (99.72), + getComment (98.94): 0 normalized diffs — pure regname webs. +- isBannerEnable (92.31, 26 insns, 7 diffs) + getBlocks (92.0, 25 insns, + 6 diffs): single diff = `addi r11,r1,0x20` restgpr-setup placement — + orig emits it at tail (after the full member-chain load), mine hoists + to slot 11. Folded-return variant (`return icons[slot][mFile..]` no + locals) emits identical code — scheduler-internal, decl-form insensitive. + Folded form kept (same output, terser). +- _create_icon (87.55) + create_banner (90.42): `(base+const)+var` + member-chain regroup — orig computes (&mFileCell + memberOffs) + + (slot*row + file*0x15C combined index) with `this+0x10EC`/`this+0x110C` + bases cached in callee regs reused across both GX_TF branches, and + rematerializes &cell.icon per call (`add r3,...` then `add r24,...` + post-bl) while mine pins it; marshal order `li r4,0` before `mr r3` + in orig. FAILED variants: `MCFileCell* cell = &mFileCell[slot][file]` + (90 insns — MWCC folded the pointer, worse); `mFileCell[0] + + slot*0x7F + file` flat-index (89 insns — aggressive CSE, worse). + Same documented mcard2 wall. + +All units stay NonMatching — no shims, no flips. Every residual is a +verified allocator/scheduler/emission-policy tie with source-form evidence. + +## Round 2 (post-#834 rebase @11c75ddb) — sdChannelTitle emit-parity probe + +Investigated per orchestrator hint whether the 152B weak-dtor + dangling-UND +residual was the same dedup-loss family as channelTitle's symbols.txt fix. +VERDICT: NOT a naming issue and NOT a flip blocker. + +- orig iplSDChannelTitle.o: ZERO weak FUNC syms. Mine emits 2 unreferenced + weak deleting-dtor bodies: `__dt__FaderSceneBase` (88B @0x1f4) + + `__dt__FrameController` (64B @0xb30), plus 3 zero-reloc UND vtable refs + (`__vt__FrameController`, `__vt__SDButtonEventHandlerBase`, `__vt__LangFile`). +- orig iplFaderSceneBase.o's own view: `~FaderSceneBase` is DECLARED-ONLY + (its `__dt__` is UND there, defined in another TU). +- Tried `__declspec(novtable)` on all 4 classes under + IPL_SD_CHANNEL_TITLE_CPP: removed the 3 dangling `__vt__` UNDs (correct + mechanism — orig stores only most-derived vt) but weak bodies persisted. +- Tried implicit-trivial dtor (removing decl): `__dt__FrameController` emit + STOPPED (64B gone), but `calc()` vtable slot shifted 0x0c→0x08 → + calcFadein/calcFadeout single-word diffs (`lwz r12,0x0c(r12)` vs 0x08) + → REVERTED everything. +- CRITICAL PROOF these bodies are harmless: main's iplChannelTitle.o + (unit fuzzy 100.0 post-#834) emits the IDENTICAL `__dt__FaderSceneBase` + 88B + `__dt__FrameController` 64B weak bodies that orig's .o lacks. + They are linker-stripped dead emission; objdiff fn-pairing ignores them. + => The 152B was never the blocker. Real residual = flushSaveBeforeExit + 98.59 only. + +## flushSaveBeforeExit — 6-diff → 2-diff minimum + +Window is the `sm` (System globals) base web: orig binds &sm to r3 and +loads +0x94→r4 (store), +0x28→r4 (heap arg), +0x94→r3 (recv); mine binds +r4 and marshals recv before arg. Variants: +- saveHeap decl hoisted above getSDPrevPage store: 2 diffs (base→r5, + +0x28 load moved early) — closer but not orig's order. +- `flushAsync(System::getMem2App())` inline: same 2 diffs, base→r4. +Residual = base-web home + marshal eval order — allocator tie. + +## GLGR — ready-set issue-order re-probes + +- def-move (sheetGlyphCount/dataBlockCount to tail): 20→99 diffs, REGRESSION. +- `u32 remWorkSpace = ctx->remWorkSpace()` hoist: 20→25, REGRESSION. +- stepSheetFlags after flagsSheetsOff (dependency-chain reorder): identical + 20 diffs — MWCC issue-order insensitive to stmt order here. Wall stands. + +## DrawFrame / MCManager re-verified + +DrawFrame 376=376: flipInfos base pinned r21(orig)/r31(mine) + stfsx weave +— callee-numbering tie unchanged. create_banner/_create_icon: `(base+const) ++var` regroup + recompute-vs-CSE (`add r3,r29,r25` remat per call in orig) +— same documented wall. -- 2.49.1 From f9358f6e466d66427c08a982e52e988e4e92613f Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 17:26:43 -0500 Subject: [PATCH 2/4] Decode BS2Mach Run asm + nup dead-static fossil (stays NonMatching) (#973) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * decomp: BS2Mach Run asm + CoverBlock/state decodes; nup dead-static fossil - BS2Mach::Run: retail zeroes r0-r31 and installs a custom stack (__pformatter+640) before the dcbz/dcbf flush loop and tail jump — inexpressible in C, so asm with the exact retail sequence. - BS2StartGCGame: CoverBlock.state direct member read (orig inlined DVDGetCommandBlockStatus accessor). - BS2StateMachine: GamePartition!=0 polarity fold. - nup.cpp __nupOp: 'static u32 lo' dead static reproduces orig's second .sbss word (orig .sbss=8: rvThread$2389 + 4B dead static). Verified vs main: BS2Mach 25/29 fns byte-exact, nup 20/23 + .sbss 8=8. Units stay NonMatching. Full build + DOL sha1 verified. Co-authored-by: coah80 Co-Authored-By: wch * decomp: drop dead 'static u32 lo' padding from __nupOp Per review: the extra .sbss word is a padding object — no relocation references it, and nup data is already exact without it. Left unowned for the linking pass. Co-Authored-By: wch --------- Co-authored-by: devin Co-authored-by: coah80 --- src/BS2/BS2Mach.c | 73 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 11 deletions(-) diff --git a/src/BS2/BS2Mach.c b/src/BS2/BS2Mach.c index 23832473..3fb4a619 100644 --- a/src/BS2/BS2Mach.c +++ b/src/BS2/BS2Mach.c @@ -242,14 +242,64 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO) extern vu32 BS2VideoMode; extern vu32 __DVDLayoutFormat; -void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) { - u8 *block = start; - for (; blockCount != 0; --blockCount) { - __dcbz(block, 0); - __dcbf(block, 0); - block += 32; - } - ((void (*)(u32))entryPoint)(argument); +extern void __pformatter(void); + +asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) { + // clang-format off +#ifdef __MWERKS__ + nofralloc + + mtctr r5 + mtlr r3 + + li r0, 0 + li r2, 0 + li r3, 0 + li r5, 0 + li r7, 0 + li r8, 0 + li r9, 0 + li r10, 0 + li r11, 0 + li r12, 0 + li r13, 0 + li r14, 0 + li r15, 0 + li r16, 0 + li r17, 0 + li r18, 0 + li r19, 0 + li r20, 0 + li r21, 0 + li r22, 0 + li r23, 0 + li r24, 0 + li r25, 0 + li r26, 0 + li r27, 0 + li r28, 0 + li r29, 0 + li r30, 0 + li r31, 0 + + lis r1, __pformatter+640@h + ori r1, r1, (__pformatter+640)@l + li r6, 0 + + b Run_loop_entry +Run_loop: + dcbz r4, r0 + dcbf r4, r0 + addi r4, r4, 0x20 + bdnz Run_loop + b Run_done +Run_done: + li r4, 0 + blr +Run_loop_entry: + b Run_loop +#endif + // clang-format on } BOOL BS2GetLockedTitles(ESTitleId *pTitleIds, u32 *count) { @@ -803,7 +853,7 @@ void BS2StartGCGame() { OSTime time; StartingGame = TRUE; - while (DVDGetCommandBlockStatus(&CoverBlock) != DVD_STATE_IDLE) { + while (CoverBlock.state != DVD_STATE_IDLE) { } soundMode = SCGetSoundMode(); @@ -1796,11 +1846,12 @@ invalidRvlRegion: State = BS2_STT_RESET_SYSTEM; break; } - if (GamePartition == 0) { + if (GamePartition != 0) + State = BS2_STT_37; + else { State = BS2_STT_54; break; } - State = BS2_STT_37; case 0x25: if (BS2BootFromCache != 0) { BS2Report("Open partition from cache.dat\n"); -- 2.49.1 From 0dfb3a551ecb3ac62d846b92b2a23bf161b5c8f6 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 2 Oct 2026 17:26:54 -0500 Subject: [PATCH 3/4] decomp: reconstruct alpha output and dictionary scan --- .../RVLMiddleware/eZiText/src/clib/zi8alpha.c | 29 ++++----- ...llhands-ezitext-alpha-followup.attempts.md | 65 +++++++++++++++++++ 2 files changed, 76 insertions(+), 18 deletions(-) create mode 100644 tools/decomp-assist/allhands-ezitext-alpha-followup.attempts.md diff --git a/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c b/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c index bfb2ebed..bd2f13fb 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c @@ -920,8 +920,7 @@ selectDictionary: if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) && ((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) { *wordCursor = ((ZiAlphaWork*)workData)->singleCharacter; - wordCursor[1] = *punctuationCursor; - punctuationCursor = punctuationCursor + 1; + wordCursor[1] = *punctuationCursor++; wordCursor[2] = 0; wordLength = 2; } @@ -1208,10 +1207,8 @@ emitCandidate: if (((ZiAlphaOptions*)optionData)->maxResults <= candidateCount) goto finishCandidates; } else { if (((ZiAlphaOptions*)optionData)->lookupMode != '\0') { - for (index = 0; - (index <= (int)wordLength && - (wordCursor[index] == ((ZiAlphaOptions*)optionData)->dictionary[index])); - index = index + 1) { + for (index = 0; index <= wordLength; index++) { + if (wordCursor[index] != ((ZiAlphaOptions*)optionData)->dictionary[index]) break; } if ((((((ZiAlphaWork*)workData)->operation != '\0') || ((int)wordLength <= index)) && ((((ZiAlphaWork*)workData)->operation == '\0' || @@ -1382,21 +1379,17 @@ finishDictionaryPass:; } if (((candidateCount == 0) && (punctuationCandidate)) && (firstCandidate == 0)) { candidateCount = 1; - if ((((ZiAlphaOptions*)optionData)->countOnly == '\0') && ((parameters->getOptions & 0xfd) != 0x81)) { - *encodedOutput = 0x3e; - encodedOutput[2] = 0; - encodedOutput[1] = 0; - } - else { + if (((ZiAlphaOptions*)optionData)->countOnly != 0 || (parameters->getOptions & 0xFD) == 0x81) { if (parameters->getMode == 1) { *wordCursor = *elements; + } else { + *wordCursor = 0x3E; } - else { - *wordCursor = 0x3e; - } - wordCursor[2] = 0; - wordCursor[1] = 0; - wordCursor = wordCursor + 2; + wordCursor[1] = wordCursor[2] = 0; + wordCursor += 2; + } else { + *encodedOutput = 0x3E; + encodedOutput[1] = encodedOutput[2] = 0; } if (((ZiAlphaOptions*)optionData)->lookupMode == '\0') { ((ZiAlphaWork*)workData)->singleCharacter = 0; diff --git a/tools/decomp-assist/allhands-ezitext-alpha-followup.attempts.md b/tools/decomp-assist/allhands-ezitext-alpha-followup.attempts.md new file mode 100644 index 00000000..599d7e12 --- /dev/null +++ b/tools/decomp-assist/allhands-ezitext-alpha-followup.attempts.md @@ -0,0 +1,65 @@ +# Alpha output and scan reconstruction follow-on, 2026-10-02 + +Parent candidate: `94b7f57e`. Its source/log were left unchanged during +independent side experiments. No ABI/header/linking changes are included. +Changed source: `libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c` only. + +## Target evidence and retained changes + +- At `Zi8AlphaGetCandidates +0x3178`, the original emits wide-character + output before the encoded-byte alternative. The wide path assigns the + same zero to output elements 2 and 1 (+0x31A4/+0x31A8), then advances by + two characters. The encoded path likewise shares its zero assignment. + Restored that positive branch and ordinary chained zero assignments. +- The dictionary comparison loop branches from +0x2904 to its bound check + at +0x292C. The comparison body exits on a character mismatch at +0x2924; + a matched character increments the index at +0x2928. Replaced the merged + `for` condition with the corresponding bounded loop and explicit break. +- The punctuation output block at +0x1B0C..+0x1B1C reads the current cursor, + emits its character and advances that same cursor. Expressed this with + `wordCursor[1] = *punctuationCursor++`. It does not reuse a mutated index + in another operand or introduce an unsequenced read/write. + +## Independently compiled, isolated trials + +Each trial used the exact 43U MWCC flags from the live Ninja command and a +separate object/report under `/tmp/ezi-side`, without altering the reviewed +worktree candidate. Report columns below are function fuzzy, unit fuzzy, +matched data bytes and exact-function count: + +- Early candidate-skip block: 94.65585, 96.10635, 408, 11; excluded +- Wide output first: 94.887985, 96.27548, 516, 11; retained +- Next-dictionary switches: 94.4037, 95.92264, 408, 11; excluded +- Explicit dictionary-scan break: 94.62088, 96.08087, 516, 11; retained +- Combined candidate-count limit: 94.35884, 95.88995, 408, 11; excluded +- Punctuation cursor increment: 94.4782, 95.97692, 516, 11; retained +- Wide output plus scan: 95.02306, 96.37389, 516, 11 +- Final three-change subset: 95.02813, 96.37759, 516, 11 + +## Full current-worktree validation + +Fresh report: `/tmp/ezi-alpha-followup.json`. +Full build log: `/tmp/ezi-alpha-followup-build.log`. +Exact functions 11/12 unchanged; exact code 5880/21664 unchanged; +exact data 516/564 unchanged. Unit fuzzy 95.97323% -> 96.37759%. +Function fuzzy 94.47314% -> 95.02813%, about 88 additional weighted bytes. +Relative to initial 449529d9, unit fuzzy improves 94.17892% -> 96.37759%. + +Pool first: identical (no narrow strings in either pool). +Main function: 3946/3946 instructions, 0x3DA8 bytes each, frame 0x2B0. +Strict ctxdiff remains nonzero (3745 differences), dominated by the known +scalar-stack displacement, instruction placement and GPR allocation. No +new exact function is claimed. Each of the existing 11 exact functions +retains identical instruction counts and ctxdiff diffs 0. + +All non-text section scores match the parent: .rodata, extab and extabindex +remain 100%; the existing 48-byte generated switch table remains unmatched. +The advisory register-normalized/control-flow alignment checked 701 branch +pairs with zero destination mismatches and 73/73 helper calls. This is a +coverage check, not an exactness claim. + +Full 43U build succeeds with the approved wrapper and +`WIBO_SJIS_MISSING_IMPORTS=1`. DOL SHA1: +`26116613f624061ba99c8d1a299aaa6efa85670d`. +`git diff --check` succeeds. No new assembly, volatile workaround, register +forcing, undefined value, dummy storage, prototype or shared-header change. -- 2.49.1 From 6b17698b849ae2d06ad903cede5a103d8c6900d7 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 2 Oct 2026 17:28:16 -0500 Subject: [PATCH 4/4] match(odh): cdj_c_colorConv byte-identical (#974) Pad with a named remainder and declare sourceStride after rowIndex so cbPlane stays r22 and the stride stays r29. decompressLoop is unchanged. --- src/system/odh.cpp | 21 +++++++++------------ tools/decomp-assist/attempts/odh-worker2.md | 8 ++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/system/odh.cpp b/src/system/odh.cpp index 88b202b4..d1e303f0 100644 --- a/src/system/odh.cpp +++ b/src/system/odh.cpp @@ -931,17 +931,15 @@ void CArGBAOdh::cdj_c_makeHeader(SArCDJ_OdhMaster* master, u32 size) { } s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int format) { - u32 paddedWidth; u16 width; u16 height; u8* workPlane; - int sourceStride; - u8* crPlane; u8* cbPlane; + u8* crPlane; u16* dimensions; int rowIndex; + int sourceStride; int i; - u16 dimension; u16 paddedDimensions[2]; dimensions = &master->width; @@ -952,11 +950,11 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for height = dimensions[1]; for (i = 0; i < 2; i++) { - dimension = dimensions[i]; - if ((dimension & 7) != 0) { - paddedDimensions[i] = (dimension + 8) - (dimension & 7); + u16 remainder = dimensions[i] & 7; + if (remainder != 0) { + paddedDimensions[i] = (dimensions[i] + 8) - remainder; } else { - paddedDimensions[i] = dimension; + paddedDimensions[i] = dimensions[i]; } } @@ -972,13 +970,12 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for } } - paddedWidth = paddedDimensions[0]; for (rowIndex = 0; rowIndex < (s32)height; rowIndex++) { LineConv11(sourceData + (rowIndex & 3) * 8 + rowIndex / 4 * sourceStride, workPlane, cbPlane, crPlane, dimensions[0], dimensions[1], (const long*)gArConvPlttTbl, format); - workPlane += paddedWidth; - cbPlane += paddedWidth; - crPlane += paddedWidth; + workPlane += paddedDimensions[0]; + cbPlane += paddedDimensions[0]; + crPlane += paddedDimensions[0]; } return 0; diff --git a/tools/decomp-assist/attempts/odh-worker2.md b/tools/decomp-assist/attempts/odh-worker2.md index 02fd7389..6e82f332 100644 --- a/tools/decomp-assist/attempts/odh-worker2.md +++ b/tools/decomp-assist/attempts/odh-worker2.md @@ -16,3 +16,11 @@ Claim was only `cdj_d_decompressLoop`. colorConv, huffmanDecoder, and LineConv11 - 2x2 tail stores the updated plane in `requiredBlockEnd` and the end pointer in `planeOffset`. That is what puts the plane in r15 and the end in r16 (`addi r15, r3, -8` / `add r16, r15, r18`). Assigning the plane back to `planeOffset` left those two callee-saves swapped (7 diffs). Splitting the `-8` let MWCC cancel it against the later `+8` and dropped to 897. colorConv left at the 18 pairwise wall. Not in this diff. + +## colorConv (2026-10-02) + +`cdj_c_colorConv` **77/77, 0 diffs, byte-identical** (308 bytes). Was 18, then 13, then 8. + +- Drop `paddedWidth`. The row loop adds `paddedDimensions[0]`, which hoists `lhz r24` and `lis r23` / `addi r10, r23, 0`. +- Pad loop: `u16 remainder = dimensions[i] & 7`, then `(dimensions[i] + 8) - remainder`. Width stays r8, the indexed load stays r7, the mask stays r9. Naming both a dimension and a remainder swaps width off r8. +- Declare `sourceStride` after `rowIndex` (cb/cr stay above it). That assigns stride r29 and `cbPlane` r22. Computing stride before the planes shortens the function to 76 and shifts the callee-saves. huffmanDecoder and LineConv11 were not edited. `cdj_d_decompressLoop` stays 899/899. -- 2.49.1