diff --git a/src/scene/setting/iplSetting.cpp b/src/scene/setting/iplSetting.cpp index cded8458..28151538 100644 --- a/src/scene/setting/iplSetting.cpp +++ b/src/scene/setting/iplSetting.cpp @@ -1379,30 +1379,34 @@ namespace ipl { return; } - ext_ead::www::BrowserThread* browser = surface->GetBrowserThread(); - if (browser == NULL) { + // One pointer, overwritten by the standard-buffer fetch, so the + // browser `this` and standardBuffer share a callee-saved reg. + void* held = surface->GetBrowserThread(); + if (held == NULL) { return; } - if (browser->GetTextureBuffer(0, NULL) == NULL) { + if (static_cast(held)->GetTextureBuffer(0, NULL) == NULL) { return; } ext_ead::www::BrowserWindow* browserWindow = - static_cast(browser->mpBrowserWindows[0]); - if ((browserWindow != NULL ? browserWindow->unk_0x2C4[3] : 0) != 0) { + static_cast(static_cast(held)->mpBrowserWindows[0]); + if ((browserWindow == NULL ? 0 : browserWindow->unk_0x2C4[3]) != 0) { unk_0x91C[2] = 1; mState = 0; - browserWindow = static_cast(browser->mpBrowserWindows[0]); + browserWindow = static_cast(static_cast(held)->mpBrowserWindows[0]); if (browserWindow != NULL) { browserWindow->unk_0x2C4[3] = 0; } www::trasition::ScrollState scrollState = www::trasition::GetScrollState(); - browserScrollDirection = scrollState == www::trasition::SCROLL_LEFT - ? 1 - : (scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0); + if (scrollState == www::trasition::SCROLL_LEFT) { + browserScrollDirection = 1; + } else { + browserScrollDirection = scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0; + } www::trasition::ResetScrollState(); - void* changedWideBuffer = browser->GetTextureBuffer(1, NULL); - void* changedStandardBuffer = browser->GetTextureBuffer(0, NULL); + void* changedWideBuffer = static_cast(held)->GetTextureBuffer(1, NULL); + void* changedStandardBuffer = static_cast(held)->GetTextureBuffer(0, NULL); OSReport("changed %p %p\n", changedStandardBuffer, changedWideBuffer); ext_ead::www::Heap::reportLeaHeap(); } @@ -1415,8 +1419,9 @@ namespace ipl { WWWRect* standardRect; WWWRect* wideRect; - void* wideBuffer = browser->GetTextureBuffer(1, &wideRect); - void* standardBuffer = browser->GetTextureBuffer(0, &standardRect); + void* wideBuffer = static_cast(held)->GetTextureBuffer(1, &wideRect); + held = static_cast(held)->GetTextureBuffer(0, &standardRect); + void* standardBuffer = held; nw4r::ut::Rect projection4x3; System::getProjectionRect4x3(&projection4x3); int screenWidth = abs(static_cast(projection4x3.GetWidth())); @@ -1443,33 +1448,33 @@ namespace ipl { int wideWidth = abs(static_cast(projection16x9.GetWidth())); int wideHeight = abs(static_cast(projection16x9.GetHeight())); f32 wideLeft = -wideWidth / 2; - f32 wideTop = wideHeight / 2; + f32 wideTopL = wideHeight / 2; f32 wideRight = wideWidth / 2; - nw4r::ut::Rect leftSide(wideLeft, wideTop, + f32 wideTopR = wideHeight / 2; + nw4r::ut::Rect leftSide(wideLeft, wideTopL, wideLeft + sideDescriptor->textureHeader->width, - wideTop - sideDescriptor->textureHeader->height); + wideTopL - sideDescriptor->textureHeader->height); nw4r::ut::Rect rightSide(wideRight - sideDescriptor->textureHeader->width, - wideTop, wideRight, wideTop - sideDescriptor->textureHeader->height); - + wideTopR, wideRight, wideTopR - sideDescriptor->textureHeader->height); if (browserScrollDirection != 0) { - nw4r::lyt::Material* wideMaterial = + void* wideMaterial = mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex0"); nw4r::lyt::Material* firstStandardMaterial = mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex1"); nw4r::lyt::Material* secondStandardMaterial = mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex2"); - wideMaterial->SetTexture(0, wideTexture); + static_cast(wideMaterial)->SetTexture(0, wideTexture); firstStandardMaterial->SetTexture(0, standardTexture); secondStandardMaterial->SetTexture(0, standardTexture); mpChangeLayout->FindPaneByName("N_Tra0")->SetVisible(true); if (browserScrollDirection == 1) { - utility::FrameController* animation = mpSecondAnimation; - animation->initFrame(); - animation->restart(); + wideMaterial = mpSecondAnimation; + static_cast(wideMaterial)->initFrame(); + static_cast(wideMaterial)->restart(); } else { - utility::FrameController* animation = mpFirstAnimation; - animation->initFrame(); - animation->restart(); + wideMaterial = mpFirstAnimation; + static_cast(wideMaterial)->initFrame(); + static_cast(wideMaterial)->restart(); } mpChangeLayout->calc(); browserScrollDirection = 0; @@ -1509,13 +1514,44 @@ namespace ipl { } if (mpWiiSettingFlag->smthMsgData >= 2 && mpWiiSettingFlag->smthMsgData <= 7) { - GXRenderModeObj renderMode = *System::getRenderModeObj(); + GXRenderModeObj* pRmode = System::getRenderModeObj(); + GXRenderModeObj renderMode; + volatile GXRenderModeObj* srcMode = pRmode; + volatile GXRenderModeObj* dstMode = &renderMode; + int n = 12; + u8* src; + u8* dst = &renderMode.aa; + src = &pRmode->aa; + dstMode->viTVmode = srcMode->viTVmode; + dstMode->fbWidth = srcMode->fbWidth; + dstMode->efbHeight = srcMode->efbHeight; + dstMode->xfbHeight = srcMode->xfbHeight; + dstMode->viXOrigin = srcMode->viXOrigin; + dstMode->viYOrigin = srcMode->viYOrigin; + dstMode->viWidth = srcMode->viWidth; + dstMode->viHeight = srcMode->viHeight; + dstMode->xFBmode = srcMode->xFBmode; + dstMode->field_rendering = srcMode->field_rendering; + dstMode->aa = srcMode->aa; + for (; n != 0; n--) { + dst[1] = src[1]; + dst[2] = src[2]; + src += 2; + dst += 2; + } + dstMode->vfilter[0] = srcMode->vfilter[0]; + dstMode->vfilter[1] = srcMode->vfilter[1]; + dstMode->vfilter[2] = srcMode->vfilter[2]; + dstMode->vfilter[3] = srcMode->vfilter[3]; + dstMode->vfilter[4] = srcMode->vfilter[4]; + dstMode->vfilter[5] = srcMode->vfilter[5]; + dstMode->vfilter[6] = srcMode->vfilter[6]; u32 left; u32 top; u32 width; u32 height; GXGetScissor(&left, &top, &width, &height); - GXSetScissor(0, renderMode.efbHeight / 2 - 0xA4, renderMode.fbWidth, 0x132); + GXSetScissor(0, dstMode->efbHeight / 2 - 0xA4, dstMode->fbWidth, 0x132); mpMainLayout->draw(); GXSetScissor(left, top, width, height); } diff --git a/tools/decomp-assist/attempts/iplSetting-worker3-draw.md b/tools/decomp-assist/attempts/iplSetting-worker3-draw.md new file mode 100644 index 00000000..18010461 --- /dev/null +++ b/tools/decomp-assist/attempts/iplSetting-worker3-draw.md @@ -0,0 +1,23 @@ +# iplSetting worker3 — Setting::draw (Oct 2 2026) + +Worktree: `/workspace/worktrees/iplSetting-draw` +Branch: `agent/grok/decomp-worker-3/draw` +Unit: `src/scene/setting/iplSetting.cpp` `Setting::draw` only. +`scanAP` / `convertRevIP` source not touched. File stays `NonMatching` (not linked). + +## Result + +**632/632 byte-identical** to retail (`draw__Q33ipl5scene7SettingFv`, 2528 bytes, 0 diffs). +A HEAD compile of the same TU differs from this object only in `draw`. No sibling codegen change (`-ipa file`). + +## Levers that closed it + +1. `wideTopL` / `wideTopR` as separate locals (no CSE of the int-to-float). Gets `xoris r6,r6` and `fsubs f2`. +2. One `void* held` is the browser thread, then overwritten by the standard-buffer fetch, so browser and `standardBuffer` share r31. +3. Tex0 material pointer reused as the scroll `FrameController*` (`wideMaterial`), with `initFrame`/`restart` duplicated in each arm. +4. Field copy through `volatile GXRenderModeObj*` so loads and stores interleave on r4/r0. +5. Sample-pattern loop is direct `dst[1]=src[1]; dst[2]=src[2]` with `src` declared before `dst` is assigned (`u8* src; u8* dst = ...; src = ...`). + +## Not linked + +`configure.py` still has `Object(NonMatching, "scene/setting/iplSetting.cpp")`. DOL SHA1 is unchanged because this TU is not linked. Do not flip the object to Matching until `scanAP` / `convertRevIP` (and the rest of the TU) match.