decomp: correct Chinese phonetic contracts and Zhuyin dispatch #1000

Merged
coah80 merged 1 commits from agent/bittle/chinese-phonetic-contract into main 2026-10-03 00:07:44 +00:00
coah80 commented 2026-10-03 00:05:35 +00:00 (Migrated from github.com)

Correctness fixes with no percentage gain

  1. Correct four Zhuyin switch destinations: initial cases 52/55 must consult the bit-11 fuzzy-pair setting, while 60/63 consult bit 10. The old source crossed these pairs. Swap only case labels, retaining body order.
  2. Make the local Zi8MatchPhonetic declaration and all three callers agree with its actual definition, including byte-pointer output locals instead of incompatible int/pointer-to-pointer casts.
  3. Restore Zi8SecMatchComp's unused workspace formal. The sole caller and original call pass four arguments; the callee discards the incoming fourth argument.

Independent verification

  • Parent inspected target and candidate dispatch at .data offsets 0xC8/0xD4/0xE8/0xF4 and the actual bit-test bodies; baseline selects the opposite settings
  • All 98 generated switch destinations map through equal normalized instruction groups after correction. This is advisory mapping, not whole-program equivalence
  • All 1027 report measures are unchanged. Chinese engine remains 96.27482%, unit 96.65468%, exact functions 5/8, data 144/536
  • All code/data payload bytes are unchanged; exactly four .data relocation destinations change. All other allocated bytes and normalized relocations across the 1027 source objects are identical
  • The interface-only changes are codegen-neutral. Zi8SecMatchComp remains 68/68 instructions, ctxdiff zero; the Chinese unit's five exact helpers remain exact
  • Pool/literal/worktree/diff checks pass; full 43U all_source/report/progress/DOL pass

This fixes real dispatch and C type-contract errors that fuzzy scores do not expose. No percentage gain, new exact function or complete-data claim. No shared-header, metadata, binary, padding or linking change.

Parent baseline: fa0cb9b7b4
Tested tree: 07d860a5ed
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d

User priority is decompilation, then matching, then linking. No merge performed or requested by this author.

Note

Fix Zhuyin dispatch case mapping and correct Zi8MatchPhonetic contract

  • Swaps the case labels for the bANDp and gANDk fuzzy-pair checks in zi8InternalGetZH in zi8cgetc.c: initials 52/55 now use gANDk, and 60/63 use bANDp
  • Updates Zi8MatchPhonetic and its callers to use byte-addressed records, a native-width dictionary address, and byte-pointer matched-record and matched-string outputs, removing the old integer matched-index output
  • Adds the missing workspace formal to Zi8SecMatchComp in zi8match.c so the caller-supplied workspace argument is declared
  • Adds three decomp-assist reports under tools/decomp-assist documenting the contract, dispatch, and workspace fixes
  • Behavioral Change: fuzzy-pair phonetic matching for Zhuyin initials 52, 55, 60, and 63 now reaches the correct pair; the masks and tests themselves are unchanged

Macroscope summarized b03456b.

## Correctness fixes with no percentage gain 1. Correct four Zhuyin switch destinations: initial cases 52/55 must consult the bit-11 fuzzy-pair setting, while 60/63 consult bit 10. The old source crossed these pairs. Swap only case labels, retaining body order. 2. Make the local Zi8MatchPhonetic declaration and all three callers agree with its actual definition, including byte-pointer output locals instead of incompatible int/pointer-to-pointer casts. 3. Restore Zi8SecMatchComp's unused workspace formal. The sole caller and original call pass four arguments; the callee discards the incoming fourth argument. ## Independent verification - Parent inspected target and candidate dispatch at .data offsets 0xC8/0xD4/0xE8/0xF4 and the actual bit-test bodies; baseline selects the opposite settings - All 98 generated switch destinations map through equal normalized instruction groups after correction. This is advisory mapping, not whole-program equivalence - All 1027 report measures are unchanged. Chinese engine remains 96.27482%, unit 96.65468%, exact functions 5/8, data 144/536 - All code/data payload bytes are unchanged; exactly four .data relocation destinations change. All other allocated bytes and normalized relocations across the 1027 source objects are identical - The interface-only changes are codegen-neutral. Zi8SecMatchComp remains 68/68 instructions, ctxdiff zero; the Chinese unit's five exact helpers remain exact - Pool/literal/worktree/diff checks pass; full 43U all_source/report/progress/DOL pass This fixes real dispatch and C type-contract errors that fuzzy scores do not expose. No percentage gain, new exact function or complete-data claim. No shared-header, metadata, binary, padding or linking change. Parent baseline: fa0cb9b7b43018c542b9768a6cd8cd121426b519 Tested tree: 07d860a5edbee8fd9c241a53b419ce73454188f4 DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d User priority is decompilation, then matching, then linking. 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 Zhuyin dispatch case mapping and correct `Zi8MatchPhonetic` contract > - Swaps the case labels for the bANDp and gANDk fuzzy-pair checks in `zi8InternalGetZH` in [zi8cgetc.c](https://github.com/coah80/wii-ipl/pull/1000/files#diff-c5899d9823fec11392add0326b5e7a8a64ca8e4e3ec1bebb2bd298304812ac69): initials 52/55 now use gANDk, and 60/63 use bANDp > - Updates `Zi8MatchPhonetic` and its callers to use byte-addressed records, a native-width dictionary address, and byte-pointer matched-record and matched-string outputs, removing the old integer matched-index output > - Adds the missing workspace formal to `Zi8SecMatchComp` in [zi8match.c](https://github.com/coah80/wii-ipl/pull/1000/files#diff-8e712316e01335567994bb1295eb125f2ff632385e3fe6bec539430c45b6fe5a) so the caller-supplied workspace argument is declared > - Adds three decomp-assist reports under [tools/decomp-assist](https://github.com/coah80/wii-ipl/pull/1000/files#diff-8a3653c1c2bcb3cc12bc860c28004192a5a278bf8f804beef70d1f07ddd79039) documenting the contract, dispatch, and workspace fixes > - Behavioral Change: fuzzy-pair phonetic matching for Zhuyin initials 52, 55, 60, and 63 now reaches the correct pair; the masks and tests themselves are unchanged > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized b03456b.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 00:07:41 +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.