Compare commits

...

1 Commits

Author SHA1 Message Date
coah
bc8b8eb8ec zi81key 5/9 (MatchAltSound1Key exact) (worker c23b5c16) 2026-09-30 14:47:33 +00:00
5 changed files with 157 additions and 90 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 97.61% | 83.81% | 58.20% | 90.15% |
| 97.63% | 83.85% | 58.20% | 90.15% |
units 778/1027 complete, functions 12038/12563 matched.
units 778/1027 complete, functions 12039/12563 matched.
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
<!-- progress:end -->

View File

@@ -212,7 +212,7 @@ extern int _Zi8GetCandidates();
extern void Zi8InitDupWordBuf();
extern ziU16 Zi8GetPInfo(ziU16,ziWChar *,ziU8,ziPtr);
extern ziU16 Zi8GetZInfo(ziU16,ziWChar *,ziU8,ziPtr);
extern ziU8 Zi8IsDupWordW();
extern ziBool Zi8IsDupWordW(ziWChar *,ziU8,ziPtr);
extern ziU8 Zi8GetFormatVersion(ziU8,ziPtr);
extern ziU16 Zi8Uni2Ord(ziWChar,ziPtr);
extern ziU16 Zi8GetPCode(ziU8 *,ziU8 *);
@@ -352,7 +352,7 @@ ziU8 Zi8IsMatch1Key(ziU16 *input,Zi8UInt inputLength,Zi8UInt key,ziU8 requireFul
return 1;
}
ziU8 MatchAltSound1Key(ziU16 *spelling,Zi8UInt spellingLength,Zi8UInt requireFull,Zi8AltSoundRecord *records,Zi8UInt recordCount,const ziU8 *phoneticTableBase,Zi8UInt key,Zi8UInt usePinyin,ziU8 tone,ziU8 modifierFlags,Zi8OneKeyWork *context)
ziU8 MatchAltSound1Key(ziU16 *spelling,Zi8UInt spellingLength,Zi8UInt requireFull,Zi8AltSoundRecord *records,Zi8UInt recordCount,const ziU8 *phoneticTableBase,Zi8UInt key,Zi8UInt usePinyin,ziU8 tone,ziU8 modifierFlags,ziPtr context)
{
int searchIndex;
ziU8 keyHigh;
@@ -391,8 +391,8 @@ PROCESS:
((modifierFlags & records[recordIndex].flags) != 0)) {
phoneticOffset = (ziU16)(records[recordIndex].code |
((ziU16)(records[recordIndex].flags & 1) << 8));
if ((context->phoneticFilter == '\0') ||
(context->phoneticEnabled[(ziU16)phoneticOffset] != '\0')) {
if ((((Zi8OneKeyWork*)context)->phoneticFilter == '\0') ||
(((Zi8OneKeyWork*)context)->phoneticEnabled[(ziU16)phoneticOffset] != '\0')) {
phoneticOffset = (ziU16)(phoneticOffset << 1);
phoneticCode = (ziU16)(((records[recordIndex].flags & 0xf0) >> 4) |
(phoneticTableBase[(ziU16)phoneticOffset] | ((ziU16)phoneticTableBase[(ziU16)phoneticOffset + 1] << 8)));
@@ -413,8 +413,8 @@ BACKWARD_PROCESS:
((modifierFlags & records[recordIndex].flags) != 0)) {
phoneticOffset = (ziU16)(records[recordIndex].code |
(((ziU16)records[recordIndex].flags & 1) << 8));
if ((context->phoneticFilter == '\0') ||
(context->phoneticEnabled[(ziU16)phoneticOffset] != '\0')) {
if ((((Zi8OneKeyWork*)context)->phoneticFilter == '\0') ||
(((Zi8OneKeyWork*)context)->phoneticEnabled[(ziU16)phoneticOffset] != '\0')) {
phoneticOffset = (ziU16)(phoneticOffset << 1);
phoneticCode = (ziU16)(((records[recordIndex].flags & 0xf0) >> 4) |
(phoneticTableBase[(ziU16)phoneticOffset] | ((ziU16)phoneticTableBase[(ziU16)phoneticOffset + 1] << 8)));
@@ -940,11 +940,14 @@ Zi8UInt Zi8Get1KeyPressSpelling(Zi8OneKeyParam *params,Zi8OneKeyOptions *options
for (tableIndex = 0; tableIndex < params->count;) {
while (*output != 0) {
if (*output != 0x27) {
*output++ |= 0xf300;
*output |= 0xf300;
output++;
} else {
*output++ = 0xf360;
*output = 0xf360;
output++;
}
}
tableIndex++;
output++;
}
}
@@ -1283,13 +1286,13 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
Zi8Memset(work->phoneticEnabled,0,0x200);
for (index = 0; index < alternateCount; index++) {
phoneticCode = phoneticTable[index * 2] | ((ziU16)phoneticTable[index * 2 + 1] << 8);
if ((ziU8)Zi8IsMatch1Key(spelling,inputLimit,phoneticCode,(ziU8)0,tone,(ziU8)0) == 0) {
work->phoneticEnabled[index] = 0;
}
else {
if ((ziU8)Zi8IsMatch1Key(spelling,inputLimit,phoneticCode,(ziU8)0,tone,(ziU8)0) != 0) {
work->phoneticEnabled[index] = 1;
validPhonetic = true;
}
else {
work->phoneticEnabled[index] = 0;
}
}
if (!validPhonetic) goto finishCandidates;
}
@@ -1572,7 +1575,7 @@ finishPhrases:
}
if ((options->countOnly == '\0') && (tableCursor != 0)) {
for (ordinalIndex = 0; ordinalIndex < tableCursor; ordinalIndex++) {
ordinal = (ziU16)ordinalTable[(Zi8UInt)ordinalIndex * 2] * 0x100 +
ordinal = ((ziU16)ordinalTable[(Zi8UInt)ordinalIndex * 2] << 8) +
(ziU16)ordinalTable[(Zi8UInt)ordinalIndex * 2 + 1];
phraseTable = syllableTable + (Zi8UInt)ordinal * 0xc;
if (((*phraseTable & languageMask) != 0) &&
@@ -1705,7 +1708,7 @@ nextUserOrdinal:
tone,includeTone,languageMask,work);
}
if (elementIndex == 0) goto nextOrdinal;
unicodeCharacter = (ziU16)phraseTable[6] * 0x100 + (ziU16)phraseTable[7];
unicodeCharacter = ((ziU16)phraseTable[6] << 8) + (ziU16)phraseTable[7];
if (unicodeCharacter == previousCharacter) goto nextOrdinal;
previousCharacter = unicodeCharacter;
if (!emitWords) {

View File

@@ -57,7 +57,7 @@ typedef struct {
ziU8 dictionaryMode;
ziWChar* dictionary;
ziU32 dictionaryFlags;
ziU32 maxResults;
ziS32 maxResults;
ziU16 capacity;
ziU8 minWordLength;
ziU8 candidateMode;
@@ -465,13 +465,13 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
if (((parameters->elementCount == 1) && (*parameters->elements >= 0xeff1)) &&
(*parameters->elements <= 0xf010)) {
contextEnabled = ZI8_FALSE;
wordLength = (ziU8)Zi8MatchROMdata(parameters->elements,1,language,candidateWord,2,1,0,0,0,
wordLength = Zi8MatchROMdata(parameters->elements,1,language,candidateWord,2,1,0,0,0,
workData);
if (wordLength == 0) {
language = parameters->subLanguage;
}
else {
wordLength = (ziU8)Zi8MatchROMdata(parameters->elements,1,parameters->subLanguage,candidateWord,2,1,0,0,0,
wordLength = Zi8MatchROMdata(parameters->elements,1,parameters->subLanguage,candidateWord,2,1,0,0,0,
workData);
if ((wordLength != 0) && (candidateWord[0] != *parameters->elements)) {
alternateSingleCharacter = 1;
@@ -480,23 +480,21 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
}
}
if ((parameters->elementCount == 1) && (((ZiAlphaOptions*)optionData)->lookupMode == '\0')) {
if (((parameters->wordCharCount < 3) ||
(((parameters->currentWord == 0 ||
(parameters->currentWord[parameters->wordCharCount - 1] != 0x77)) ||
(parameters->currentWord[parameters->wordCharCount - 2] != 0x77)))) ||
(parameters->currentWord[parameters->wordCharCount - 3] != 0x77)) {
((ZiAlphaWork*)workData)->letterHyphen = 0x2d;
if (parameters->wordCharCount >= 3 && parameters->currentWord != 0 &&
parameters->currentWord[parameters->wordCharCount - 1] == 0x77 &&
parameters->currentWord[parameters->wordCharCount - 2] == 0x77 &&
parameters->currentWord[parameters->wordCharCount - 3] == 0x77) {
((ZiAlphaWork*)workData)->letterHyphen = 0x2e;
}
else {
((ZiAlphaWork*)workData)->letterHyphen = 0x2e;
((ZiAlphaWork*)workData)->letterHyphen = 0x2d;
}
}
if (((elementCount != 0) && (((ZiAlphaOptions*)optionData)->lookupMode == '\0')) && (((ZiAlphaOptions*)optionData)->countOnly == '\0')) {
index = Zi8IsAlphaPunct(elements[elementCount - 1]);
if (index == '\0') {
if (Zi8IsAlphaPunct(elements[elementCount - 1]) == '\0') {
((ZiAlphaWork*)workData)->rememberedCount = elementCount;
}
else if (elementCount < ((ZiAlphaWork*)workData)->rememberedCount) {
else if (((ZiAlphaWork*)workData)->rememberedCount > elementCount) {
((ZiAlphaWork*)workData)->rememberedCount = elementCount - 1;
}
}
@@ -738,10 +736,9 @@ prepareDictionaries:
apostropheIndex = apostropheIndex + 1;
}
}
if ((((completionAllowed) && (languagePassCount != 2)) && (parameters->elementCount == 2)) &&
if ((((currentVowelRestriction) && (languagePassCount != 2)) && (parameters->elementCount == 2)) &&
((parameters->elements[1] == 0xEFF1 && (((ZiAlphaWork*)workData)->singleCharacter != 0)))) {
index = Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData);
if (index == '\0') {
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
punctuationBuffer[0] = 0;
}
}
@@ -766,8 +763,15 @@ prepareDictionaries:
}
}
if (dictionaryIndex != ((ZiAlphaWork*)workData)->dictionaryCount) {
dictionaryKind = (unsigned int)((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex];
if ((dictionaryKind != 0xc) || (languagePassCount == 2)) {
dictionaryKind = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex];
if (dictionaryKind == 12) {
if (languagePassCount != 2) goto finishDictionaryPass;
goto selectDictionary;
}
} else {
if (((ZiAlphaOptions*)optionData)->lookupMode != 0) goto finishDictionaryPass;
dictionaryKind = 10;
}
selectDictionary:
if (secondLanguagePass) {
switch (dictionaryKind) {
@@ -880,7 +884,7 @@ selectDictionary:
case 1:
case 5:
if (elementCount == 0) break;
if ((((matchMode == 0) && (completionAllowed)) &&
if ((((matchMode == 0) && (currentVowelRestriction)) &&
((2 < (int)elementCount &&
((((ZiAlphaWork*)workData)->language == language &&
((unsigned int)((ZiAlphaWork*)workData)->prefixCount == elementCount - 1)))))) &&
@@ -889,23 +893,23 @@ selectDictionary:
}
else {
if (alternateSingleCharacter != 2) {
wordLength = (ziU8)Zi8MatchROMdata(elements,elementCount & 0xff,language,wordCursor,
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,language,wordCursor,
wordCapacity & 0xffff,matchMode,
dictionaryStatus[dictionaryKind] & 0xff,0,exactLengthOnly,workData);
}
if ((alternateSingleCharacter != 0) && ((wordLength == 0 || (*wordCursor == *elements)))) {
if (alternateSingleCharacter == 1) {
alternateSingleCharacter = 2;
wordLength = (ziU8)Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordCapacity & 0xffff,1,0,0,exactLengthOnly,workData);
}
else {
wordLength = (ziU8)Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordCapacity & 0xffff,1,1,0,exactLengthOnly,workData);
}
}
}
if ((dictionaryExact != 0) && ((int)elementCount < (int)wordLength)) {
if ((dictionaryExact != 0) && ((int)wordLength > (int)elementCount)) {
wordLength = 0;
}
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
@@ -938,12 +942,14 @@ selectDictionary:
}
if (wordLength != 0) goto filterVowelCandidate;
dictionaryStatus[dictionaryKind] = 1;
if (0xeff0 < elements[apostropheIndex]) goto retryDictionary;
goto finishDictionaryPass;
if (elements[apostropheIndex] < 0xEFF1) goto finishDictionaryPass;
goto retryDictionary;
}
filterVowelCandidate:
if ((wordLength != 0) && (prefixVowelRestriction)) {
if ((*wordCursor < 0x30) || (0x39 < *wordCursor)) {
if ((*wordCursor >= 0x30) && (*wordCursor <= 0x39)) {
wordLength = 0;
} else {
if (((elementCount == 1) && (dictionaryKind != 10)) && (0xeff0 < *wordCursor)) {
punctuationCandidate = ZI8_TRUE;
goto finishDictionaryPass;
@@ -967,10 +973,8 @@ filterVowelCandidate:
}
}
}
else {
wordLength = 0;
}
if (wordLength == 0) {
wordLength = 0;
dictionaryStatus[dictionaryKind] = 1;
goto retryDictionary;
}
@@ -988,7 +992,7 @@ filterVowelCandidate:
case 2:
case 6:
if (elementCount != 0) {
wordLength = (ziU8)Zi8MatchPUDdata(elements,elementCount & 0xff,language,wordCursor,
wordLength = Zi8MatchPUDdata(elements,elementCount & 0xff,language,wordCursor,
wordCapacity & 0xffff,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
}
@@ -996,7 +1000,7 @@ filterVowelCandidate:
case 3:
case 7:
while( ZI8_TRUE ) {
wordLength = (ziU8)Zi8MatchUWDdata(elements,elementCount & 0xff,
wordLength = Zi8MatchUWDdata(elements,elementCount & 0xff,
parameters->currentWord,parameters->wordCharCount,
language,wordCursor,wordCapacity & 0xffff,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
@@ -1007,7 +1011,7 @@ filterVowelCandidate:
case 4:
case 8:
if (elementCount != 0) {
wordLength = (ziU8)Zi8MatchOEMdata(elements,elementCount & 0xff,language,wordCursor,
wordLength = Zi8MatchOEMdata(elements,elementCount & 0xff,language,wordCursor,
wordCapacity & 0xffff,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
}
@@ -1074,8 +1078,7 @@ appendPunctuation:
if (language != ((ZiAlphaWork*)workData)->language) break;
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
if ((index == 0xc) || (((index < 0xc && (index < 9)) && (4 < index)))) {
index = Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData);
if (index == '\0') {
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
punctuationBuffer[0] = 0;
}
punctuationCursor = &punctuationBuffer[0];
@@ -1095,8 +1098,7 @@ appendPunctuation:
(languagePassCount == 2)))) break;
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
if ((index != 0xc) && (((0xb < index || (8 < index)) || (index < 5)))) break;
index = Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData);
if (index == '\0') {
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
punctuationBuffer[0] = 0;
}
punctuationCursor = &punctuationBuffer[0];
@@ -1193,7 +1195,18 @@ checkKeyLayout:
else if (dictionaryKind == 9) goto checkKeyLayout;
emitCandidate:
if (firstCandidate == 0) {
if (((ZiAlphaOptions*)optionData)->countOnly == '\0') {
if (((ZiAlphaOptions*)optionData)->countOnly != '\0') {
if (((ZiAlphaOptions*)optionData)->suffixOnly != '\0') {
if ((int)(wordLength + prefixCount) < (int)(unsigned int)(ziU8)((ZiAlphaOptions*)optionData)->shortestWord) {
((ZiAlphaOptions*)optionData)->shortestWord = wordLength + prefixCount;
}
if ((int)(unsigned int)(ziU8)((ZiAlphaOptions*)optionData)->longestWord < (int)(wordLength + prefixCount)) {
((ZiAlphaOptions*)optionData)->longestWord = wordLength + prefixCount;
}
}
candidateCount = candidateCount + 1;
if (((ZiAlphaOptions*)optionData)->maxResults <= candidateCount) goto finishCandidates;
} else {
if (((ZiAlphaOptions*)optionData)->lookupMode != '\0') {
for (index = 0;
(index <= (int)wordLength &&
@@ -1344,18 +1357,6 @@ emitCandidate:
}
}
}
else {
if (((ZiAlphaOptions*)optionData)->suffixOnly != '\0') {
if ((int)(wordLength + prefixCount) < (int)(unsigned int)(ziU8)((ZiAlphaOptions*)optionData)->shortestWord) {
((ZiAlphaOptions*)optionData)->shortestWord = wordLength + prefixCount;
}
if ((int)(unsigned int)(ziU8)((ZiAlphaOptions*)optionData)->longestWord < (int)(wordLength + prefixCount)) {
((ZiAlphaOptions*)optionData)->longestWord = wordLength + prefixCount;
}
}
candidateCount = candidateCount + 1;
if (((ZiAlphaOptions*)optionData)->maxResults <= candidateCount) goto finishCandidates;
}
}
else {
firstCandidate = firstCandidate - 1;
@@ -1367,13 +1368,6 @@ emitCandidate:
retryDictionary:;
} while (dictionaryKind != 0);
}
}
} else {
if (((ZiAlphaOptions*)optionData)->lookupMode == '\0') {
dictionaryKind = 10;
goto selectDictionary;
}
}
finishDictionaryPass:;
}
if ((((candidateCount == 0) && (!punctuationCandidate)) &&
@@ -1595,36 +1589,34 @@ finishCandidates:
((((ZiAlphaWork*)workData)->prefixEnabled < 2 ||
(parameters->elements[elementIndex] == 0xEFF1)))) {
index = 0;
for (; (-1 < (int)elementIndex &&
(parameters->elements[elementIndex] == 0xEFF1));
elementIndex = elementIndex + -1) {
index = index + 1;
while (elementIndex >= 0) {
if (parameters->elements[elementIndex] != 0xEFF1) break;
elementIndex--;
index++;
}
if (index == 0) {
if (index != 0) {
((ZiAlphaWork*)workData)->prefixEnabled = (ziU8)index;
} else {
if (candidateCount != 0) {
((ZiAlphaWork*)workData)->prefixEnabled = 0;
((ZiAlphaWork*)workData)->requiredLength = 0;
}
}
else {
((ZiAlphaWork*)workData)->prefixEnabled = (ziU8)index;
}
((ZiAlphaWork*)workData)->requiredLength = parameters->elementCount;
}
if ((parameters->letters != 0) && (parameters->maxCandidates == 1)) {
if ((parameters->getOptions & 0x81) == 0x81) {
wordCursor = parameters->candidates;
}
else if (outputLanguage == 0) {
wordCursor = (ziU16 *)0x0;
}
else {
else if (outputLanguage != 0) {
encodedOutput = (ziU8*)parameters->candidates;
wordCursor = candidateWord;
for (index = 0; encodedOutput[index] != '\0'; index = index + 1) {
wordCursor[index] = Zi8ConvertUC2WC(encodedOutput[index],outputLanguage,workData);
}
wordCursor[index] = 0;
} else {
wordCursor = 0;
}
if (wordCursor != (ziU16 *)0x0) {
Zi8SetHighlightedWordW(wordCursor,parameters->language,parameters->subLanguage,workData);
@@ -1632,17 +1624,16 @@ finishCandidates:
}
}
if (((ZiAlphaWork*)workData)->dictionaryCounts != 0) {
if ((int)dictionaryIndex < (int)(unsigned int)((ZiAlphaWork*)workData)->dictionaryCount) {
if ((int)dictionaryIndex >= (int)((ZiAlphaWork*)workData)->dictionaryCount) {
((ZiAlphaWork*)workData)->dictionaryCounts[((ZiAlphaWork*)workData)->dictionaryCount - 1] = candidateCount;
} else {
((ZiAlphaWork*)workData)->dictionaryCounts[dictionaryIndex] = candidateCount;
}
else {
((ZiAlphaWork*)workData)->dictionaryCounts[((ZiAlphaWork*)workData)->dictionaryCount - 1] = candidateCount;
}
countIndex = dictionaryIndex;
if ((int)(unsigned int)((ZiAlphaWork*)workData)->dictionaryCount <= (int)dictionaryIndex) {
if (countIndex >= ((ZiAlphaWork*)workData)->dictionaryCount) {
countIndex = ((ZiAlphaWork*)workData)->dictionaryCount - 1;
}
for (; 0 < (int)countIndex; countIndex = countIndex - 1) {
for (; countIndex >= 1; countIndex = countIndex - 1) {
((ZiAlphaWork*)workData)->dictionaryCounts[countIndex] =
((ZiAlphaWork*)workData)->dictionaryCounts[countIndex] -
((ZiAlphaWork*)workData)->dictionaryCounts[countIndex - 1];

View File

@@ -138,3 +138,44 @@ Additional near-match source trials in this continuation:
Retained PY component initialization in declaration order: 97.54777% versus 97.038216% at entry, 158/157 instructions. Initializing length first restored the lower baseline score; constant tone worsened it. Quick gate PASS, zero regressions. ZY retains six table-base register differences; no rejected source variant remains.
Final full gate over zi81key and zi8alpha: PASS, original DOL hash, identical pools, zero regressions, zero net forbidden patterns and readability warnings. zi81key remains 4/9 instruction-exact; exact code 2588/21460, exact data 1208/1388, weighted fuzzy 96.51463%. Entry exact data was 1160/1388. Final function scores: ZY 99.756096%, PY 97.54777%, alternate sound 99.82404%, spelling 96.82353%, candidates 94.64998%; the four exact functions remain exact. Both large bodies cover all original block regions. Remaining differences and rejected source variants are recorded above; no new exact function is claimed.
## Exactness continuation from a3b04ad9, 2026-09-30
Entry 4/9 instruction-exact. MatchAltSound1Key had 341/341 instructions, twelve differences exchanging the workspace and phonetic-table registers r25/r26. Recovered the shared generic workspace formal and cast only its field accesses to the local workspace structure. This preserves the API's original workspace type, with no extra pointer local. Result: objdiff 100.0%, 341/341 instructions, ctxdiff diffs 0. All other function scores unchanged. Quick gate PASS, identical pool, zero regressions.
Further exactness variants in this continuation (rejected unless explicitly retained):
- Zi8SpellingZY: unsigned long length; 99.756096%, src 0x1ec base 0x1ec insns 123/123.
- Zi8SpellingZY: index before table pointer in address expression; 99.756096%, src 0x1ec base 0x1ec insns 123/123.
- Zi8SpellingZY: signed length counter; 99.756096%, src 0x1ec base 0x1ec insns 123/123.
- Zi8SpellingPY: full-width tone switch expression; 97.54777%, src 0x278 base 0x274 insns 158/157.
- Zi8SpellingPY: repeated halfword normalization at tone switch; 97.54777%, src 0x278 base 0x274 insns 158/157.
- Zi8SpellingPY: full-width include-tone formal with byte test; 97.54777%, src 0x278 base 0x274 insns 158/157.
- Zi8SpellingPY: halfword key formal; 93.598724%, src 0x280 base 0x274 insns 160/157.
- Zi8SpellingPY: unsigned long tone temporary; 97.19745%, src 0x274 base 0x274 insns 157/157.
- Zi8SpellingPY: signed tone temporary; 97.19745%, src 0x274 base 0x274 insns 157/157.
- Zi8Get1KeyPressSpelling: generic workspace parameter with typed field access; 96.82353%, src 0x1a80 base 0x1a90 insns 1696/1700.
- Zi8Get1KeyPressSpelling: restore phonetic output candidate-loop increment; 96.882355%, src 0x1a84 base 0x1a90 insns 1697/1700.
ZY additionally tried generic output formal, unsigned-long and signed length counters, reversed index/table address operands and a typed final-spelling row structure: all retained 123/123 instructions and the same six differences, 99.756096%. Restored the ordinary two-dimensional table.
Retained the missing tableIndex increment after each converted phonetic candidate. The target increments this index before advancing past the string terminator; without it the source loop could fail to terminate. Spelling now 96.882355%, 1697/1700 instructions, frame 0x90. Quick gate PASS, zero regressions, identical pool.
Spelling follow-up variants: combined terminator-trimming while condition fell to 96.16765%; unsigned-long total counter and const phonetic-table pointer retained 96.882355%. Separating the two phonetic conversion stores from their pointer increments raised the score to 97.74117%, 1701/1700 instructions; first strict divergence moved from +0x20 to +0xa0 (branch displacement). Retained after quick gate PASS with zero regressions and identical pool.
Candidate workspace generic-formal variant retained 94.64998%, 2381/2397. Recovered Zi8IsDupWordW's three-argument prototype from its matched definition in zi8getc2.c: ziBool return, wide-string pointer, byte length and generic workspace. This supplies the original byte-argument narrowing at length-one calls and removes old-style-call promotion. Candidates rose to 94.779305%; spelling rose to 97.867645%, with all five exact functions preserved. Quick gate PASS, zero regressions.
Spelling postfix-compound-store retry fell to 96.805885%; capturing an element pointer before advancing fell to 95.17765% and enlarged the frame. Both rejected.
Candidate prefix-filter branch now emits the matching case before the failing case, as in the target. 94.87901%, 2384/2397 instructions, frame 0x140. Quick gate PASS, zero regressions; retained.
Candidate endian decoding: shift the explicitly narrowed high byte before adding the low byte, replacing multiplication by 0x100 in the sorted ordinal and ordinary character paths. This restores two target narrowing instructions and high-byte-first evaluation. 95.355446%, 2386/2397 instructions. Explicit duplicate-return byte casts did not change the prior score. Quick gate PASS, zero regressions; shift expressions retained.
Final rejected variants (restored the committed higher score after each):
- Zi8Get1KeyPressCandidates: prefix total candidate increment inside capacity comparison; 95.06467%, src 0x253c base 0x2574 insns 2383/2397.
- Zi8Get1KeyPressSpelling: merge nested language fallback conditions into else if; 97.867645%, src 0x1a90 base 0x1a90 insns 1700/1700.
Final retained scores: alternate sound 100%, ZY 99.756096%, PY 97.54777%, spelling 97.867645%, candidates 95.355446%. All large bodies are complete. ZY retains six table-address register differences; PY retains a register-held tone rather than the target halfword stack slot; spelling retains helper-result copies and output-cursor scheduling differences; candidates retain helper-result copies, matcher argument narrowing and counter/output scheduling. Each remaining function has more than three distinct source-level attempts recorded. Five of nine functions are instruction-exact.
Final full gate over both owned units: GATE PASS, full build ok, original DOL hash 26116613f624061ba99c8d1a299aaa6efa85670d, both pools identical, zero regressions, zero added forbidden patterns and zero readability warnings. zi81key exact functions 4/9 -> 5/9, exact code 2588 -> 3952 of 21460 bytes, exact data 1208/1388 unchanged, weighted fuzzy 96.5146% -> 97.1719%. zi8alpha exact functions 10/12 unchanged, exact code 5704/21664 and exact data 72/564 unchanged, weighted fuzzy 86.7764% -> 88.8508%. These are partial matching improvements; the remaining functions are not claimed exact.

View File

@@ -132,3 +132,35 @@ Highlighted-output audit: recovered the element-index length slot, the last-high
Dictionary-mode dispatch audit: replaced the reconstructed comparison chain with the target's switch, in address order: punctuation, OEM, UWD, alternate sound, completion/default, ROM/PUD. Restored the forward dictionary-kind scan with a body break and initialized scan position only on the dual-language path. 81.71363%, 3978/3946 instructions. Recovered previous-count-before-clear order, ordinary-dictionary-before-terminal-punctuation order and the secondary-pass skip switch: 81.86037%. Quick gate PASS, identical pool, zero regressions and readability warnings. Every engine exit and dictionary/prefix/suffix pass remains present.
Final full gate over both units: PASS. Alpha remains 10/12 instruction-exact; exact code 5704/21664, exact data 72/564, weighted fuzzy 86.776405%. Final engine score 81.86037%, 3978/3946 instructions, frame 0x2b0; first strict divergence +0x40, before the target's retry-flag initialization. Case conversion remains 99.09091% with eight register differences. All 330 emitted rodata bytes equal the target prefix; its remaining six bytes are trailing alignment, which was not reproduced with padding objects. The target's workspace-copy slot and some field meanings remain unresolved. All source functions are complete; no additional exact function or linked-unit completion is claimed.
## Exactness continuation from a3b04ad9, 2026-09-30
Entry engine 81.86037%, case conversion 99.09091%; unit 10/12 exact. Both units remain NonMatching. Workspace snapshot used for dictionary/helper calls restored the target scalar slot offsets but scored 81.77065%; making it const scored 81.71845%. A scoped phonetic-character cache scored 80.372025% and introduced a frame-pointer register. Rejected all three variants; no unused copy was added.
Flattened terminal-punctuation selection before the shared dictionary body rather than jumping backward from the loop tail: 82.4108%, 3975/3946 instructions. Target slots 0x84 at +0x1288 and +0x18e8 control the two punctuation/ROM mode checks; corrected those checks to use the corresponding current restriction variable instead of slot 0x88. Recovered word-length-first comparison, failure branch direction, digit-before-vowel branch and the explicit failed-length reset: 82.60162%. Recovered signed result limit and direct keyboard-layout tests; removed redundant dictionary-return casts: 82.613785%, 3976/3946, frame 0x2b0. Quick gate PASS, identical pool, zero regressions.
Finalization pass: restored count-only zero output before normal letters, the trailing punctuation loop's body break and decrement/count order, terminal dictionary-count branch direction and the stack-resident count-loop comparison. 84.43994%; reversed the prefix-history update and encoded-output/null branch: 84.59275%, 3978/3946 instructions. Arrays and frame still match. A keyboard-layout workspace alias scored 84.66067%, but was rejected: it primarily occupied the unused target word while adding a redundant alias, rather than recovering a demonstrated local use. The retained source has no added workspace placeholder. Quick gate PASS, zero regressions.
Further exactness variants in this continuation (rejected unless explicitly retained):
- Zi8ChangeWordCase: full-width language formal; 99.09091%, src 0xb0 base 0xb0 insns 44/44.
- Zi8ChangeWordCase: generic word buffer with typed cursor; 95.454544%, src 0xb4 base 0xb0 insns 45/44.
- Zi8ChangeWordCase: const workspace pointer parameter; 99.09091%, src 0xb0 base 0xb0 insns 44/44.
- Zi8ChangeWordCase: case flag initialized separately; 99.09091%, src 0xb0 base 0xb0 insns 44/44.
Nested phonetic range bounds left 84.59275% unchanged. Restored target positive web-prefix branch before the ordinary hyphen fallback: 84.599594%, 3978/3946, frame 0x2b0. Quick gate PASS, zero regressions; retained.
Removing the early dictionary-index initialization scored 84.626205%, but rejected after source review: early jumps to finalization can read the index before the dictionary loop initializes it. The safe initialization remains. Swapped the remembered-length comparison operands to match target load order and branch sense: 84.65154%, 3978/3946 instructions. Quick gate PASS, zero regressions; retained.
Direct tests for all vowel and punctuation helpers together fell to 84.5593%; rejected. Isolating the initial punctuation test avoids reusing the main index temporary for this Boolean result and raises 84.65154% to 84.70755%, 3978/3946, frame 0x2b0. Quick gate PASS, zero regressions; retained. Full-width case selector with explicit byte call argument remains 44/44, eight register differences, 99.09091%; rejected.
Final rejected variants (restored the committed higher score after each):
- Zi8ChangeWordCase: read-only workspace formal with generic helper argument; 99.09091%, src 0xb0 base 0xb0 insns 44/44.
- Zi8AlphaGetCandidates: signed remembered length comparison against input minus one; 84.59503%, src 0x3e28 base 0x3da8 insns 3978/3946.
- Zi8AlphaGetCandidates: typed workspace local for structure field access; 84.00431%, src 0x3e2c base 0x3da8 insns 3979/3946.
- Zi8AlphaGetCandidates: typed workspace field view in recovered scalar declaration order; 84.04105%, src 0x3e2c base 0x3da8 insns 3979/3946.
Final retained alpha engine: 84.70755%, frame 0x2b0, 3978/3946 instructions. Every body region is present. Scalar slots remain four bytes below target; the original stores a workspace snapshot at stack 0x20 that is never loaded. Tried used generic snapshots and typed field views; they altered call or field register allocation and lowered the score. No unused snapshot or padding was introduced. Remaining structural differences include phonetic range-load reuse, result copies, punctuation/dictionary branches and cursor scheduling. Case conversion retains eight register swaps in 44/44 instructions, 99.09091%; multiple formal, selector, cursor and loop variants do not resolve them. Ten of twelve functions remain exact.
Final full gate over both owned units: GATE PASS, full build ok, original DOL hash 26116613f624061ba99c8d1a299aaa6efa85670d, both pools identical, zero regressions, zero added forbidden patterns and zero readability warnings. zi81key exact functions 4/9 -> 5/9, exact code 2588 -> 3952 of 21460 bytes, exact data 1208/1388 unchanged, weighted fuzzy 96.5146% -> 97.1719%. zi8alpha exact functions 10/12 unchanged, exact code 5704/21664 and exact data 72/564 unchanged, weighted fuzzy 86.7764% -> 88.8508%. These are partial matching improvements; the remaining functions are not claimed exact.