decomp: restore Korean scan entry and lookup widths #1008

Merged
coah80 merged 1 commits from agent/bittle/korean-empty-context into main 2026-10-03 00:53:59 +00:00
coah80 commented 2026-10-03 00:52:27 +00:00 (Migrated from github.com)

Source corrections

An empty word context must skip prefix-result cleanup and enter the existing key-table scan setup. Parent verified the original branch at function+0x158 goes to +0x730; the old compiled source went to its cleanup block instead. Restore that edge without moving the body.

Recover the lookup helper's halfword return and loop-index pair, replacing explicit index masks with ordinary typed uses. Its count and not-found result fit the halfword contract; both callers are in this unit. The helper itself remains byte-identical while its callers avoid two target-absent narrowings.

Independent verification

  • Zi8GetKOcandidates: 97.96712% → 98.146484%; source 673 → 671 instructions, target 669
  • Unit fuzzy: 98.65385% → 98.746155%; exact functions 1/7, code 332/5200 and data 96/180 preserved
  • Empty-context change alone modifies one branch-displacement byte
  • All other functions unchanged; the exact packing helper remains 83/83 instructions, ctxdiff zero; lookup remains 59 instructions and byte-identical
  • .data/extab unchanged; existing unmatched extabindex only updates the main function extent 0xA84 → 0xA7C, versus target 0xA74
  • No report regressions across 1027 units; pool/literal/worktree/diff checks pass
  • Full 43U all_source/report/progress/DOL pass

This is partial source/flow reconstruction. The empty-context edge does not necessarily alter visible output when prior state is initialized; no unproven user-visible bug claim. No header, metadata, artificial storage or linking change.

Parent baseline: e5987de5ad
Tested tree: eb18c85729
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d

No merge performed or requested by this author.

Note

Fix Korean empty-word candidate scan and restore 16-bit lookup widths in zkokeyp.c

  • Restores the Zi8_8148302C lookup helper to 16-bit types: return value and loop index change from ziU32 to ziU16, matching the halfword table count directly. Success and failure values stay the same (matching index and 0xFFFF).
  • Adds an explicit guard in Zi8GetKOcandidates so an empty current word (wordCharCount == 0) skips the prefix-search cleanup block and jumps straight to the key-table scan. Nonempty words keep the existing lookup and search-table paths.
  • Adds recovery reports under tools/decomp-assist documenting the control-flow fix and the lookup-width reconstruction, with validation and binary comparison notes.
  • Behavioral Change: empty-word input now follows the scan path directly; check the zero-wordCharCount branch and scan label placement in zkokeyp.c if candidate output differs.

Macroscope summarized f67d0d0.

## Source corrections An empty word context must skip prefix-result cleanup and enter the existing key-table scan setup. Parent verified the original branch at function+0x158 goes to +0x730; the old compiled source went to its cleanup block instead. Restore that edge without moving the body. Recover the lookup helper's halfword return and loop-index pair, replacing explicit index masks with ordinary typed uses. Its count and not-found result fit the halfword contract; both callers are in this unit. The helper itself remains byte-identical while its callers avoid two target-absent narrowings. ## Independent verification - Zi8GetKOcandidates: 97.96712% → 98.146484%; source 673 → 671 instructions, target 669 - Unit fuzzy: 98.65385% → 98.746155%; exact functions 1/7, code 332/5200 and data 96/180 preserved - Empty-context change alone modifies one branch-displacement byte - All other functions unchanged; the exact packing helper remains 83/83 instructions, ctxdiff zero; lookup remains 59 instructions and byte-identical - .data/extab unchanged; existing unmatched extabindex only updates the main function extent 0xA84 → 0xA7C, versus target 0xA74 - No report regressions across 1027 units; pool/literal/worktree/diff checks pass - Full 43U all_source/report/progress/DOL pass This is partial source/flow reconstruction. The empty-context edge does not necessarily alter visible output when prior state is initialized; no unproven user-visible bug claim. No header, metadata, artificial storage or linking change. Parent baseline: e5987de5ad1d0b4adb5a5cbc388f7a1dc561001b Tested tree: eb18c857298496b580f0e459054139cc24f0f92a DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d No merge performed or requested by this author. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Fix Korean empty-word candidate scan and restore 16-bit lookup widths in `zkokeyp.c` > - Restores the `Zi8_8148302C` lookup helper to 16-bit types: return value and loop index change from `ziU32` to `ziU16`, matching the halfword table count directly. Success and failure values stay the same (matching index and 0xFFFF). > - Adds an explicit guard in `Zi8GetKOcandidates` so an empty current word (`wordCharCount == 0`) skips the prefix-search cleanup block and jumps straight to the key-table scan. Nonempty words keep the existing lookup and search-table paths. > - Adds recovery reports under [tools/decomp-assist](https://github.com/coah80/wii-ipl/pull/1008/files#diff-8a3653c1c2bcb3cc12bc860c28004192a5a278bf8f804beef70d1f07ddd79039) documenting the control-flow fix and the lookup-width reconstruction, with validation and binary comparison notes. > - Behavioral Change: empty-word input now follows the scan path directly; check the zero-`wordCharCount` branch and scan label placement in [zkokeyp.c](https://github.com/coah80/wii-ipl/pull/1008/files#diff-7d85c7ae1619302f9a4b7290a2e67027238ea966969aa266dd584b9cae0b06af) if candidate output differs. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized f67d0d0.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 00:53:56 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.