diff --git a/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c b/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c index 8706f9cd..5c242997 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c @@ -11,15 +11,15 @@ typedef struct { ziU8 characterLow; } ZiKoreanKeyEntry; -ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) { +ziU16 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) { ziU32 value; ziU16 count; - ziU32 i; + ziU16 i; count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK); - for (i = 0; (ziU16)i < count; i++) { - value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) | - table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]); + for (i = 0; i < count; i++) { + value = (ziU16)(((ziU16)table[(i << 3) + i + 7] << 8) | + table[(i << 3) + i + 8]); if (value == key) { Zi8LogError(0x64, ZI_WORK); return i; @@ -313,7 +313,8 @@ ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI param->candidates[0] = 0; } Zi8LogError(100, ZI_WORK); - if (param->wordCharCount != 0) { + if (param->wordCharCount == 0) goto scan_key_table; + { if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) && ((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) { search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow | @@ -438,6 +439,7 @@ search_table: param->count = search.candidateCount; param->letters = search.candidateCount; } +scan_key_table: if (param->elementCount > 9) { param->letters = 0; return 0; diff --git a/tools/decomp-assist/allhands-ezitext-korean-empty-context.attempts.md b/tools/decomp-assist/allhands-ezitext-korean-empty-context.attempts.md new file mode 100644 index 00000000..81cff1a9 --- /dev/null +++ b/tools/decomp-assist/allhands-ezitext-korean-empty-context.attempts.md @@ -0,0 +1,51 @@ +# Korean empty-context flow recovery, 2026-10-03 + +Base: 1fa33882; branch agent/bittle/korean-candidate-reconstruction. +Owned source: zkokeyp.c / Zi8GetKOcandidates only. + +## Target evidence + +The first context-length test at target function+0x158 sends an empty current +word directly to+0x730, the input-length/key-table scan setup. The compiled +source instead sent this case to its+0x6C8, the prefix-search result copy and +candidate cleanup. That block corresponds to target+0x6BC, which is reached +only after a nonempty context lookup attempt or word-table search. + +Added an explicit empty-context guard to a label immediately before the +existing input-length check. The nonempty prefix-search paths still enter +search_table and perform the original result/candidate cleanup. The change +recovers the target control-flow edge without moving any body or introducing +storage, helper calls, or artificial register constraints. The old edge did +not necessarily change visible output for initialized empty context; this +is a target-flow correction, not a claim of a newly demonstrated user bug. + +## Validation + +Fresh baseline: /tmp/ezi-korean-recon-baseline.json. +Fresh final report: /tmp/ezi-korean-flow-full-report.json. +Full build: /tmp/ezi-korean-flow-full-build.log. +Detailed gates: /tmp/ezi-korean-flow-verification.txt. + +Zi8GetKOcandidates: 97.96712% ->97.97459%. +Unit fuzzy: 98.65385% ->98.65769%. +Exact functions remain1/7, exact code332/5200, matched data96/180. +All1027 units were checked: the unit fuzzy gain is the only changed measure, +with no code/data/function or fuzzy regressions. No new exact function claimed. + +The source object differs from its preserved baseline at exactly one .text +payload byte, the corrected branch displacement. All section sizes and all +canonical relocation tuples remain unchanged. .data40, extab56 and +extabindex84 are byte-identical to baseline. The unit's existing exact +Zi8_81483118 remains83/83 instructions and ctxdiff diffs0, with its exact +10-entry generated switch table unchanged. + +Pool first: identical and empty. Main still673/669 instructions; the known +extra zero materialization, two lookup-result narrowings and return-value +move remain. All92 mapped direct main branches now preserve their target +destinations; the17 ordered helper calls agree. The filter's43 direct branches +also agree. These are advisory correspondence checks, not an exactness claim. + +Full43U build passes with the approved wrapper and WIBO_SJIS_MISSING_IMPORTS=1. +DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d. +git diff --check passes. No header, metadata, linking, remote, assembly, +volatile, dummy-storage or forced-register changes. diff --git a/tools/decomp-assist/allhands-ezitext-korean-lookup-width.attempts.md b/tools/decomp-assist/allhands-ezitext-korean-lookup-width.attempts.md new file mode 100644 index 00000000..11e8fd70 --- /dev/null +++ b/tools/decomp-assist/allhands-ezitext-korean-lookup-width.attempts.md @@ -0,0 +1,76 @@ +# Korean lookup halfword contract, 2026-10-03 + +Parent: dea3851e; its empty-context correction is unchanged. +Owned source: zkokeyp.c / Zi8_8148302C and its two local callers. + +## Recovered type boundary + +The lookup traverses a table whose count is ziU16, comparing and addressing +records through a halfword index, and returns either that index or0xFFFF. +For countN<=65535, successful indexes are0..N-1. The loop exits atN; a +halfword index cannot wrap on any traversed iteration. There is no need for +a full-word index or return value in this contract. + +Both callers store the result into the halfword search.keyIndex. The target +stores the returned register directly through the halfword store. The first +caller then narrows for its assignment-value comparison, while the second +reloads the halfword for comparison. The current full-word declaration made +MWCC emit an additional narrowing before both stores. + +Recovered the helper's ziU16 return and ziU16 loop index together, then used +the typed index directly in the loop condition and nine-byte address +expressions. The old explicit masks were the reconstruction of those same +halfword promotions while the local had the wrong full-word type. They are +not stripped from a full-word value or replaced by register constraints. + +The resulting helper body is byte-for-byte identical to its previous body, +including its59 instructions and resolved calls. This demonstrates that the +same lookup operations and return representation are preserved while its +callers recover the target halfword assignment boundary. Both source callers +are in this unit. A scan of all extracted target objects found the same two +text references and only the helper's own extabindex reference otherwise. +No shared declaration or header changes are needed. + +## Separate trials + +A native unsigned-int return alone and explicit caller-store casts were +codegen-neutral and were not retained. The coherent halfword index/return +pair is the sole selected candidate. No old Chinese ABI experiment or +arbitrary declaration/register sweep was repeated. + +## Validation + +Baseline: /tmp/ezi-korean-flow-full-report.json. +Fresh full report: /tmp/ezi-korean-lookup-full-report.json. +Full build: /tmp/ezi-korean-lookup-full-build.log. +Detailed gates: /tmp/ezi-korean-lookup-verification.txt. + +Zi8GetKOcandidates: 97.97459% ->98.146484%. +Unit fuzzy: 98.65769% ->98.746155%. +Relative to initial1fa33882, unit98.65385% ->98.746155%. +Exact functions remain1/7, exact code332/5200, matched data96/180. +All1027 unit measures and all per-function fuzzy scores were checked: the +Korean unit/main-function gains are the only metric changes, with no +regressions. No new exact function or complete unit is claimed. + +Every other function's disassembly is baseline-identical, including the +changed lookup helper. The existing exact packing helper remains83/83 +instructions and ctxdiff diffs0. Main shrinks673 ->671 instructions versus +target669, from0xA84 to0xA7C versus target0xA74. Its0x60 frame is preserved. +The remaining normalized differences are one zero materialization and one +call-result move; no further width or flow difference is identified. + +.data40 and extab56 retain identical payloads and canonical relocations. +The already-unmatched84-byte extabindex changes only its main-function size +byte at0x4F,0x84 ->0x7C; its score remains97.61904%, and exact-data accounting +is unchanged. No real data object or section extent was changed. + +Pool first: identical and empty. All92 mapped main branches preserve their +corrected target destinations; all17 helper calls correspond. An associative, +register-value-aware advisory audit pairs all163 store/call/branch effects +without differences. These checks are not formal equivalence or exactness +claims. Full43U build passes with the approved wrapper and +WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1: +26116613f624061ba99c8d1a299aaa6efa85670d. +git diff --check passes. No linking, remote, header, assembly, volatile, +dummy-storage, undefined-value or forced-register change.