Compare commits

...

1 Commits

Author SHA1 Message Date
devin
ddc3eeadd9 decomp(scene4): nested-switch guards + dead-store fossils (address/sdChannelSelect)
Decodes:
- start_drag_event: nested single-case switch emits the b<cond>+b
  two-branch guard (insn-identical, 7-word web-home residual)
- onEventDerived: no-break TRIG->ON_POINT fallthrough + || polarity fold
  (insn-identical, regname residuals)
- set_err_msg: default arm reads uninitialized messageId register,
  matching the orig's uninit-r4 retail bug (verified in base asm)
- movePane_onDrag width-accumulate scoping, FriendListCache::update
  member-chain regroup, AddressEdit::create/get_friendinfo arg marshals

All three units stay NonMatching; data 100% on all; documented walls in
tools/decomp-assist/scene4.attempts.md.

Co-authored-by: coah80 <usernamecole7@gmail.com>
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 22:11:41 +00:00
4 changed files with 113 additions and 34 deletions

View File

@@ -1179,10 +1179,10 @@ namespace ipl {
return;
}
if (mState != STATE_NORMAL || mMode != 0) {
return;
}
switch (mState) {
case STATE_NORMAL:
switch (mMode) {
case 0:
if (!mpFriendCache->isThere(buttonNo + mPage * BTN_MAX)) {
return;
}
@@ -1240,6 +1240,8 @@ namespace ipl {
snd::getSystem()->startSEwithPos("WIPL_SE_CH_HOLD", mDrag.mPos.x);
mState = STATE_DRAG;
}
}
}
void Address::start_drag_point_event(const char* paneName, controller::Interface* con) {
@@ -1425,10 +1427,7 @@ namespace ipl {
if (con->downTrg(controller::BTN_INTERACT)) {
Button* button = static_cast<Button*>(System::getScene(SCENE_BUTTON));
if (mState != STATE_COVER_NORMAL && mState != STATE_NORMAL) {
break;
}
if (mState == STATE_COVER_NORMAL || mState == STATE_NORMAL) {
if (Button::cmpButtonName(paneName, Button::BTN_EXIT) == 0) {
MailAddressSelect* mailAddrSel = static_cast<MailAddressSelect*>(System::getScene(SCENE_MAIL_ADDRESS_SELECT));
button->animation(Button::IDANIM_SELECT_CALENDAR_EXIT);
@@ -1477,7 +1476,7 @@ namespace ipl {
snd::getSystem()->startSE("WIPL_SE_FL_PAGE_DEC");
onPreviousPage();
}
break;
}
}
// fallthrough
}
@@ -1783,13 +1782,15 @@ namespace ipl {
nw4r::math::VEC3 baseTrans = mpLayout->FindPaneByName("N_base_move")->GetTranslate();
math::VEC2 pos = System::getControllerManager()->getController(mDrag.mChan)->getDpdProjectionPos();
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(mpLayout->FindPaneByName("T_name_move"));
const u16* name = mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX).attr.name;
f32 width = 0.0f;
if (textBox != NULL && name != NULL) {
textBox->GetFont()->GetWidth();
for (; *name != 0; name++) {
width += textBox->GetFont()->GetCharWidth(*name);
if (textBox != NULL) {
const u16* name = mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX).attr.name;
if (name != NULL) {
textBox->GetFont()->GetWidth();
for (; *name != 0; name++) {
width += textBox->GetFont()->GetCharWidth(*name);
}
}
}
width += 0.01f;
@@ -1946,11 +1947,10 @@ namespace ipl {
}
void FriendListCache::update(u32 index, const wchar_t* name, u64 fdId) {
NWC24FriendInfo* info = &mInfos[index];
info->attr.fdId = fdId;
memset(info->attr.name, 0, sizeof(info->attr.name));
wcsncpy((wchar_t*)info->attr.name, name, 10);
System::getNwc24Manager()->updateFriendInfo(info, index);
mInfos[index].attr.fdId = fdId;
memset(mInfos[index].attr.name, 0, sizeof(mInfos[index].attr.name));
wcsncpy((wchar_t*)getInfo(index).attr.name, name, 10);
System::getNwc24Manager()->updateFriendInfo(&getInfo(index), index);
}
void FriendListCache::del(u32 index) {

View File

@@ -521,7 +521,8 @@ void ipl::scene::AddressEdit::create() {
set_textbox(textPane, friendText);
textPane = (mpCodeLayout)
->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true);
set_textbox(textPane, mString.mDisplayText);
friendText = mString.mDisplayText;
set_textbox(textPane, friendText);
mState = 0;
break;
}
@@ -2779,7 +2780,7 @@ void ipl::scene::AddressEdit::set_err_msg(wchar_t* outErrMsg, u32 outErrMsgLen,
swprintf(nwc24ErrStr, sizeof(nwc24ErrStr) / sizeof(wchar_t), L"%06d\n", errorCode);
wcsncat(outErrMsg, nwc24ErrStr, outErrMsgLen - wcslen(outErrMsg));
u32 messageId = MESG_ERROR_NWC24_SERVER;
u32 messageId;
switch (nwc24Err) {
case NWC24_ERR_NETWORK:
messageId = MESG_ERROR_NWC24_NETWORK;
@@ -2865,10 +2866,7 @@ void ipl::scene::AddressEdit::get_friendinfo() {
memcpy(&ipl::scene::sFriendInfo, &mpFriendCache->getInfo(mSelectedFriend),
sizeof(ipl::scene::sFriendInfo));
mString.setName(reinterpret_cast<const wchar_t*>(ipl::scene::sFriendInfo.attr.name));
const wchar_t* name = mString.mName;
nw4r::lyt::Pane* namePane =
mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true);
set_textbox(namePane, name);
set_textbox(mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true), mString.mName);
wchar_t wiiNo[0x100];
wchar_t email[0x102];
@@ -2881,10 +2879,7 @@ void ipl::scene::AddressEdit::get_friendinfo() {
ipl::utility::CharacterCode::ANSIToUTF16(email, reinterpret_cast<const u8*>(&ipl::scene::sFriendInfo.addr), 0x102);
mString.setEMail(email);
}
const wchar_t* displayText = mString.mDisplayText;
nw4r::lyt::Pane* friendCodePane =
mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true);
set_textbox(friendCodePane, displayText);
set_textbox(mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true), mString.mDisplayText);
memcpy(&mCreateID, &ipl::scene::sFriendInfo.attr.fdId, sizeof(mCreateID));
}

View File

@@ -1341,13 +1341,11 @@ namespace ipl {
wchar_t* titleName = System::getChannelManager()->getTitleName(
page, channelIndex, 0);
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
u32 nextTitleCount = *titleCount + 1;
*titleCount = nextTitleCount;
++*titleCount;
if (bytes < secondUsage[0] || blocks < secondUsage[1]) {
continue;
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
return true;
}
return true;
}
}
}

