From 4bd8fc59e93ac21da0a83c1dd11501cd6ae7f7f2 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Thu, 8 Oct 2026 19:46:01 +0000 Subject: [PATCH] decomp: match WithZi::update and DeleteUnauthorizedData; link tiZiString and iplESMisc (worker adf0d9ee) --- configure.py | 4 +- src/keyboard/tiZiString.cpp | 90 +++--- src/utility/iplESMisc.cpp | 83 ++++-- tools/decomp-assist/sol-ties.attempts.md | 360 +++++++++++++++++++++++ 4 files changed, 466 insertions(+), 71 deletions(-) create mode 100644 tools/decomp-assist/sol-ties.attempts.md diff --git a/configure.py b/configure.py index 96e2980a..0137232a 100644 --- a/configure.py +++ b/configure.py @@ -678,7 +678,7 @@ config.libs = [ Object(Matching, "utility/iplThread.cpp"), Object(Matching, "utility/iplMessageBase.cpp"), Object(Matching, "utility/iplJpegDecoder.cpp"), - Object(NonMatching, "utility/iplESMisc.cpp"), + Object(Matching, "utility/iplESMisc.cpp"), Object(Matching, "utility/iplCSFlags.cpp"), ] ), @@ -917,7 +917,7 @@ config.libs = [ Object(Matching, "keyboard/tiSignWindow.cpp", extra_cflags=["-O4,p"]), Object(NonMatching, "keyboard/tiString.cpp", extra_cflags=["-O4,p"]), Object(NonMatching, "keyboard/tiAtokString.cpp", extra_cflags=["-O4,p"]), # for 4.3J - Object(NonMatching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E + Object(Matching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E Object(Matching, "keyboard/tiTextDrawer.cpp", extra_cflags=["-O4,p"]), Object(Matching, "keyboard/tiNw4rManager.cpp", extra_cflags=["-O4,p"]), Object(Matching, "keyboard/tiKeyboard.cpp", extra_cflags=["-O4,p"]), diff --git a/src/keyboard/tiZiString.cpp b/src/keyboard/tiZiString.cpp index 920696db..3af5d1d7 100644 --- a/src/keyboard/tiZiString.cpp +++ b/src/keyboard/tiZiString.cpp @@ -295,13 +295,40 @@ confirmLetters: update(); } +static inline void CopyWordSuffix(u16* word, u32 length) { + u32 wordLength; + u32 copied; + wordLength = wcslen((wchar_t*)word) & 0xff; + for (copied = 0; copied < length; ++copied) { + word[copied] = word[(wordLength - length) + copied]; + } + word[copied] = 0; +} + void WithZi::update() { + u16* koreanOutput; + u16* keyOutput; + wchar_t* candidateOutput; + u16* destination; + u32 copyLength; + u16 keyCharacter; + u16* wordOutput; + u16* letter; + u32 count; + s32 elementCount; + u16* source; + s32 keyIndex; + s32 position; + s32 candidateLength; + u16 character; + s32 index; + if (mbDictionaryOpen == 0) { return; } mSelectedCandidate = 0; - s32 elementCount = static_cast(setElementBuffer()); + elementCount = static_cast(setElementBuffer()); mSearch.language = getPredictLanguage(); mSearch.subLanguage = 7; mSearch.getMode = 0; @@ -339,24 +366,23 @@ void WithZi::update() { CandidatedWord[0] = L'>'; CandidatedWord[1] = 0; mCandidateCount = 1; - u16* output = CandidatedWord + 0x40; - for (s32 keyIndex = 1; keyIndex < 16; ++keyIndex) { - u16 candidate = static_cast(mpHoldingKey)->wc[keyIndex - 1]; - if (candidate != 0) { - output[0] = candidate; - output[1] = 0; + keyOutput = CandidatedWord; + for (keyIndex = 1; keyIndex < 16; ++keyIndex) { + keyCharacter = static_cast(mpHoldingKey)->wc[keyIndex - 1]; + if (keyCharacter != 0) { + keyOutput[keyIndex * 0x40] = keyCharacter; + keyOutput[keyIndex * 0x40 + 1] = 0; ++mCandidateCount; } - output += 0x40; } EZTXGetCandidates(&mSearch, mpDictionaryWork); } else { memcpy(PredictionBuffer, CandidatesBuffer, 0x200); ChangeDictionaryLanguage(getPredictLanguage()); - u32 count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff; + count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff; if (getPredictLanguage() == ZI8_LANG_ZH && count == 0x61) { - wchar_t* candidateOutput = reinterpret_cast(PredictionBuffer); + candidateOutput = reinterpret_cast(PredictionBuffer); mSearch.firstCandidate = 0x61; mSearch.candidates = candidateOutput + 0xC2; mSearch.maxCandidates = 199; @@ -369,13 +395,8 @@ void WithZi::update() { } if (getPredictLanguage() == ZI8_LANG_ZH && mbContextChanged != 0 && (mbContextChanged = 0, mSearch.count == 0)) { - u32 length = mCurrentWordLength; - u32 wordLength = wcslen((wchar_t*)LatestWord) & 0xff; - u32 copied; - for (copied = 0; copied < length; ++copied) { - LatestWord[copied] = LatestWord[(wordLength - length) + copied]; - } - LatestWord[copied] = 0; + copyLength = mCurrentWordLength; + CopyWordSuffix(LatestWord, copyLength); mSearch.wordCharCount = wcslen((wchar_t*)LatestWord); count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff; } @@ -392,28 +413,25 @@ void WithZi::update() { memset(CandidatedWord, 0, 0x1400); mCandidateCount = 0; if (elementCount != 0 || mSearch.wordCharCount != 0) { - u16* source = reinterpret_cast(mSearch.candidates); - u16* destination = CandidatedWord; - for (s32 index = 0; index < static_cast(count); index++) { + source = reinterpret_cast(mSearch.candidates); + destination = CandidatedWord; + for (index = 0; index < static_cast(count); index++) { if (getPredictLanguage() == ZI8_LANG_ZH) { - u16* output; - s32 length; - length = 0; - output = destination; + candidateLength = 0; + wordOutput = destination; for (; *source != L' ' && *source != 0; source++) { - *output++ = *source; - ++length; + *wordOutput++ = *source; + ++candidateLength; } ++source; - destination[length] = 0; + destination[candidateLength] = 0; } else if (mPredictLanguage == PL_11) { *destination = *source++; destination[1] = 0; } else if (getPredictLanguage() == ZI8_LANG_KO) { - u16* output = destination; - u16 character; + koreanOutput = destination; while ((character = *source) >= 0x100) { - *output++ = character; + *koreanOutput++ = character; ++source; } } else if (EZTXCopy(reinterpret_cast(destination), &mSearch, index & 0xff, mpDictionaryWork) == 0) { @@ -421,20 +439,18 @@ void WithZi::update() { } ++mCandidateCount; { - u16* candidate; - s32 position; position = 0; - for (candidate = destination; *candidate != 0; ++candidate, ++position) { + for (letter = destination; *letter != 0; ++letter, ++position) { switch (mLetterMode) { case LM_1: - *candidate = util::toWLower(*candidate); + *letter = util::toWLower(*letter); break; case LM_2: - *candidate = util::toWUpper(*candidate); + *letter = util::toWUpper(*letter); break; case LM_0: - if (position == 0) *candidate = util::toWUpper(*candidate); - else *candidate = util::toWLower(*candidate); + if (position == 0) *letter = util::toWUpper(*letter); + else *letter = util::toWLower(*letter); break; case LM_3: break; diff --git a/src/utility/iplESMisc.cpp b/src/utility/iplESMisc.cpp index 75295209..39804365 100644 --- a/src/utility/iplESMisc.cpp +++ b/src/utility/iplESMisc.cpp @@ -998,12 +998,24 @@ namespace ipl { return ret; } - static inline void verifySavedataZD(EGG::Heap* heap, ESTitleId titleId, NANDFileInfo* fileInfo) { - char path[NAND_MAX_PATH]; + static inline void verifySavedataZD(EGG::Heap* heap, ESTitleId requestedTitleId, NANDFileInfo* fileInfo) { + ESTitleId titleId; + u32 offset; + u32 j; + BOOL valid; + BOOL fileOpen; + u8* firstBlock; + u8* secondBlock; + BOOL deleteSaveData; s32 ret; - u8* saveData = NULL; - BOOL fileOpen = FALSE; - BOOL deleteSaveData = FALSE; + u8* saveData; + titleId = requestedTitleId; + + char path[NAND_MAX_PATH]; + + saveData = NULL; + fileOpen = FALSE; + deleteSaveData = FALSE; sprintf(path, "/title/%08x/%08x/data/%s", (u32)((titleId & 0x00FFFFFFFFFFFFFFULL) >> 32), (u32)(titleId & 0x00FFFFFFFFFFFFFFULL), "zeldaTp.dat"); if (!ESMisc::ChangeUid(titleId)) { @@ -1030,17 +1042,17 @@ namespace ipl { OSReport("%s::%s: File size is not correct: %d\n", __FILE__, __FUNCTION__, ret); deleteSaveData = TRUE; } else { - u32 offset = 8; - u32 j = 0; - BOOL valid = FALSE; + offset = 8; + valid = FALSE; + j = 0; while (j < 3) { - u8* block = saveData + offset; - if (!checkForNullTermination((char*)block + 0x4e, 8) || - !checkForNullTermination((char*)block + 0x58, 8) || - !checkForNullTermination((char*)block + 0x72, 8) || - !checkForNullTermination((char*)block + 0x8e, 8) || - !checkForNullTermination((char*)block + 0x1b4, 0x11) || - !checkForNullTermination((char*)block + 0x1c5, 0x11)) { + firstBlock = saveData + offset; + if (!checkForNullTermination((char*)firstBlock + 0x4e, 8) || + !checkForNullTermination((char*)firstBlock + 0x58, 8) || + !checkForNullTermination((char*)firstBlock + 0x72, 8) || + !checkForNullTermination((char*)firstBlock + 0x8e, 8) || + !checkForNullTermination((char*)firstBlock + 0x1b4, 0x11) || + !checkForNullTermination((char*)firstBlock + 0x1c5, 0x11)) { goto verify_failed; } j++; @@ -1050,13 +1062,13 @@ namespace ipl { offset = 0x2008; j = 0; while (j < 3) { - u8* block = saveData + offset; - if (!checkForNullTermination((char*)block + 0x4e, 8) || - !checkForNullTermination((char*)block + 0x58, 8) || - !checkForNullTermination((char*)block + 0x72, 8) || - !checkForNullTermination((char*)block + 0x8e, 8) || - !checkForNullTermination((char*)block + 0x1b4, 0x11) || - !checkForNullTermination((char*)block + 0x1c5, 0x11)) { + secondBlock = saveData + offset; + if (!checkForNullTermination((char*)secondBlock + 0x4e, 8) || + !checkForNullTermination((char*)secondBlock + 0x58, 8) || + !checkForNullTermination((char*)secondBlock + 0x72, 8) || + !checkForNullTermination((char*)secondBlock + 0x8e, 8) || + !checkForNullTermination((char*)secondBlock + 0x1b4, 0x11) || + !checkForNullTermination((char*)secondBlock + 0x1c5, 0x11)) { goto verify_failed; } j++; @@ -1093,8 +1105,11 @@ namespace ipl { } static inline s32 DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) { - ESTicketView* ticketViewList = NULL; s32 ret; + u32 j; + ESTicketView* ticketViewList; + ticketViewList = NULL; + memset(ticketViews, 0, OSRoundUp32B(sizeof(ESTicketView))); ret = ES_GetTicketViews(titleId, NULL, ticketViewCount); if (ret != ES_ERR_OK) { @@ -1110,7 +1125,7 @@ namespace ipl { OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId); goto cleanup; } - for (u32 j = 0; j < *ticketViewCount; j++) { + for (j = 0; j < *ticketViewCount; j++) { memcpy(ticketViews, &ticketViewList[j], sizeof(ESTicketView)); ret = ES_DeleteTicket((ESTicketView*)ticketViews); if (ret != ES_ERR_OK) { @@ -1126,12 +1141,16 @@ namespace ipl { } static inline s32 InitSavedata(EGG::Heap* heap) { + u32 i; + s32 ret; + ESTitleId* titleIds; + u8* ticketScratch; u8 ticketViews[OSRoundUp32B(sizeof(ESTicketView))] ALIGN32; NANDFileInfo fileInfo ALIGN32; u32 ticketViewCount; - ESTitleId* titleIds = NULL; + titleIds = NULL; u32 titleCount = 0; - s32 ret = ES_ListTitlesOnCard(NULL, &titleCount); + ret = ES_ListTitlesOnCard(NULL, &titleCount); if (ret != ES_ERR_OK) { OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, __FUNCTION__, ret); @@ -1151,8 +1170,8 @@ namespace ipl { } { - u8* ticketScratch = ticketViews; - for (u32 i = 0; i < titleCount; i++) { + ticketScratch = ticketViews; + for (i = 0; i < titleCount; i++) { if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) { verifySavedataZD(heap, titleIds[i], &fileInfo); continue; @@ -1177,10 +1196,6 @@ namespace ipl { return ret; } - s32 ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) { - return InitSavedata(heap); - } - BOOL checkForNullTermination(char* str, u32 len) { for (u32 i = 0; i < len; i++) { if (*str == 0) { @@ -1191,6 +1206,10 @@ namespace ipl { return FALSE; } + s32 ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) { + return InitSavedata(heap); + } + TMDFile::TMDFile(EGG::Heap* heap) : mpHeap(heap), mbFileOpen(FALSE), mFileLength(0) { memset(&mFile, 0, sizeof(mFile)); } diff --git a/tools/decomp-assist/sol-ties.attempts.md b/tools/decomp-assist/sol-ties.attempts.md new file mode 100644 index 00000000..a091083d --- /dev/null +++ b/tools/decomp-assist/sol-ties.attempts.md @@ -0,0 +1,360 @@ +# sol-ties attempts + +Base 23b77a33, branch agent/w1008/rx1. No source edits initially. +Baseline: update 85/446, DeleteUnauthorizedData 74/449, equal sizes. +Both string pools identical. Tracer requires output beneath _mwdbg; first local-output attempt rejected before compilation. + +ZI1 lift declarations in reverse requested virtual order: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI2 u32 LatestWord[copied] = LatestWord[copied + (wordLength - copyLength)];: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI3 u32 *(LatestWord + copied) = *(LatestWord + wordLength - copyLength + copied);: 215 differing. src size 0x700 base size 0x6f8 + +ZI4 u32 LatestWord[copied] = LatestWord[wordLength + copied - copyLength];: 233 differing. src size 0x744 base size 0x6f8 + +ZI5 u32 LatestWord[copied] = LatestWord[copied - copyLength + wordLength];: 232 differing. src size 0x748 base size 0x6f8 + +ZI6 s32 LatestWord[copied] = LatestWord[copied + (wordLength - copyLength)];: 216 differing. src size 0x6dc base size 0x6f8 + +ZI7 s32 *(LatestWord + copied) = *(LatestWord + wordLength - copyLength + copied);: 216 differing. src size 0x6c0 base size 0x6f8 + +ZI8 s32 LatestWord[copied] = LatestWord[wordLength + copied - copyLength];: 232 differing. src size 0x740 base size 0x6f8 + +ZI9 s32 LatestWord[copied] = LatestWord[copied - copyLength + wordLength];: 226 differing. src size 0x71c base size 0x6f8 + +ZI10 u16 LatestWord[copied] = LatestWord[copied + (wordLength - copyLength)];: 215 differing. src size 0x65c base size 0x6f8 + +ZI11 u16 *(LatestWord + copied) = *(LatestWord + wordLength - copyLength + copied);: 215 differing. src size 0x65c base size 0x6f8 + +ZI12 u16 LatestWord[copied] = LatestWord[wordLength + copied - copyLength];: 217 differing. src size 0x660 base size 0x6f8 + +ZI13 u16 LatestWord[copied] = LatestWord[copied - copyLength + wordLength];: 217 differing. src size 0x660 base size 0x6f8 + +ZI14 int LatestWord[copied] = LatestWord[copied + (wordLength - copyLength)];: 216 differing. src size 0x6dc base size 0x6f8 + +ZI15 int *(LatestWord + copied) = *(LatestWord + wordLength - copyLength + copied);: 216 differing. src size 0x6c0 base size 0x6f8 + +ZI16 int LatestWord[copied] = LatestWord[wordLength + copied - copyLength];: 232 differing. src size 0x740 base size 0x6f8 + +ZI17 int LatestWord[copied] = LatestWord[copied - copyLength + wordLength];: 226 differing. src size 0x71c base size 0x6f8 + +ZI18 copied != copyLength copied++: 216 differing. src size 0x6c0 base size 0x6f8 + +ZI19 copied != copyLength copied += 1: 216 differing. src size 0x6c0 base size 0x6f8 + +ZI20 copied != copyLength copied = copied + 1: 216 differing. src size 0x6c0 base size 0x6f8 + +ZI21 copyLength > copied copied++: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI22 copyLength > copied copied += 1: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI23 copyLength > copied copied = copied + 1: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI24 pointer copy before ++source; ++destination; ++copied: 299 differing. src size 0x6d4 base size 0x6f8 + +ZI25 pointer copy before ++copied; ++destination; ++source: 299 differing. src size 0x6d4 base size 0x6f8 + +ZI26 pointer copy before ++destination; ++source; ++copied: 299 differing. src size 0x6d4 base size 0x6f8 + +ZI27 pointer copy after ++source; ++destination; ++copied: 299 differing. src size 0x6d4 base size 0x6f8 + +ZI28 pointer copy after ++copied; ++destination; ++source: 299 differing. src size 0x6d4 base size 0x6f8 + +ZI29 pointer copy after ++destination; ++source; ++copied: 299 differing. src size 0x6d4 base size 0x6f8 + +ZI30 element type (wchar_t*)LatestWord: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI31 element type (unsigned short*)LatestWord: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI32 swap wordLength copied: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI33 swap copyLength wordLength: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI34 swap copied copyLength: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI35 while copy: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI36 precompute offset: 201 differing. src size 0x6f4 base size 0x6f8 + +ZI37 source base indexing: 216 differing. src size 0x6f0 base size 0x6f8 + +ZI38 typed character temporary u16: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI39 typed character temporary wchar_t: 32 differing. src size 0x6f8 base size 0x6f8 + +ZI40 inline suffix helper u16* word, u32 length, u32 wordLength u32: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI41 inline suffix helper u16* word, u32 length, u32 wordLength void: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI42 inline suffix helper u16* word, u32 wordLength, u32 length u32: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI43 inline suffix helper u16* word, u32 wordLength, u32 length void: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI44 parameter order ('u16* word', 'u32 length', 'u32 wordLength'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI45 parameter order ('u16* word', 'u32 wordLength', 'u32 length'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI46 parameter order ('u32 length', 'u16* word', 'u32 wordLength'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI47 parameter order ('u32 length', 'u32 wordLength', 'u16* word'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI48 parameter order ('u32 wordLength', 'u16* word', 'u32 length'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI49 parameter order ('u32 wordLength', 'u32 length', 'u16* word'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI50 helper copies ('wordLength',): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI51 helper copies ('length',): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI52 helper copies ('word',): 214 differing. src size 0x6f4 base size 0x6f8 + +ZI53 helper copies ('wordLength', 'length'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI54 helper copies ('length', 'wordLength'): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI55 helper copies ('word', 'wordLength', 'length'): 218 differing. src size 0x6f4 base size 0x6f8 + +ZI56 helper copies ('length', 'word', 'wordLength'): 218 differing. src size 0x6f4 base size 0x6f8 + +ZI57 source/destination helper source[copied] order 0: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI58 source/destination helper source[copied] order 1: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI59 source/destination helper *(source + copied) order 0: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI60 source/destination helper *(source + copied) order 1: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI61 source/destination helper source[offset + copied] order 0: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI62 source/destination helper source[offset + copied] order 1: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI63 source/destination helper const source[copied] order 0: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI64 source/destination helper const source[copied] order 1: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI65 source/destination helper const *(source + copied) order 0: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI66 source/destination helper const *(source + copied) order 1: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI67 source/destination helper const source[offset + copied] order 0: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI68 source/destination helper const source[offset + copied] order 1: 19 differing. src size 0x6f8 base size 0x6f8 + +ES1 titleId received by value and copied into last local: 116 differing. src size 0x704 base size 0x704 + +ZI69 helper offset before wordLength - length: 186 differing. src size 0x6f4 base size 0x6f8 + +ZI70 helper offset before wordLength + -length: 186 differing. src size 0x6f4 base size 0x6f8 + +ZI71 helper offset after wordLength - length: 186 differing. src size 0x6f4 base size 0x6f8 + +ZI72 helper offset after wordLength + -length: 186 differing. src size 0x6f4 base size 0x6f8 + +ZI73 helper expression word[copied + (wordLength - length)]: 19 differing. src size 0x6f8 base size 0x6f8 + +ZI74 helper expression word[wordLength + copied - length]: 232 differing. src size 0x744 base size 0x6f8 + +ZI75 helper expression *(word + (wordLength - length) + copied): 19 differing. src size 0x6f8 base size 0x6f8 + +ZI76 helper loop u32 remaining = length;: 216 differing. src size 0x6c4 base size 0x6f8 + +ZI77 helper loop u32 copied = 0;: 19 differing. src size 0x6f8 base size 0x6f8 + +ES2 reverse paired desired locals: 34 differing. src size 0x704 base size 0x704 + +ES3 forward paired desired locals: 158 differing. src size 0x704 base size 0x704 + +ES4 reverse paired desired by ref: 403 differing. src size 0x70c base size 0x704 + +ES5 forward paired desired by ref: 412 differing. src size 0x70c base size 0x704 + +ES6 reverse paired desired by pointer: 34 differing. src size 0x704 base size 0x704 + +ES7 forward paired desired by pointer: 158 differing. src size 0x704 base size 0x704 + +ES8 InitSavedata declarations ('titleIds', 'ret', 'ticketScratch', 'i'): 34 differing. src size 0x704 base size 0x704 + +ES9 Init declarations ('titleIds', 'ret', 'ticketScratch', 'i') and ticket order: 20 differing. src size 0x704 base size 0x704 + +ES10 InitSavedata declarations ('titleIds', 'ret', 'i', 'ticketScratch'): 30 differing. src size 0x704 base size 0x704 + +ES11 Init declarations ('titleIds', 'ret', 'i', 'ticketScratch') and ticket order: 16 differing. src size 0x704 base size 0x704 + +ES12 InitSavedata declarations ('titleIds', 'ticketScratch', 'ret', 'i'): 39 differing. src size 0x704 base size 0x704 + +ES13 Init declarations ('titleIds', 'ticketScratch', 'ret', 'i') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES14 InitSavedata declarations ('titleIds', 'ticketScratch', 'i', 'ret'): 39 differing. src size 0x704 base size 0x704 + +ES15 Init declarations ('titleIds', 'ticketScratch', 'i', 'ret') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES16 InitSavedata declarations ('titleIds', 'i', 'ret', 'ticketScratch'): 35 differing. src size 0x704 base size 0x704 + +ES17 Init declarations ('titleIds', 'i', 'ret', 'ticketScratch') and ticket order: 21 differing. src size 0x704 base size 0x704 + +ES18 InitSavedata declarations ('titleIds', 'i', 'ticketScratch', 'ret'): 39 differing. src size 0x704 base size 0x704 + +ES19 Init declarations ('titleIds', 'i', 'ticketScratch', 'ret') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES20 InitSavedata declarations ('ret', 'titleIds', 'ticketScratch', 'i'): 39 differing. src size 0x704 base size 0x704 + +ES21 Init declarations ('ret', 'titleIds', 'ticketScratch', 'i') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES22 InitSavedata declarations ('ret', 'titleIds', 'i', 'ticketScratch'): 35 differing. src size 0x704 base size 0x704 + +ES23 Init declarations ('ret', 'titleIds', 'i', 'ticketScratch') and ticket order: 21 differing. src size 0x704 base size 0x704 + +ES24 InitSavedata declarations ('ret', 'ticketScratch', 'titleIds', 'i'): 28 differing. src size 0x704 base size 0x704 + +ZI78 helper computes word length, local order 0 u16* word, u32 length: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI79 helper computes word length, local order 0 u32 length, u16* word: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI80 helper computes word length, local order 1 u16* word, u32 length: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI81 helper computes word length, local order 1 u32 length, u16* word: 2 differing. src size 0x6f8 base size 0x6f8 + +ES25 Init declarations ('ret', 'ticketScratch', 'titleIds', 'i') and ticket order: 14 differing. src size 0x704 base size 0x704 + +ES26 InitSavedata declarations ('ret', 'ticketScratch', 'i', 'titleIds'): 39 differing. src size 0x704 base size 0x704 + +ES27 Init declarations ('ret', 'ticketScratch', 'i', 'titleIds') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES28 InitSavedata declarations ('ret', 'i', 'titleIds', 'ticketScratch'): 24 differing. src size 0x704 base size 0x704 + +ES29 Init declarations ('ret', 'i', 'titleIds', 'ticketScratch') and ticket order: 10 differing. src size 0x704 base size 0x704 + +ES30 InitSavedata declarations ('ret', 'i', 'ticketScratch', 'titleIds'): 39 differing. src size 0x704 base size 0x704 + +ES31 Init declarations ('ret', 'i', 'ticketScratch', 'titleIds') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES32 InitSavedata declarations ('ticketScratch', 'titleIds', 'ret', 'i'): 39 differing. src size 0x704 base size 0x704 + +ES33 Init declarations ('ticketScratch', 'titleIds', 'ret', 'i') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES34 InitSavedata declarations ('ticketScratch', 'titleIds', 'i', 'ret'): 39 differing. src size 0x704 base size 0x704 + +ES35 Init declarations ('ticketScratch', 'titleIds', 'i', 'ret') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES36 InitSavedata declarations ('ticketScratch', 'ret', 'titleIds', 'i'): 23 differing. src size 0x704 base size 0x704 + +ZI82 key copy loop iteration ++keyIndex, keyOutput += 0x40: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI83 key copy loop iteration keyOutput += 0x40, ++keyIndex: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI84 key copy loop body index then output: 2 differing. src size 0x6f8 base size 0x6f8 + +ES37 Init declarations ('ticketScratch', 'ret', 'titleIds', 'i') and ticket order: 9 differing. src size 0x704 base size 0x704 + +ES38 InitSavedata declarations ('ticketScratch', 'ret', 'i', 'titleIds'): 34 differing. src size 0x704 base size 0x704 + +ES39 Init declarations ('ticketScratch', 'ret', 'i', 'titleIds') and ticket order: 20 differing. src size 0x704 base size 0x704 + +ES40 InitSavedata declarations ('ticketScratch', 'i', 'titleIds', 'ret'): 28 differing. src size 0x704 base size 0x704 + +ES41 Init declarations ('ticketScratch', 'i', 'titleIds', 'ret') and ticket order: 14 differing. src size 0x704 base size 0x704 + +ES42 InitSavedata declarations ('ticketScratch', 'i', 'ret', 'titleIds'): 39 differing. src size 0x704 base size 0x704 + +ES43 Init declarations ('ticketScratch', 'i', 'ret', 'titleIds') and ticket order: 25 differing. src size 0x704 base size 0x704 + +ES44 InitSavedata declarations ('i', 'titleIds', 'ret', 'ticketScratch'): 32 differing. src size 0x704 base size 0x704 + +ES45 Init declarations ('i', 'titleIds', 'ret', 'ticketScratch') and ticket order: 18 differing. src size 0x704 base size 0x704 + +ES46 InitSavedata declarations ('i', 'titleIds', 'ticketScratch', 'ret'): 36 differing. src size 0x704 base size 0x704 + +ES47 Init declarations ('i', 'titleIds', 'ticketScratch', 'ret') and ticket order: 22 differing. src size 0x704 base size 0x704 + +ES48 InitSavedata declarations ('i', 'ret', 'titleIds', 'ticketScratch'): 16 differing. src size 0x704 base size 0x704 + +ES49 Init declarations ('i', 'ret', 'titleIds', 'ticketScratch') and ticket order: 2 differing. src size 0x704 base size 0x704 + +ES50 InitSavedata declarations ('i', 'ret', 'ticketScratch', 'titleIds'): 31 differing. src size 0x704 base size 0x704 + +ES51 Init declarations ('i', 'ret', 'ticketScratch', 'titleIds') and ticket order: 17 differing. src size 0x704 base size 0x704 + +ES52 InitSavedata declarations ('i', 'ticketScratch', 'titleIds', 'ret'): 25 differing. src size 0x704 base size 0x704 + +ES53 Init declarations ('i', 'ticketScratch', 'titleIds', 'ret') and ticket order: 11 differing. src size 0x704 base size 0x704 + +ES54 InitSavedata declarations ('i', 'ticketScratch', 'ret', 'titleIds'): 36 differing. src size 0x704 base size 0x704 + +ES55 Init declarations ('i', 'ticketScratch', 'ret', 'titleIds') and ticket order: 22 differing. src size 0x704 base size 0x704 + +ES56 initialize valid before j: 0 differing. src size 0x704 base size 0x704 + +ZI85 key source expression *(static_cast(mpHoldingKey)->wc + keyIndex - 1): 2 differing. src size 0x6f8 base size 0x6f8 + +ZI86 key source expression static_cast(mpHoldingKey)->wc[-1 + keyIndex]: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI87 key source expression (static_cast(mpHoldingKey)->wc - 1)[keyIndex]: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI88 key source expression static_cast(mpHoldingKey)->wc[keyIndex + -1]: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI89 swap keyOutput declaration with keyIndex: 15 differing. src size 0x6f8 base size 0x6f8 + +ZI90 swap keyOutput declaration with keyCharacter: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI91 swap keyOutput declaration with koreanOutput: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI92 swap keyOutput declaration with index: 35 differing. src size 0x6f8 base size 0x6f8 + +ZI93 swap keyOutput declaration with source: 30 differing. src size 0x6f8 base size 0x6f8 + +ZI94 swap keyOutput declaration with elementCount: 44 differing. src size 0x6f8 base size 0x6f8 + +ZI95 key destination increment keyOutput = keyOutput + 0x40: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI96 key destination increment keyOutput = 0x40 + keyOutput: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI97 key destination increment keyOutput += 64: 2 differing. src size 0x6f8 base size 0x6f8 + +ZI98 preincrement key destination: 347 differing. src size 0x6f4 base size 0x6f8 + +ZI99 key destination base plus indexed offset: 353 differing. src size 0x6f4 base size 0x6f8 + +ZI100 key destination indexed by keyIndex: 0 differing. src size 0x6f8 base size 0x6f8 + +Both requested functions reached zero differing with equal size. ZI100 also indexes the key output by keyIndex, removing the final induction-update scheduling pair. ES56 initializes valid before j, removing its final scheduling pair. No configure status change yet; unit-wide checks follow. + +Unit-wide objdiff after the exact source edits: tiZiString 29/29 functions, 5504/5504 code, 7680/7680 data, every section 100%; iplESMisc 31/31 functions, 11200/11200 code, 4416/4416 data, every section 100%. Pools identical; ctxdiff update 446/446 instructions, diffs 0; DeleteUnauthorizedData 449/449 instructions, diffs 0. Both configure entries changed to Matching. + +Initial full gate failed despite all owned code/data exact: DOL a9c0db300b393a94c498af7a6ef5a710f804edcb. Isolating configure entries showed tiZiString linking preserves the failure hash; both NonMatching restore the target hash. dtk dol diff proved checkForNullTermination and DeleteUnauthorizedData were emitted in reverse object order. Reordered these two definitions to symbols.txt order without changing their bodies. + +Final gate after definition-order repair: + +```text +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[src/keyboard/tiZiString] pool: IDENTICAL +[src/keyboard/tiZiString] objdiff: code 5504/5504 data 7680/7680 functions 29/29 fuzzy 100.0000 linked code 5504 +[src/keyboard/tiZiString] instruction-exact functions: 29/29 +[src/keyboard/tiZiString] section .bss size 7296 match 100.0 +[src/keyboard/tiZiString] section .data size 328 match 100.0 +[src/keyboard/tiZiString] section .rodata size 56 match 100.0 +[src/keyboard/tiZiString] section .text size 5504 match 100.0 +[src/keyboard/tiZiString] baseline: code 3720/5504 data 7680 functions 28 fuzzy 99.4717 +[src/utility/iplESMisc] pool: IDENTICAL +[src/utility/iplESMisc] objdiff: code 11200/11200 data 4416/4416 functions 31/31 fuzzy 100.0000 linked code 11200 +[src/utility/iplESMisc] instruction-exact functions: 31/31 +[src/utility/iplESMisc] section .data size 4384 match 100.0 +[src/utility/iplESMisc] section .sdata size 32 match 100.0 +[src/utility/iplESMisc] section .text size 11200 match 100.0 +[src/utility/iplESMisc] baseline: code 9404/11200 data 4416 functions 30 fuzzy 99.8625 +regressions vs baseline: 0 +global matched_code_percent: 97.29338 -> 97.41291 +global fuzzy_match_percent: 99.88914 -> 99.89063 +global complete_code_percent: 88.00925 -> 88.56695 +global matched_data_percent: 100.00000 -> 100.00000 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +note: config touched: configure.py (orchestrator reviews every config/symbols change) +GATE PASS +``` + +Final ctxdiff: update 446/446, diffs 0; DeleteUnauthorizedData 449/449, diffs 0. Both exact and linked. + +Allocator captures: baseline tiZiString `_mwdbg/runs/update__Q39textinput8tistring6WithZiFv-20261008-193010`; ordered locals `...-20261008-193122`; baseline iplESMisc `_mwdbg/runs/DeleteUnauthorizedData__Q33ipl7utility6ESMiscFPQ23EGG4Heap-20261008-193201`; titleId-copy `...-20261008-193510`. Baseline regsim reproduces 161/161. Paired titleId constrained simulation found 64/64 wants. Generated trial scripts, reports and raw logs are retained locally under build/sol-ties. + +ES exact implementation and its Matching entry committed as 0b3c7842. tiZiString exact implementation and its Matching entry follow in a separate commit. The final gate above covers the combined tree. -- 2.49.1