diff --git a/libs/RVLMiddleware/eZiText/src/clib/Zi8punct.c b/libs/RVLMiddleware/eZiText/src/clib/Zi8punct.c index 2f9e519a..50a21fd0 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/Zi8punct.c +++ b/libs/RVLMiddleware/eZiText/src/clib/Zi8punct.c @@ -1,5 +1,20 @@ #include +typedef struct { + ziU8 countOnly; + ziU8 maxWordLength; + ziU8 lookupMode; + ziU8 suffixOnly; + ziU8 controls[8]; + ziU32 maxCount; + ziU16 capacity; + ziU8 minWordLength; + ziU8 flags; + ziU16 candidateCapacity; + ziU8 checkOnly; + ziU8 reserved; +} ZiCandidateOptions; + const ziWChar Zi8PunctTable[40] = { 0xFF0C, 0x3002, 0x3001, 0xFF1A, 0xFF1F, 0xFF01, 0x3005, 0x2026, 0x2015, 0xFF1B, 0xFF0E, 0x30FB, 0x201C, 0x201D, 0xFF08, 0xFF09, @@ -8,8 +23,8 @@ const ziWChar Zi8PunctTable[40] = { 0xFFE1, 0x20AC, 0x203B, 0xFF20, 0x0000, }; -ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) { - ziS32 limit = ((ziU16*)__zi8_work_data)[8] - 1; +ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) { + ziS32 limit = ((ZiCandidateOptions*)options)->capacity - 1; ziS32 count = 0; ziU8 i = 0; ziU16 fc = param->firstCandidate; @@ -21,7 +36,7 @@ ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) { } if (fc == 0) { count++; - if (ZI_WORK->getcPhase == 0) { + if (((ZiCandidateOptions*)options)->countOnly == 0) { param->candidates[i++] = Zi8PunctTable[j]; if ((param->context & 0x10) != 0) { param->candidates[i++] = 0x20; @@ -33,7 +48,7 @@ ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) { break; } } else { - if (count >= (ziS32)ZI_WORK->targetCount) { + if (count >= (ziS32)((ZiCandidateOptions*)options)->maxCount) { return count; } } @@ -42,7 +57,7 @@ ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) { } j++; } - if (ZI_WORK->getcPhase == 0) { + if (((ZiCandidateOptions*)options)->countOnly == 0) { param->letters = count; } return count; diff --git a/libs/RVLMiddleware/eZiText/src/clib/zi8initd.c b/libs/RVLMiddleware/eZiText/src/clib/zi8initd.c index ab30b5d9..5b69bef4 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zi8initd.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zi8initd.c @@ -62,7 +62,7 @@ ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) { return 1; } -ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len) { +ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len ZI_NEED_WORK) { if ((ziU16)len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 && p[3] == 0x6F && p[4] == 0x72 && p[5] == 0x70) { return 1; diff --git a/tools/decomp-assist/allhands-ezitext-punctuation-options.attempts.md b/tools/decomp-assist/allhands-ezitext-punctuation-options.attempts.md new file mode 100644 index 00000000..2ac1e79b --- /dev/null +++ b/tools/decomp-assist/allhands-ezitext-punctuation-options.attempts.md @@ -0,0 +1,83 @@ +# Punctuation options receiver, 2026-10-03 + +Base: bf8ebfa3. Owned source: Zi8punct.c only. This is a source-contract +correction with unchanged generated code and no percentage gain. + +## Actual call and receiver + +All original-object references show exactly one executable caller, +Zi8GetCandidatesOrCount, plus the punctuation function's exception-index +reference. At that call the fixed ABI positions are: + +- r3: the candidate request +- r4: the candidate options object +- r5: the workspace + +The dispatcher preserves these three incoming pointers separately. Its +_GetCandidates/_CheckCandidates producers create the existing 24-byte +ZiCandidateOptions object, initialize capacity from the workspace, and pass +its address as the second argument. The dispatcher then writes maxCount +from the workspace before calling the punctuation helper. + +The punctuation target reads a byte at options +0, a word at options +0x0C, +and a halfword at options +0x10. These are countOnly, maxCount and capacity. +It overwrites incoming r5 before reading it, so the third workspace formal +is present in the caller contract but unused by this implementation. + +The reconstructed definition previously omitted that third formal and named +the second argument workspace. It consequently described options accesses +using unrelated workspace fields at coincidentally equal offsets. + +## Minimal correction + +Copy the existing private ZiCandidateOptions type verbatim from zi8getc2.c; +no shared header or producer is changed. Its complete layout is reused, +including its established fields, without introducing any object, extra +storage or invented padding. A fixed-target-width layout check confirms +size 24 and the three accessed offsets 0/0x0C/0x10. + +The definition now takes request, opaque options and workspace, and accesses +the real options fields through the private view. Its ziU32 result agrees +with the sole caller's declaration. All locals, comparisons, loops, output +stores and branch directions remain unchanged. The unused workspace formal +recovers an argument already supplied by the target caller; it does not +manufacture state or instructions. + +## Verification + +Fresh configured 43U baseline and candidate full builds pass with the approved +wrapper and WIBO_SJIS_MISSING_IMPORTS=1. Pool first: identical and empty. +All allocated payloads and canonical relocations are baseline-identical: +.text 300, .rodata 80, extab 8 and extabindex 12 bytes. The only complete-object +difference is two anonymous symbol-number characters in nonallocated .strtab. +All other 1,026 source objects are byte-identical to baseline. + +Zi8Punctuation stays 75/75 instructions with ctxdiff zero differences. Unit +code 300/300, data 100/100, and 1/1 exact functions remain 100%. The entire +1,027-unit objdiff report is unchanged. Full 43U DOL SHA1 remains +26116613f624061ba99c8d1a299aaa6efa85670d. git diff --check passes. + +Private evidence: /tmp/ezi-options-punct-{report.json,build.log,verification.txt}, +/tmp/ezi-options-baseline.json and /tmp/ezi-new-receiver-refs.txt. +No remote changes, other-region builds, assembly, linking flags, forced +registers, volatile, dummy assignments or shared-header edits. + +## Broader read-only ABI audit + +The original-object call inventory covered 20 remaining nonexact functions, +excluding the already resolved one-key/PUD/conversion work: 337 direct calls +and one OEM callback. A symbolic-expression comparison pins each value to +its actual ABI argument register and outgoing stack slot; it does not apply +a global argument-register permutation. After applying only the previously +proven alpha scalar-frame offset mapping, all 338 call argument expressions +agree. The callback's four arguments and stored callback target also agree. +No external tail branch was found; indirect non-call branches are switches. +A separate incoming-register/stack-use audit found no additional live +argument beyond a callee's reconstructed parameter list. These are diagnostic +checks, not a formal whole-program equivalence proof. + +The declaration/definition scan identified the separate missing workspace +formal on Zi8IsZicorpSignature. Three exact version-query helpers also have +old-style empty definitions despite receiving an unused workspace in their +exact caller; those are outside this candidate. No allocation experiments +were performed. diff --git a/tools/decomp-assist/allhands-ezitext-signature-work-formal.attempts.md b/tools/decomp-assist/allhands-ezitext-signature-work-formal.attempts.md new file mode 100644 index 00000000..d1843fbc --- /dev/null +++ b/tools/decomp-assist/allhands-ezitext-signature-work-formal.attempts.md @@ -0,0 +1,35 @@ +# Signature-check workspace formal, 2026-10-03 + +Parent: 8a0aa7ce; its punctuation-options correction is preserved unchanged. +Owned source: zi8initd.c / Zi8IsZicorpSignature only. + +The local declaration in zi8alpha.c takes word, halfword length and workspace. +An original-object reference scan finds exactly one caller and no function +pointer or other address escape. The target AlphaGetCandidates call puts the +word in r3, narrows the length into r4, and moves its preserved workspace into +r5 immediately before calling Zi8IsZicorpSignature. + +The callee's current definition omitted the third formal. Its target reads +only r3/r4; r5 never appears anywhere in its 48 instructions. It has no calls +or tail target. Add the existing ZI_NEED_WORK formal to align the definition +with the actual caller and its declaration. The argument is genuinely passed +but unused. No local, assignment, storage, volatility or forced spill is added. +The body and all other declarations remain unchanged. + +Validation after this separate change: +- The complete zi8initd object is byte-identical to the fresh baseline +- Zi8IsZicorpSignature remains 48/48 instructions, ctxdiff zero differences +- Zi8InitializeDynamic remains 128/128 instructions, ctxdiff zero differences +- Unit code 704/704, data 20/20 and 2/2 exact functions remain 100% +- The complete 1,027-unit report is identical to baseline and the preceding + punctuation-only report; all source objects except punctuation's already + documented nonallocated symbol-name difference are byte-identical +- Owned allocated sections and canonical relocations are unchanged +- Pool is identical and empty; full configured 43U build passes +- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d +- git diff --check passes + +This is contract reconstruction only, with no percentage gain. No shared +header, caller, linking flag, assembly, other-region build or remote change. +Private evidence: /tmp/ezi-options-signature-{report.json,build.log,verification.txt} +and /tmp/ezi-new-receiver-refs.txt.