Compare commits

...

5 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
coah
7fac2b91ec decomp: refine MD5 rotation sums and word consumption (#969) 2026-10-02 17:09:45 -05:00
coah
6456e33a4c decomp: reconstruct AES last-round key cursor (#968) 2026-10-02 17:09:20 -05:00
coah
3244c6d7ff decomp: reconstruct CHANSVm opcode-local error paths (#967) 2026-10-02 16:59:59 -05:00
coah
b2089fbdba decomp: reconstruct alpha restriction gates and suffix fallback (#966) 2026-10-02 16:53:19 -05:00
12 changed files with 467 additions and 110 deletions

View File

@@ -1068,7 +1068,7 @@ filterVowelCandidate:
(((ZiAlphaWork*)workData)->requiredLength != parameters->elementCount)) &&
(((((ZiAlphaWork*)workData)->prefixLength == '\0' ||
(((ZiAlphaWork*)workData)->prefixLength + 1 >= parameters->elementCount)) && (dictionaryExact != 0)))
))) && ((((completionAllowed && (prefixCount == 0)) && (dictionaryKind != 0xb)) &&
))) && ((((currentVowelRestriction && (prefixCount == 0)) && (dictionaryKind != 0xb)) &&
((((int)dictionaryIndex < (int)(unsigned int)((ZiAlphaWork*)workData)->dictionaryCount &&
(((ZiAlphaOptions*)optionData)->lookupMode == '\0')) &&
(((ZiAlphaWork*)workData)->dictionaries[language] == 0)))))) {
@@ -1084,7 +1084,7 @@ filterVowelCandidate:
goto retryDictionary;
}
}
if ((((((dictionaryExact == 0) || (!completionAllowed)) || (prefixCount != 0)) ||
if ((((((dictionaryExact == 0) || (!currentVowelRestriction)) || (prefixCount != 0)) ||
((dictionaryKind == 0xb ||
(dictionaryIndex >= ((ZiAlphaWork*)workData)->dictionaryCount)))) ||
(elements == 0)) ||
@@ -1367,7 +1367,7 @@ emitCandidate:
}
}
retryDictionary:;
} while (dictionaryKind != 0);
} while (dictionaryIndex != 0);
}
finishDictionaryPass:;
}
@@ -1406,13 +1406,13 @@ finishDictionaryPass:;
secondLanguagePass = ZI8_TRUE;
languagePassCount = 0;
language = parameters->subLanguage;
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
dictionaryStatus[9] = 0;
dictionaryStatus[5] = 0;
dictionaryStatus[6] = 0;
dictionaryStatus[7] = 0;
dictionaryStatus[8] = 0;
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
if (switchedLanguage) {
secondLanguagePass = ZI8_FALSE;
dictionaryStatus[1] = 0;
@@ -1426,14 +1426,15 @@ finishDictionaryPass:;
if (language == 0) {
language = parameters->language;
}
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
if (language == parameters->language) {
completionAllowed = primaryCompletionAllowed;
currentVowelRestriction = primaryVowelRestriction;
} else {
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
}
if ((((ZiAlphaOptions*)optionData)->lookupMode != '\0') || ((!currentVowelRestriction && (!completionAllowed)))) goto finishCandidates;
if ((completionAllowed) &&
if ((((ZiAlphaOptions*)optionData)->lookupMode != '\0') || ((!completionAllowed && (!currentVowelRestriction)))) goto finishCandidates;
if ((currentVowelRestriction) &&
((((((ZiAlphaWork*)workData)->suffixMode == '\0' && (2 < (int)elementCount)) &&
(elements[elementCount - 2] == 0xeff1)) &&
((int)((ZiAlphaWork*)workData)->prefixCount == elementCount - 2)))) {
@@ -1444,66 +1445,65 @@ finishDictionaryPass:;
prefixPrepared = ZI8_TRUE;
goto preparePrefix;
}
if (!((((completionAllowed) && (((ZiAlphaWork*)workData)->suffixMode != '\0')) &&
((((ZiAlphaWork*)workData)->suffixLocked == '\0' && (2 < (int)elementCount)))) &&
(((elements[elementCount - 2] == 0xeff1 &&
((int)((ZiAlphaWork*)workData)->suffixCount == elementCount - 2)) ||
(((int)((ZiAlphaWork*)workData)->suffixCount == elementCount - 1 &&
((Zi8IsAlphaPunct(elements[elementCount - 1])) != '\0'))))))) {
tryAlternatePrefix:
if ((prefixPrepared) && (1 < ((ZiAlphaWork*)workData)->alternatePrefixCount)) {
if (language == parameters->language) {
if (primaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
}
else if (secondaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
if (((ZiAlphaWork*)workData)->alternatePrefixCount != '\0') {
if (currentVowelRestriction && ((ZiAlphaWork*)workData)->suffixMode != 0 &&
((ZiAlphaWork*)workData)->suffixLocked == 0 && elementCount > 2 &&
((elements[elementCount - 2] == 0xEFF1 &&
((ZiAlphaWork*)workData)->suffixCount == elementCount - 2) ||
(((ZiAlphaWork*)workData)->suffixCount == elementCount - 1 &&
Zi8IsAlphaPunct(elements[elementCount - 1]) != 0))) {
if (((ZiAlphaWork*)workData)->prefixEnabled >= 1 && elements[elementCount - 1] == 0xEFF1) {
goto checkPrefixPunctuation;
}
if (!primaryMatched && !secondaryMatched) {
((ZiAlphaWork*)workData)->suffixLocked = 1;
((ZiAlphaWork*)workData)->suffixElementCount = parameters->elementCount - 1;
if (prefixCount != 0) {
wordCursor -= prefixCount;
elements -= prefixCount;
elementCount = elementCount + prefixCount;
wordCapacity = wordCapacity + prefixCount;
prefixCount = 0;
prefixPrepared = ZI8_FALSE;
((ZiAlphaWork*)workData)->suffixMode = 0;
((ZiAlphaWork*)workData)->suffixLocked = 0;
((ZiAlphaWork*)workData)->suffixCount = 0;
for (index = 0; index < (int)(unsigned int)((ZiAlphaWork*)workData)->alternatePrefixCount; index = index + 1) {
((ZiAlphaWork*)workData)->prefix[index] =
((ZiAlphaWork*)workData)->alternatePrefix[index];
}
((ZiAlphaWork*)workData)->prefixCount = (ziU8)index;
if (((ZiAlphaWork*)workData)->language == parameters->language) {
((ZiAlphaWork*)workData)->language = parameters->subLanguage;
}
else {
((ZiAlphaWork*)workData)->language = parameters->language;
}
}
goto preparePrefix;
}
}
if ((prefixPrepared) && (1 < ((ZiAlphaWork*)workData)->alternatePrefixCount)) {
if (language == parameters->language) {
if (primaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
}
if ((((primaryMatched) && (secondaryMatched)) || (elementCount == 0)) ||
(((language == parameters->language && (primaryMatched)) || ((language == parameters->subLanguage && (secondaryMatched))))))
goto finishCandidates;
if (completionAllowed) goto checkPrefixPunctuation;
} else {
if ((((ZiAlphaWork*)workData)->prefixEnabled == '\0') || (elements[elementCount - 1] != 0xeff1)) {
if ((!primaryMatched) && (!secondaryMatched)) {
((ZiAlphaWork*)workData)->suffixLocked = 1;
((ZiAlphaWork*)workData)->suffixElementCount = parameters->elementCount - 1;
if (prefixCount != 0) {
wordCursor -= prefixCount;
elements -= prefixCount;
elementCount = elementCount + prefixCount;
wordCapacity = wordCapacity + prefixCount;
prefixCount = 0;
}
goto preparePrefix;
}
goto tryAlternatePrefix;
else if (secondaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
if (((ZiAlphaWork*)workData)->alternatePrefixCount != '\0') {
wordCursor -= prefixCount;
elements -= prefixCount;
elementCount = elementCount + prefixCount;
wordCapacity = wordCapacity + prefixCount;
prefixCount = 0;
prefixPrepared = ZI8_FALSE;
((ZiAlphaWork*)workData)->suffixMode = 0;
((ZiAlphaWork*)workData)->suffixLocked = 0;
((ZiAlphaWork*)workData)->suffixCount = 0;
for (index = 0; index < (int)(unsigned int)((ZiAlphaWork*)workData)->alternatePrefixCount; index = index + 1) {
((ZiAlphaWork*)workData)->prefix[index] =
((ZiAlphaWork*)workData)->alternatePrefix[index];
}
((ZiAlphaWork*)workData)->prefixCount = (ziU8)index;
if (((ZiAlphaWork*)workData)->language == parameters->language) {
((ZiAlphaWork*)workData)->language = parameters->subLanguage;
}
else {
((ZiAlphaWork*)workData)->language = parameters->language;
}
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
}
if ((((primaryMatched) && (secondaryMatched)) || (elementCount == 0)) ||
(((language == parameters->language && (primaryMatched)) || ((language == parameters->subLanguage && (secondaryMatched))))))
goto finishCandidates;
if (currentVowelRestriction) {
checkPrefixPunctuation:
if ((1 < ((ZiAlphaWork*)workData)->prefixEnabled) &&
(parameters->elements[parameters->elementCount - 1] != 0xEFF1))

View File

@@ -197,8 +197,9 @@ void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
u32 rounds=context->rounds;
u32* key=context->keys + rounds*4;
u32* key=context->keys;
u32 a,b,c,d;
key += rounds*4;
if (context->needsTransform) {
u32 round;
for (round=1; round<context->rounds; ++round) {

View File

@@ -72,7 +72,7 @@ static inline u32 rotateSum(u32 state, const u32* word, u32 constant, int shift)
// Each rotation half reads its own byte-reversed message word.
u32 right = __lwbrx((void*)word, 0);
u32 left = __lwbrx((void*)word, 0);
return ((state + (left + constant)) << shift) | ((right + (constant + state)) >> (32 - shift));
return ((state + (constant + left)) << shift) | ((constant + (state + right)) >> (32 - shift));
}
#define STEP(a, b, c, d, f, word, n) ((a) = (b) + rotateSum((a) + (f), word, *constant, n))
@@ -90,10 +90,10 @@ static void ProcessBlock(NETMD5Context* context) {
word = block;
constant = constants;
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,(b & c) | (~b & d),word,7); ++word; ++constant;
STEP(d,a,b,c,(a & b) | (~a & c),word,12); ++word; ++constant;
STEP(c,d,a,b,(d & a) | (~d & b),word,17); ++word; ++constant;
STEP(b,c,d,a,(c & d) | (~c & a),word,22); ++word; ++constant;
STEP(a,b,c,d,(b & c) | (~b & d),word++,7); ++constant;
STEP(d,a,b,c,(a & b) | (~a & c),word++,12); ++constant;
STEP(c,d,a,b,(d & a) | (~d & b),word++,17); ++constant;
STEP(b,c,d,a,(c & d) | (~c & a),word++,22); ++constant;
}
index = indices;
for (round = 0; round < 4; ++round) {

View File

@@ -7441,8 +7441,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
}
if (leftOp == vmNull || rightOp == vmNull) {
result = CHANS_VM_ERR_RESULT_TYPE;
break;
return CHANS_VM_ERR_RESULT_TYPE;
}
result = opFunc(vm, convTypeIdx, &pVm->accumulator, leftOp, rightOp);
@@ -7882,8 +7881,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
computedAddr += pVm->pActiveCtx->pc + 5;
}
if (computedAddr < 1 || computedAddr >= pVm->pActiveCtx->pDbg->codeSize) {
result = CHANS_VM_ERR_CODE_RANGE;
break;
return CHANS_VM_ERR_CODE_RANGE;
}
pVm->pActiveCtx->pc = computedAddr;
opSize = 0;
@@ -7931,8 +7929,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
computedAddr += pVm->pActiveCtx->pc + 4;
}
if (computedAddr < 1 || computedAddr >= pVm->pActiveCtx->pDbg->codeSize) {
result = CHANS_VM_ERR_CODE_RANGE;
break;
return CHANS_VM_ERR_CODE_RANGE;
}
pVm->pActiveCtx->pc = computedAddr;
opSize = 0;
@@ -7957,11 +7954,13 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
}
case CHANS_VM_OP_DELETE_INDIRECT: {
result = CHANS_VM_ERR_DELETE_INDIRECT;
if (pVm->accumulator.type == CHANS_VM_TYPE_INDEX_REF) {
foundObj = VmGetArrayElement(vm, &pVm->accumulator, *((u32*)&pVm->accumulator.value + 1), vmFalse);
result = VmDeleteCommon(vm, foundObj);
CHANSVmObjHdr* accumulator = &pVm->accumulator;
CHANSVmErr deleteResult = CHANS_VM_ERR_DELETE_INDIRECT;
if (accumulator->type == CHANS_VM_TYPE_INDEX_REF) {
foundObj = VmGetArrayElement(vm, accumulator, accumulator->value.data.len, vmFalse);
deleteResult = VmDeleteCommon(vm, foundObj);
}
result = deleteResult;
break;
}

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,49 @@
# CHANSVm opcode error-path reconstruction
Baseline: 2f399716. This is a separate structural-reconstruction candidate; it preserves the preceding LOAD_STRING_CONST behavior fix. Only CHANSVm.c changed apart from this log. No headers, linking flags, remote branches, or original assets were changed.
## Retained changes and target evidence
- Failed binary-operand conversion returns CHANS_VM_ERR_RESULT_TYPE directly. Target Step relative +0x410 selects the error and +0x414 returns through +0x1364.
- Invalid GET_PROPERTY_NAME and JUMP destinations return CHANS_VM_ERR_CODE_RANGE directly. Target error tails are +0xd90/+0xd94 and +0xefc/+0xf00, respectively, both ending at +0x1364.
- DELETE_INDIRECT has a typed accumulator and a local deletion result, and reads the index through value.data.len rather than an offset-based u32 pointer cast. SET_INDEX elsewhere in the same function establishes this field as the index-reference index. The target holds the opcode-local result until the merge at +0xfb0, then assigns the common interpreter status. The rebuilt +0xf80 through +0xfb4 block is instruction-identical to the target.
These preserve existing C behavior. Unlike the preceding deletion-error fix, no new behavioral defect is claimed.
## Measurements
- Exact functions: 221/233 -> 221/233. Every previously exact function remains instruction-exact, not merely objdiff-exact.
- Decompiled/fuzzy unit: 99.383840% -> 99.406320%.
- CHANSVmStep: 96.673584% -> 96.913800%; 1253/1253 instructions; differing positions 297 -> 285.
- Exact code: unchanged, 37608/53564 bytes (70.211334%).
- Exact data: unchanged, 6904/6904 bytes (100%).
- Per-function score regressions: zero.
- Unit remains NonMatching/unlinked; twelve functions remain non-exact.
## Rejected investigations
All rejected source changes were restored, and no register forcing or declaration-order sweep was used.
- GET_PROPERTY_NAME output-state separation: a local found flag, initialized flag, shared index/output, and inline helper. These produced 1251-1253 instructions but moved generated data-table destinations; rejected.
- Direct result-type-table accesses, an explicit zero-count normalization/pretested loop, and indexed operand-type enumeration: 1254-1257 instructions; generated data-table destinations moved; rejected.
- Internal linkage for result-type or constant-header tables, individually and together, did not change those results; restored.
- CASE strict-comparison result separation, case-local match state, byte-sized operand types, and indexed operand enumeration: improved some local structure but introduced an operand-type spill and 1254-1255 instructions; generated tables moved; rejected.
- Direct exceptional returns alone: retained for combination, 96.697525%, data 100%.
- Typed DELETE_INDIRECT and local result alone: retained for combination, 96.889860%, data 100%.
- Combined direct returns and typed deletion result: accepted candidate, 96.913800%, data 100%.
- A first combination script used an obsolete substring end offset and did not compile; restored, corrected, and rerun. No source from the malformed attempt remains.
- Adding strict-comparison restructuring to the retained combination still produced 1254 instructions and data regression; rejected.
## Validation
- Full 43U build passed with the assigned wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
- pool_diff: 125/125 strings identical.
- .data: 4672/4672 raw bytes and 352/352 canonical relocations identical.
- .rodata: 1432/1432 raw bytes and 258/258 canonical relocations identical.
- All 233 target functions compared: 221 instruction-exact; zero falsely exact objdiff functions; zero per-function score regressions from 2f399716.
- Narrow-string-reference audit: all 233 functions analyzed, 40 arguments checked, no candidates/errors/skips.
- Source-extracted host C tests: four DELETE_INDIRECT cases passed (wrong type, successful deletion, deletion failure, and null element forwarding), including exact unsigned index forwarding. The six prior LOAD_STRING_CONST cases also passed unchanged. These stub surrounding VM dependencies and are not Wii runtime tests.
- git diff --check passed.
The focused candidate is paused for independent parent review.

View File

@@ -0,0 +1,78 @@
# AES key-schedule cursor reconstruction, 2026-10-02
Source baseline: `449529d9`. This separate candidate follows the frozen MD5
commit `521056a9`; it changes only `libs/RevoEX/src/net/aes.c` and this log.
43U only. No linking flags, configuration, tables, or public API edits.
## Target evidence and retained change
`AESiDecryptBlock` in `build/43U/obj/libs/RevoEX/src/net/aes.o` is 0x3EC bytes /
251 instructions. Its entry first forms the key-schedule base at context+0x10
(function-relative offset 0x18), extracts the last-round offset from the flags
word (offset 0x24), and adds that offset to the already formed base (offset
0x28). The baseline combined initializer produced 249 instructions. Explicitly
initializing the typed key pointer to `context->keys` before advancing it by
`rounds*4` recovers the target's two-stage pointer construction and body size.
The retained change is two added source lines and one removed line. All AES
round expressions, lazy inverse key transformation, tables and CBC chaining
remain unchanged.
This is a structural matching improvement, not a newly implemented AES path.
Both existing block algorithms were already present and pass the behavior tests.
## Explored and rejected alternatives
- Inlined single-word round helpers, byte-typed table lookups and table-rotation
helpers changed scheduling but regressed encryption or added source complexity.
- Staging four inverse-mix column outputs through a typed round helper improved
decrypt similarity but required substantially more source and still did not
match. Not retained.
- Alternate inverse-key-transform local lifetimes and an inverse-key helper
gave only small extra fuzzy movement, without new algorithm reconstruction.
- Context-relative key indexing and row/word loop variants did not improve the
minimal key-base candidate.
- Moving next-state locals outside the round loop did not change codegen.
- Reordering key-base declarations produced a negligible score change; the
original natural declaration order was kept.
- Two exploratory C89-incompatible mixed-declaration variants failed to compile
and were immediately discarded. No failed source is retained.
## Verification
Before -> after:
- AESiDecryptBlock: 249 -> 251 instructions against target 251;
fuzzy 61.49004 -> 63.836655%. Final ctxdiff: 224 positional differences.
- AESiEncryptBlock: unchanged, 158/158 instructions and 60.348103% fuzzy.
- Unit fuzzy: 76.844475 -> 77.700584%.
- Exact functions: 7/9 -> 7/9. Exact code: 1116/2752 bytes unchanged.
- Data: objdiff 2800/2800, 100%, unchanged. Linked status unchanged.
- All seven exact functions have ctxdiff diffs 0: NETAESCreateEx 108/108,
NETAESCreate 2/2, NETAESDelete 1/1, NETAESEncrypt 46/46, NETAESDecrypt 46/46,
NETiAESEncryptoBlock 39/39, NETiAESDecryptoBlock 37/37.
- String pool: all four strings identical.
- .rodata: 2592 identical bytes; .sdata2: 8 identical bytes. Source .data is
197 bytes with the same prefix as the 200-byte target section; three target
alignment bytes are an existing extent difference. No padding was added.
- The full 1027-unit report has no regressions in exact functions/code/data or
fuzzy score against the baseline report. Frozen MD5 metrics are unchanged.
- Full 43U build passed with the configured wibo wrapper; build/43U/ok passed.
DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
Host validation: `python3 /tmp/crypto-remainder/validate_aes.py` compiles the
production C unchanged with minimal types/OSReport shims. Input, key and IV
words are represented with their PPC big-endian numeric values, so native host
byte order does not change the algorithm. Known-answer tests cover AES-128,
AES-192 and AES-256; seeded randomized CBC tests compare against cryptography's
AES implementation for all three key sizes. Each tests separate/in-place
buffers and single/incremental calls.
Result: all 2,406 production-source known-answer/randomized checks passed. The
original baseline had independently passed the same coverage before changes.
A separate saved helper experiment also passed but is not part of this commit.
Local evidence, not committed or uploaded: `/tmp/crypto-remainder/aes-final.ctx`,
`aes-final.json`, `aes-full-build.log`, `aes-vectors.log`, `aes-decrypt.target`,
and `validate_aes.py` plus its header shims. No retail assembly is included.
GATE: validated partial structural candidate; no regressions. Exact matching
and linking remain open.

View File

@@ -0,0 +1,89 @@
# eZiText remainder reconstruction, 2026-10-02
Base: `449529d9`; branch `agent/bittle/allhands-ezi-decompile`.
Only 43U was configured, using `../toolchain/wibo-build/wibo` and
`WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja`. No linking flags, shared
headers, remote refs, or upstream resources were changed.
## Baseline and first candidate: alpha engine
Fresh baseline report: `/tmp/ezi-baseline.json`.
`zi8alpha`: 11/12 exact functions, 5880/21664 exact code bytes,
516/564 exact data bytes; unit fuzzy 94.17892%.
`Zi8AlphaGetCandidates`: 3946/3946 instructions, function fuzzy 92.01039%.
These function and unit percentages are deliberately distinguished.
The scalar layout is four bytes lower in source than in the target because
of the target's existing workspace snapshot at stack 0x20. No dummy alias,
padding, or unused local was added to occupy that slot.
Six semantic corrections were established from definitions and uses, not
from equal-looking raw offsets:
- The flag initialized at target stack 0x84 is the current vowel/punctuation
restriction. At function +0x0798, the table-31 flag test for bit 4 clears
target 0x84 and its primary-language snapshot at 0x8C. Source uses 0x80
and 0x88 for those same definitions.
- The different completion flag is at target 0x88. The table-31 bit-2 test
at +0x07C8 clears target 0x88 and primary snapshot 0x90. Its source slots
are 0x84 and 0x8C. Language-pass restoration confirms both identities.
- Target reads of 0x84 at +0x2114, +0x2214, +0x32F4, +0x3384 and +0x3664
gate punctuation retries, suffix activation, suffix locking and prefix
punctuation. The source incorrectly read the completion flag in all five
places. The candidate uses the traced current-restriction variable.
- At +0x1430 the target loads the dictionary-order index from 0x64, uses it
to select a byte dictionary kind, and stores that kind at 0x60. The retry
condition at +0x3060 reads 0x64, also used by the following outer-loop
increment. Source incorrectly tested dictionaryKind; it now tests
dictionaryIndex. The safe existing early dictionaryIndex initialization
was preserved.
The isolated six-line semantic patch is preserved at
`/tmp/ezi-alpha-six-conditions.patch`. Alone it gives function 92.009125%,
unit 94.17799%, with code/data/exact counts unchanged. This tiny fuzzy
fluctuation does not invalidate the traced variable corrections.
The first handed-off candidate also restores the original address-order
suffix-lock block before alternate-prefix fallback, restores positive branch
conditions, and places each language's restriction snapshots at its actual
control-flow position. No helper prototype change is included in this first
candidate.
First-candidate fresh report: `/tmp/ezi-alpha-minimal.json`.
`Zi8AlphaGetCandidates`: 94.47314%, 3946/3946 instructions.
Unit fuzzy: 94.17892% -> 95.97323% (about 389 fewer weighted deficit bytes).
Exact functions: 11/12 -> 11/12. Exact code: 5880 -> 5880 bytes.
Exact data: 516 -> 516 bytes. All non-text section scores are unchanged.
Both pools contain no strings and compare identical.
## Separate later research, not part of the first candidate
- Further emission/cursor/comparison/switch reconstruction reached function
95.63913%, unit 96.82275%, 3950/3946 instructions. Existing exact functions
remain exact, but extabindex accounting drops by 108 bytes. Preserved at
`/tmp/ezi-alpha-deliver.c`; not included in the first candidate.
- Matching PUD return declarations to zi8pud2.c's ziU32 definitions, with
explicit caller byte narrowing, leaves alpha's score unchanged but moves
one-key candidates 95.39716% -> 95.32416%. Its 5 exact functions and data
1280/1388 remain unchanged. Held separately for ABI review.
- Matching Chinese Zi8GetPCode to zi8match.c's ziU16 definition restores the
two target halfword narrowings in paired-phonetic lookup. Together with the
explicit PUD ABI correction: engine 96.27482% -> 96.492134%, unit
96.65468% -> 96.848755%, 10678/10676 instructions, 5 exact unchanged.
extabindex accounting drops 72 bytes. Held for section/relocation audit.
- Splitting the Chinese component cursor/table chained assignment reproduces
the target's intermediate reload but lowers the engine to 96.090294%;
rejected and restored.
- Replacing the spelling candidate-count assignment with postfix increment
lowers spelling 99.555885% -> 96.8%; rejected and restored.
The larger scratch candidate's branch-destination audit found no mapped
branch-target differences over 720 alpha, 351 one-key and 1594 Chinese
branches. Helper-call counts are respectively 73/73, 71/71 and 168/168.
This audit ignores register choices and accounts for the known stack shift;
it is evidence of control-flow coverage, not a claim of exact matching.
First-candidate validation: full 43U build succeeds; DOL SHA1 is
`26116613f624061ba99c8d1a299aaa6efa85670d`. Every one of the 11 baseline
exact alpha functions has identical instruction counts and ctxdiff diffs 0.
`git diff --check` succeeds. No new exact function or complete unit is claimed.

View File

@@ -0,0 +1,62 @@
# MD5 unsigned arithmetic and cursor reconstruction, 2026-10-02
Separate follow-on to accepted MD5 commit `521056a9`. AES commit `2a537c14`
and both prior logs are unchanged. Only 43U was configured or built.
## Target-grounded changes
The target ProcessBlock rotation halves retain independently grouped additions
of the unsigned state, round constant and separately byte-reversed message
words. Reassociating those three u32 operands inside the accepted helper brings
the compiler's data-flow closer to the target while preserving modulo-2^32
arithmetic. The first MD5 round consumes sequential message words; expressing
that consumption with `word++` as the helper's pointer argument improves its
schedule. STEP evaluates this pointer argument exactly once; the helper still
uses that captured pointer for both byte-reversed reads. No evaluation-order
ambiguity, extra read, undefined value, or new helper is introduced.
Experiments enumerated 144 valid addition operand/grouping combinations for
the two halves. The best target-sized arithmetic expression reached 93.447716%
ProcessBlock fuzzy. Five cursor/loop variants and eight independent cursor-
consumption combinations then identified the minimal `word++` form, reaching
94.30719%. A larger by-reference cursor helper reached 94.98366% but duplicated
rotation code for a small gain and was rejected. Three explicit feed-forward
variants did not improve the retained result. No declaration/register sweep,
assembly, volatile qualifier, padding or linking change was used.
## Verification
Accepted MD5 -> this candidate:
- ProcessBlock: 81.82026 -> 94.30719% fuzzy; 306/306 instructions unchanged.
- Unit fuzzy: 87.80044 -> 96.179825%.
- Exact functions 3/4 and exact code 600/1824 are unchanged.
- Data 456/456 (100%) and linking status are unchanged.
- NETMD5Init 16/16, NETMD5Update 60/60 and NETMD5GetDigest 74/74 still have
ctxdiff diffs 0 and objdiff 100%.
- ProcessBlock has 215 positional differences. An advisory comparison that
ignores GPR names leaves five opcode/immediate-order differences: three
sequential cursor offsets and two final state-load positions. This is not
an exact match or a proof that every remaining difference is register-only.
- Empty string pools remain identical. Constants/index tables and end-marker
data are unchanged from the accepted candidate.
- AES metrics and source are unchanged from commit 2a537c14.
- Full 1027-unit report: zero exact-function/code/data/fuzzy regressions versus
baseline449529d9; additionally both owned units preserve the immediately
preceding candidate's exact/data scores and improve or preserve fuzzy scores.
- Full 43U build and build/43U/ok passed. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
All 3,088 MD5 known-answer/random/chunking comparisons passed again against
Python hashlib. Run `python3 /tmp/crypto-remainder/validate_md5.py`. The test
compiles production C unchanged with PPC intrinsic shims, supplies RFC1321
padding externally, and exercises ProcessBlock through NETMD5Update. The
instruction-exact GetDigest platform-endian stores are not host-tested.
Local evidence (not committed/uploaded): `/tmp/crypto-remainder/` contains
`md5.grouping-results.json`, `md5-grouping-final.json`,
`md5-grouping-ProcessBlock.ctx`, `md5-grouping-vectors.log`, and
`md5-grouping-full-build.log`. Original target evidence remains in the local
split object and disassembly; no retail assembly is included in this commit.
GATE: validated partial structural candidate; no regressions. Exact matching
and linking remain open.

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.