Compare commits

...

2 Commits

Author SHA1 Message Date
coah
306ff59554 fix: model Run stack address independently of printf 2026-10-02 17:46:45 -05:00
coah
813660b96e match(iplSetting): Setting::draw byte-identical (#980)
draw is 632/632 against retail. The TU stays NonMatching, so the DOL is unchanged.
2026-10-02 17:36:11 -05:00
5 changed files with 144 additions and 32 deletions

View File

@@ -37,6 +37,9 @@ force_active:
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
block_relocations:
# Run establishes a fixed stack at 0x81600000, not __pformatter + 0x280.
- source: .text:0x8137B468
- source: .text:0x8137B46C
- source: .data:0x8165E15C
- source: .data:0x8165E19C

View File

@@ -242,8 +242,6 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
extern vu32 BS2VideoMode;
extern vu32 __DVDLayoutFormat;
extern void __pformatter(void);
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
// clang-format off
#ifdef __MWERKS__
@@ -282,8 +280,9 @@ asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
li r30, 0
li r31, 0
lis r1, __pformatter+640@h
ori r1, r1, (__pformatter+640)@l
// The application stack is fixed; it is unrelated to the formatter.
lis r1, 0x8160
ori r1, r1, 0
li r6, 0
b Run_loop_entry

View File

@@ -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<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, NULL) == NULL) {
return;
}
ext_ead::www::BrowserWindow* browserWindow =
static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
if ((browserWindow != NULL ? browserWindow->unk_0x2C4[3] : 0) != 0) {
static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(held)->mpBrowserWindows[0]);
if ((browserWindow == NULL ? 0 : browserWindow->unk_0x2C4[3]) != 0) {
unk_0x91C[2] = 1;
mState = 0;
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(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<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, NULL);
void* changedStandardBuffer = static_cast<ext_ead::www::BrowserThread*>(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<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, &wideRect);
held = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, &standardRect);
void* standardBuffer = held;
nw4r::ut::Rect projection4x3;
System::getProjectionRect4x3(&projection4x3);
int screenWidth = abs(static_cast<int>(projection4x3.GetWidth()));
@@ -1443,33 +1448,33 @@ namespace ipl {
int wideWidth = abs(static_cast<int>(projection16x9.GetWidth()));
int wideHeight = abs(static_cast<int>(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<nw4r::lyt::Material*>(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<utility::FrameController*>(wideMaterial)->initFrame();
static_cast<utility::FrameController*>(wideMaterial)->restart();
} else {
utility::FrameController* animation = mpFirstAnimation;
animation->initFrame();
animation->restart();
wideMaterial = mpFirstAnimation;
static_cast<utility::FrameController*>(wideMaterial)->initFrame();
static_cast<utility::FrameController*>(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);
}

View File

@@ -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.

View File

@@ -0,0 +1,51 @@
# Run fixed-stack relocation correction
This is a narrow follow-up to #973, not another Run implementation or a new
match. The existing assembly, cache loop, register clearing, labels and handoff
remain intact. No linking flag changes.
## Evidence
The hash-verified original DOL and linked ELF contain Run at 0x8137B3EC,
size 0xAC (43 instructions). Its instructions at 0x8137B468/0x8137B46C establish
SP as 0x81600000. This architectural stack value should not depend on placement
of an unrelated formatted-output routine.
Automatic extraction had attached two relocations to __pformatter + 0x280:
R_PPC_ADDR16_HI at Run+0x7E and R_PPC_ADDR16_LO at Run+0x82. The linked formatter
address happens to make this expression equal 0x81600000 in this target, but
that is a false semantic dependency in the reconstruction.
DTK block_relocations uses instruction addresses, not ELF halfword offsets.
The two exclusions are therefore .text:0x8137B468 and .text:0x8137B46C.
The source removes the unrelated extern and uses the fixed high/low immediate.
No other source instructions or original bytes are replaced.
## Independent validation
- Full 43U all_source, progress, report and DOL check pass.
- Original app and rebuilt DOL SHA1 both remain
26116613f624061ba99c8d1a299aaa6efa85670d.
- Run remains 100%, 43/43 instructions, ctxdiff zero. No new match attribution.
- Whole report is unchanged: no code, data, function, linking or fuzzy delta.
- Pool: all 91 strings identical.
- All 1027 native source objects compared: only BS2Mach .text changes; size
16960 is unchanged. Exactly the two false text relocations are removed.
All other allocated objects and data sections are unchanged.
- All 1027 active extracted objects compared, plus the same obsolete cached
tiManager.o in both trees. Only BS2Mach .text changes: size 16980 unchanged;
only Run's high immediate placeholder bytes at +0x7E/+0x7F become 0x81,0x60.
Exactly the two formatter relocations disappear, with no added relocations.
Defined target symbols and non-text sections stay unchanged.
- Supplemental integer-PPC contract model checks the compiled source for 1,
4 and 131072 cache lines, preserved LR entry, SP 0x81600000, cleared GPRs and
alternating dcbz/dcbf events. The zero-count prefix retains the original CTR
wrap to 0xFFFFFFFF; the full 2^32-iteration path is not executed. This is an
abstract contract test, not actual cache/MMIO or console execution.
- Workflow/literal/jump-table/pool tests: 8/36/27/8 passed.
- Diff check passes.
Assembly was already introduced by #973. The original isolated full-Run
experiment is deliberately not included here. This correction adds no new
assembly instructions, forced register uses, retail .s objects or padding.
Please review the metadata/source constant attribution explicitly.