View File

@@ -0,0 +1,86 @@
# scene4 leaf — decode attempts & evidence
Branch `agent/w1008/scene4` off origin/main@e3457d11.
Scope: iplAddress, iplAddressEdit, iplSDChannelSelect are the only sub-100 units in
the scene/address + sdChannelSelect remainder (iplAddressAddSel, iplAddressInputName,
iplAddressSelect, addressHelpers, addressInputHelpers, agreeSettings, agreeHttp,
iplFaceSelect, iplNCDSetting all verified already 100% on main; no open PR claims).
## Decodes that landed (this leaf)
### Single-case `switch` produces the `b<eq> caseblock; b after` 2-branch guard
`switch (x) { case C:` emits `cmp; beq caseblock; b exit` — MWCC keeps the
dispatch's second `b` because the case-block is a separate labelled region.
Equivalent `if`, `if||`, `if&&`, `goto`-goto, `if/else`-goto all get normalized
to a single fused `beq`/`bne`. Used in:
- `Address::start_drag_event` (892B): outer `switch (mState) { case STATE_NORMAL:`
+ inner `switch (mMode) { case 0:` reproduces orig's two nested 2-branch guards.
Residual: 7 word diffs, pure regname — nigaoe web pinned r26 (orig) vs r29
(mine), miiPane web r29 vs r26. Allocator home-order tie; decl-hoist of
miiPane above the `if` was a no-op (web homes unchanged).
- `Address::onEventDerived` (1080B): TRIG case falls through to ON_POINT
(orig has NO `break`); the `mState == COVER_NORMAL || mState == NORMAL`
guard folds to `beq`+`bne` inside the TRIG case. Residual: 81 word diffs,
all regname — insn sequence identical.
### `addic.` fusion for `ptr = base + const` NULL-tested members
`record->attr.name` tested `!= 0` fuses into `addic.` only when the pointer is
materialized lazily at the compare — decl the local inside the `if`. Hoisted
decls emit `addi`+`cmpwi`. (movePane_onDrag `name` web.)
## Walls re-verified (evidence)
### `Address::movePane_onDrag` 92.45 (620 orig vs 612 mine)
- Orig emits `bne next; b exit` 2-branch guards for both `textBox != NULL` and
`name != NULL` (the `b` skips to the shared `width += 0.01f` block).
- This is switch-dispatch-shaped, but every legal polarity fails:
`switch(ptr) { case NULL: break; default: body }` bool-materializes
(`addic/subfe/cmpwi 1` — +3 insns); `switch (p != NULL) { case true:` also
bool-materializes; `do { if (!x) break; } while (0)` folds to single `beq`.
- Orig computes the record math (`lwz 0x70 / mulli 5 / lwz 0x274 / mulli 0x140`)
before the textBox branch — scheduler interleave around the guard.
- Residual also regname r27↔r29 (textBox web) + loop `name` web.
### `FriendListCache::update` 95.5 (160 orig vs 156 mine)
Orig remats `mInfos + index*0x140` per use site (memset, wcsncpy,
updateFriendInfo = 3 `mulli`+`add` pairs). Mine CSEs into callee r31.
`getInfo(index)` vs `mInfos[index]` vs `(int)index` cast — all VN-identical,
still CSE. Remat-vs-pin in the unusual remat-is-orig direction; no lever.
### `AddressEdit::create` 97.45 (3280B)
Two distinct residuals:
- Wholesale r30↔r31 web-order swap: orig pins string-table const web in r31
and `boardFile` (getScene+0xd20) in r30; mine the reverse. Webs born in the
same source order — allocator processing order tie.
- `friendText` (this+0x2b4 / this+0x2cc) pin: orig materializes
`addi r25, r29, 0x2b4` at decl point between `initFrame()` and `restart()`,
reassigns `addi r25, r29, 0x2cc` mid-block — the reg+const web is pinned.
Mine remats `addi r5, r29, 0x2b4` at each marshal. Variants tried: non-const
`wchar_t*`, decl moved before `animator =` — both no-op. Same this+const
pin family as get_friendinfo.
### `AddressEdit::get_friendinfo` 88.04 (336 orig vs 328 mine)
Orig: this→r28, `this+0x2b4` (mName) pinned in r29 materialized before the
FindPaneByName marshal — 2 extra insns vs mine's marshal-site remats, and one
more callee web (savegpr_28 vs my _29 window differs). Same `this+const`
pin-vs-remat wall as create's friendText.
### `AddressEdit::update_friendinfo` 99.42 (152B)
Single 2-insn scheduling swap: `addi r4,r30,0x2b4` vs `addi r3,r31,8` order
in the wcsncpy marshal.
### iplSDChannelSelect 99.58 — 7 fns
- `create` 97.74: regname r29↔r30 swap + marshal interleaves around `bl`s
(scheduler family); insn count equal.
- `collectTitles*` ×4 (97.29–97.83): documented ties — callee-web rotations
around the same ES_GetTitleCount/ES_GetTitles marshal blocks.
- `flushSaveDataAndMountSD` 99.66 (140B): marshal order tie.
- `setChannelScissor` 93.47 (932B): fp/scheduling family (DrawFrame-class).
## Notes
- ndiff.py NORMALIZES register names — "diffs 0" can hide regname-only
diffs. Always confirm with raw byte-compare of `.text` (readelf -sW for
addr/size, -SW for file offset).
- `objdiff-cli diff` is interactive-only (fails headless); use disasm_fn.py
+ byte-compare.