diff --git a/configure.py b/configure.py index e6caa0c9..68cdda19 100644 --- a/configure.py +++ b/configure.py @@ -868,7 +868,7 @@ config.libs = [ ] ), IPLSection("setting", [ - Object(NonMatching, "scene/setting/iplSetting.cpp"), + Object(Matching, "scene/setting/iplSetting.cpp"), Object(Matching, "scene/setting/iplSensitivity.cpp"), Object(Matching, "scene/setting/iplNCDSetting.cpp"), Object(Matching, "scene/setting/iplParental.cpp"), diff --git a/docs/asm-inventory.md b/docs/asm-inventory.md index 6fa9beaa..e57b3cf3 100644 --- a/docs/asm-inventory.md +++ b/docs/asm-inventory.md @@ -1,7 +1,7 @@ # Assembly inventory -4.3U, 2026-10-05. 171 functions contain 173 assembly -bodies/blocks: 162 ORIGINAL functions and 9 PLACEHOLDER functions. +4.3U, 2026-10-05. 170 functions contain 172 assembly +bodies/blocks: 162 ORIGINAL functions and 8 PLACEHOLDER functions. Run `python3 tools/check_asm_inventory.py`. Completion requires exit 0, complete coverage and zero placeholders. The checker also rejects stale/duplicate rows, @@ -191,7 +191,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in | `src/scene/nakamuraTest/gamespy/common/gsPlatformUtil.c` | `GetTicks` | ORIGINAL | Inactive PS2 branch reads the CP0 Count register with mfc0 $9. | | `src/system/iplChannelManager.cpp` | `getTitleName__Q33ipl7channel7ManagerCFiii` | PLACEHOLDER | Channel-name copying; best C 99.57746%, 71/71 instructions, four address-order differences, [rx17][rx17]. | | `src/system/iplSaveDataManager.cpp` | `Manager::hasChannel` | PLACEHOLDER | Title-slot search; best C 98.87324%, 71/71 instructions, 14 mask/base register differences, [rx30][rx30]. | -| `src/system/iplSaveDataManager.cpp` | `Manager::doUpdateChanInfos` | PLACEHOLDER | Channel metadata updates; best C 93.35821%, 68/67 instructions, extra memset base, [rx17][rx17]. | | `src/system/iplSystem.cpp` | `System::warning_run` | PLACEHOLDER | Scene/render calls; best C 98.66477%, 176/176 instructions, 47 saved-register differences, [rx17][rx17]. | | `src/system/rvl_dec.c` | `Rvl_decode` | ORIGINAL | Direct beq decoder entries preserve r3/r4 and LR; lis/ori builds the format signatures. | | `src/system/rvl_dec.c` | `Rvl_decode_szs` | ORIGINAL | Original SZS decoder convention: nofralloc, r0 retains output length, fixed r3..r10/CTR byte-copy pipeline. | diff --git a/src/scene/sdChannelSelect/iplSDChannelSelect.cpp b/src/scene/sdChannelSelect/iplSDChannelSelect.cpp index b4d9b313..27cbf1dc 100644 --- a/src/scene/sdChannelSelect/iplSDChannelSelect.cpp +++ b/src/scene/sdChannelSelect/iplSDChannelSelect.cpp @@ -212,6 +212,8 @@ namespace ipl { } } +#pragma push +#pragma ppc_iro_level 0 void SDChannelSelect::create() { mpSDWorker = new (System::getMem2App(), 4) NandSDWorker(); mpWorkerHeap = (EGG::Heap*)System::getMem2App()->alloc(0x3EA60, 0x40); @@ -253,6 +255,7 @@ namespace ipl { utility::CSFlags::UpdateFlagsFile(); } +#pragma pop void SDChannelSelect::enqueueStartNotice() { SDChannelSelectCommand command; command.type = 1; @@ -1647,6 +1650,8 @@ namespace ipl { } } +#pragma push +#pragma ppc_iro_level 0 void SDChannelSelect::flushSaveDataAndMountSD() { if (System::getDialog()->getLastResult() != DialogWindow::RESULT_NONE) { mpPointerLayout->getAnim(0)->initAnmFrame(); @@ -1658,6 +1663,7 @@ namespace ipl { } } +#pragma pop void SDChannelSelect::handleThreePageDialog() { if (System::getDialog()->callBtn2Multi(sThreePageDialogPages, 3, 10)) { mState = 27; diff --git a/src/scene/sdChannelTitle/iplSDChannelTitle.cpp b/src/scene/sdChannelTitle/iplSDChannelTitle.cpp index dd3cec8c..d50a5e78 100644 --- a/src/scene/sdChannelTitle/iplSDChannelTitle.cpp +++ b/src/scene/sdChannelTitle/iplSDChannelTitle.cpp @@ -1351,6 +1351,8 @@ extern "C" void iplSDChannelTitle_prepareSceneExit(SDChannelTitle* scene, int ne } } +#pragma push +#pragma ppc_iro_level 0 extern "C" void iplSDChannelTitle_flushSaveBeforeExit(SDChannelTitle* scene, int nextScene) { int page; int index; @@ -1358,10 +1360,10 @@ extern "C" void iplSDChannelTitle_flushSaveBeforeExit(SDChannelTitle* scene, int System::getSaveData()->pushTitleCache(scene->mTitleId); } System::getSaveData()->getSDPrevPage() = scene->mPage; - EGG::Heap* saveHeap = System::getMem2App(); - scene->mpSaveFile = System::getSaveData()->flushAsync(saveHeap); + scene->mpSaveFile = System::getSaveData()->flushAsync(System::getMem2App()); __WPADReconnect(TRUE); } +#pragma pop extern "C" void iplSDChannelTitle_rebootSystem(SDChannelTitle*) { snd::getSystem()->stopAllSound(0); diff --git a/src/scene/setting/iplSetting.cpp b/src/scene/setting/iplSetting.cpp index 75f16ff3..65f0f0da 100644 --- a/src/scene/setting/iplSetting.cpp +++ b/src/scene/setting/iplSetting.cpp @@ -2705,6 +2705,8 @@ namespace ipl { mUiStatus[2] = 0; } +#pragma push +#pragma ppc_iro_level 1 void Setting::scanAP() { BOOL playing = FALSE; switch (mAPScanState) { @@ -2753,9 +2755,8 @@ namespace ipl { mpPaneManager->update(); break; case 6: { - int animationIndex = mAPAnimationIndex; mInputDelayFrame = 1; - playing |= mpMainLayout->getAnim(animationIndex)->isPlaying(); + playing |= mpMainLayout->getAnim(mAPAnimationIndex)->isPlaying(); if (!playing) { mAPScanState = 5; setAPDraw(); @@ -2780,9 +2781,8 @@ namespace ipl { break; } case 7: { - int animationIndex = mAPAnimationIndex; mInputDelayFrame = 1; - playing |= mpMainLayout->getAnim(animationIndex)->isPlaying(); + playing |= mpMainLayout->getAnim(mAPAnimationIndex)->isPlaying(); if (!playing) { updateScroll(); mAPScanState = 6; @@ -2806,6 +2806,7 @@ namespace ipl { break; } } +#pragma pop void Setting::initScroll() { if (mUiStatus[2] == 0) { diff --git a/src/system/iplSaveDataManager.cpp b/src/system/iplSaveDataManager.cpp index 0bc3b606..4810ec06 100644 --- a/src/system/iplSaveDataManager.cpp +++ b/src/system/iplSaveDataManager.cpp @@ -696,81 +696,35 @@ namespace ipl { } } - asm BOOL Manager::doUpdateChanInfos(register ESTitleId* titleIds) { - nofralloc - stwu r1, -0x40(r1) - mflr r0 - stw r0, 0x44(r1) - addi r11, r1, 0x40 - bl _savegpr_20 - mr r27, r3 - mr r28, r4 - li r3, 0 - li r30, 0 - li r26, 0 - li r25, 0 - li r20, 3 - li r21, 0 - li r22, 0xe - li r23, -1 - doUpdateChanInfos_L1: - add r31, r27, r26 - li r29, 0 - li r24, 0 - doUpdateChanInfos_L2: - add r4, r31, r24 - lbz r0, 0x30(r4) - cmplwi r0, 1 - beq doUpdateChanInfos_L5 - add r0, r29, r25 - lwz r9, 0x38(r4) - slwi r0, r0, 3 - lwz r5, 0x3c(r4) - add r8, r28, r0 - lwzx r6, r28, r0 - lwz r7, 4(r8) - xor r0, r9, r6 - xor r5, r5, r7 - or. r0, r5, r0 - beq doUpdateChanInfos_L5 - or. r0, r7, r6 - bne doUpdateChanInfos_L4 - addi r3, r4, 0x30 - li r4, 0 - li r5, 0x10 - bl memset - b doUpdateChanInfos_L6 - doUpdateChanInfos_L4: - stb r20, 0x30(r4) - stb r21, 0x31(r4) - stb r21, 0x32(r4) - stb r21, 0x33(r4) - stw r22, 0x34(r4) - lwz r0, 0(r8) - and r0, r0, r23 - stw r0, 0x38(r4) - lwz r0, 4(r8) - and r0, r0, r23 - stw r0, 0x3c(r4) - doUpdateChanInfos_L6: - li r3, 1 - doUpdateChanInfos_L5: - addi r29, r29, 1 - addi r24, r24, 0x10 - cmpwi r29, 0xc - blt doUpdateChanInfos_L2 - addi r30, r30, 1 - addi r25, r25, 0xc - cmpwi r30, 4 - addi r26, r26, 0xc0 - blt doUpdateChanInfos_L1 - addi r11, r1, 0x40 - bl _restgpr_20 - lwz r0, 0x44(r1) - mtlr r0 - addi r1, r1, 0x40 - blr +#pragma push +#pragma ppc_iro_level 0 + BOOL Manager::doUpdateChanInfos(ESTitleId* titleIds) { + BOOL changed = FALSE; + for (int page = 0; page < MAX_CHANNEL_PAGE; page++) { + for (int index = 0; index < MAX_CHANNEL_INDEX; index++) { + if (mData.chanInfo[page][index].primaryType != channel::PRIMARY_TYPE_DISK) { + ESTitleId titleId = ES_TITLE_ID(mData.chanInfo[page][index].titleType, mData.chanInfo[page][index].titleCode); + int n = index + page * MAX_CHANNEL_INDEX; + if (titleId != titleIds[n]) { + if (titleIds[n] == TITLE_NULL) { + memset(&mData.chanInfo[page][index], 0, sizeof(channel::SInfo)); + } else { + mData.chanInfo[page][index].primaryType = channel::PRIMARY_TYPE_CHANNEL; + mData.chanInfo[page][index].secondaryType = channel::SECONARY_TYPE_NORMAL; + mData.chanInfo[page][index].reserved[0] = 0; + mData.chanInfo[page][index].reserved[1] = 0; + mData.chanInfo[page][index].sceneID = SCENE_NORMAL_CHANNEL; + mData.chanInfo[page][index].titleType = ES_TITLE_TYPE(titleIds[n]); + mData.chanInfo[page][index].titleCode = ES_TITLE_CODE(titleIds[n]); + } + changed = TRUE; + } + } + } + } + return changed; } +#pragma pop #endif BOOL Manager::checkValidApp(ESTitleId titleId) { diff --git a/tools/decomp-assist/opus-iro.attempts.md b/tools/decomp-assist/opus-iro.attempts.md new file mode 100644 index 00000000..bc27337f --- /dev/null +++ b/tools/decomp-assist/opus-iro.attempts.md @@ -0,0 +1,36 @@ +# opus-iro attempts + +## Part A: function-scoped ppc_iro_level + +| unit | function | before | change | after | +|------|----------|--------|--------|-------| +| sdChannelSelect/iplSDChannelSelect | create | 39/146 | `ppc_iro_level 0` around the function | 0/146 | +| sdChannelSelect/iplSDChannelSelect | flushSaveDataAndMountSD | 2/35 | `ppc_iro_level 0` | 0/35 | +| sdChannelTitle/iplSDChannelTitle | iplSDChannelTitle_flushSaveBeforeExit | 6/37 | `ppc_iro_level 0`; dropped the `saveHeap` temporary | 0/37 | +| setting/iplSetting | scanAP | 4/272 | `ppc_iro_level 1` (level 0 not exact per sweep); dropped `animationIndex` temporaries in cases 6/7 | 0/272 | + +Other functions in each unit unchanged (per-function diff before/after). Pools identical. + +- iplSetting: every function exact; flipped to Matching, full build DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. +- iplSDChannelTitle: every .text function exact, but flipping to Matching breaks the DOL (0x40 shift). + Object .text is 0x4b48 vs target 0x48c0 and .data 0x65c vs 0x6a0, so the unit emits extra code and + misses data that objdiff's per-symbol view does not show. Left NonMatching. +- iplSDChannelSelect: 4 functions still non-exact; stays NonMatching. + +## Part B: asm placeholders under ppc_iro_level + +| function | candidate | default (3) | level 0 | level 1 | level 2 | +|----------|-----------|-------------|---------|---------|---------| +| Manager::doUpdateChanInfos | plain `mData.chanInfo[page][index]` form, `n` local | 62/68 | 7/67 | 7/67 | 66/71 | +| Manager::doUpdateChanInfos | swap `!=` operands | - | 7/67 | | | +| Manager::doUpdateChanInfos | inline `titleIds[index + page * 12]`, no `n` | - | 7/67 | | | +| Manager::doUpdateChanInfos | `int n` hoisted to function scope | - | 7/67 | | | +| Manager::doUpdateChanInfos | `ESTitleId* titleId = &titleIds[n]` | - | 7/67 | | | +| Manager::doUpdateChanInfos | `ESTitleId titleId = titleIds[n]` value local | - | 48/67 | | | +| Manager::doUpdateChanInfos | `ESTitleId titleId = ES_TITLE_ID(stored)` before `n` (same shape as makePriorTitleIDList) | - | **0/67** | | | +| Manager::hasChannel | rx30 has-00 (best C) | 14/71 | 29/71 | 29/71 | 29/71 | +| getTitleName | grok-title best C | 4/71 | 82/88 | 82/88 | 56/71 | + +doUpdateChanInfos converted to C under `ppc_iro_level 0`; the remaining 7 register diffs came from the order the +stored title and the input title were evaluated. hasChannel and getTitleName have strength-reduced, hoisted +IRO-on codegen in the target (mtctr loop, hoisted name stride), so lowering IRO makes them worse; both stay asm.