From 3a33bb3e51a6cad318f1396646916045581bc51d Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 9 Oct 2026 17:19:30 +0000 Subject: [PATCH] cleanup(keyboard): document required Hangul stub, rename stand-in and zero local, drop glyphBottom temp (worker ffc2272c) --- src/keyboard/tiInputForm.cpp | 22 +++++---- src/keyboard/tiString.cpp | 3 +- tools/decomp-assist/cleanup-c7.attempts.md | 52 ++++++++++++++++++++++ 3 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 tools/decomp-assist/cleanup-c7.attempts.md diff --git a/src/keyboard/tiInputForm.cpp b/src/keyboard/tiInputForm.cpp index 2e0f3334..d64c266a 100644 --- a/src/keyboard/tiInputForm.cpp +++ b/src/keyboard/tiInputForm.cpp @@ -315,8 +315,7 @@ static inline f32 scaledExtent(f32 scale, f32 start, f32 end) { } static inline f32 glyphBottom(f32 origin, const Base::DrawInfo& glyph, const nw4r::math::VEC2& scale) { - f32 extent = glyph.rect.GetHeight(); - return origin + scale.y * extent; + return origin + scale.y * glyph.rect.GetHeight(); } } // namespace inputform @@ -1361,10 +1360,8 @@ void Base::makeUpCursorPos(CursorPos* cursorPos, u32 pos, s32 startLine, s32 end muWordWrapCounter = wordWrapCounter; } -// The original file had an uncalled function here that the linker stripped, so its body -// is lost. It called getDrawModifyEndLine and getEndPos and was the first user of 0.5f, -// which places those inline copies and the constant; this stand-in keeps that order. -f32 strippedFunctionStandIn(Base* base) { +// MWCC needs this unreferenced stand-in for a lost function to emit the getters and 0.5f in target order. +f32 preserveStrippedFunctionLayout(Base* base) { base->getDrawModifyEndLine(); base->getEndPos(); return 0.5f; @@ -1827,7 +1824,8 @@ void Base::drawCursor(f32 x, f32 y) { } u32 Base::calcCursorPos(f32 x, f32 y) { - f32 zero; + // MWCC needs this local declared first and assigned before the loop to preserve FPR allocation. + f32 rectZero; f32 cursorX; f32 lineTop; f32 lineBottom; @@ -1841,13 +1839,13 @@ u32 Base::calcCursorPos(f32 x, f32 y) { u32 pos = 0; muWordWrapCounter = 0; mbHyphen = false; - zero = 0.0f; + rectZero = 0.0f; while (*string) { DrawInfo info; - info.rect.left = zero; - info.rect.top = zero; - info.rect.right = zero; - info.rect.bottom = zero; + info.rect.left = rectZero; + info.rect.top = rectZero; + info.rect.right = rectZero; + info.rect.bottom = rectZero; info.character = *string; calcRect(info); lineBottom = glyphBottom(lineTop, info, scale); diff --git a/src/keyboard/tiString.cpp b/src/keyboard/tiString.cpp index a3715993..053e4e64 100644 --- a/src/keyboard/tiString.cpp +++ b/src/keyboard/tiString.cpp @@ -141,8 +141,7 @@ wchar_t StringBase::getLastWChar() { } namespace { -// State of a Hangul syllable under composition. This build has no Hangul -// composer, so the state is always empty and each key is committed as typed. +// MWCC needs these aggregate tests and dead stores for Hangul scheduling and count narrowing. struct HangulSyllable { u32 length; diff --git a/tools/decomp-assist/cleanup-c7.attempts.md b/tools/decomp-assist/cleanup-c7.attempts.md new file mode 100644 index 00000000..71f73766 --- /dev/null +++ b/tools/decomp-assist/cleanup-c7.attempts.md @@ -0,0 +1,52 @@ +# cleanup-c7 keyboard cleanup + +Worktree `sol-high`, branch `agent/w1009/cleanup-c7`, base `f1db6b65`. +Read cleanup-common.md, o-tistr.attempts.md, o-ifl.attempts.md and o3-keyboard.attempts.md before trials. +Initial full 43U build passed. DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`; `DECOMPLETE_OK`. +Baseline tiString 42/42 exact, code 5176/5176, data 288/288; tiInputForm 221/221 exact, code 50656/50656, data 3772/3772. +Both units are Matching and every reported section is 100%. Preexisting untracked rx4/rx59/rx70 artifacts are preserved. + +## Retained changes + +- tiString.cpp replaces the unsupported composer explanation with one compiler comment. The aggregate tests and dead stores remain because removing each one changes .text. CharacterOutput and its reset method were already absent at this base; the newline reset is composing.clear(). +- tiInputForm.cpp removes glyphBottom's extent temporary, renames strippedFunctionStandIn to preserveStrippedFunctionLayout, and shortens its explanation to one line. The external stand-in remains because deleting it or making it static changes getter emission order and .sdata2. +- calcCursorPos's zero local becomes rectZero. Its first declaration and assignment before the loop remain, with one comment explaining the FPR allocation requirement. scaledExtent retains its extent local because a direct return changes 28 instructions. +- include/keyboard/tiString.h and include/keyboard/tiInputForm.h are unchanged. The retained source needs no declaration changes; inline/vtable ownership remains as established by o-tistr and o-ifl. + +## Compiled trials + +Each trial used the real source path and rebuilt only its owned 43U object. Allocated section sizes and bytes were compared with fresh baseline objects. Every rejected trial was restored. + +| Trial | Function instruction differences | Changed allocated sections | Result | +| --- | ---: | --- | --- | +| hangul-no-empty-test | 73/136 | .text | rejected and restored | +| hangul-no-newline-reset | 71/136 | .text | rejected and restored | +| hangul-no-next-state | 65/136 | .text | rejected and restored | +| hangul-no-dead-next-store | 65/136 | .text | rejected and restored | +| hangul-no-dead-length-store | 30/136 | .text | rejected and restored | +| hangul-direct | 73/136 | .text | rejected and restored | +| hangul-explicit-count-narrowing | 30/136 | .text | rejected and restored | +| extent-direct-return | 28/326 | .text | rejected and restored | +| glyph-bottom-direct-return | 0/326 | none | retained in final cleanup | +| calc-no-zero-local | 8/326 | .text | rejected and restored | +| calc-zero-at-declaration | 35/326 | .text | rejected and restored | +| calc-direct-geometry | 41/326 | .text | rejected and restored | +| calc-direct-height | 31/326 | .text | rejected and restored | +| calc-direct-width | 32/326 | .text | rejected and restored | +| remove-stripped-function | 0/326 | .text, .sdata2 | rejected and restored | +| static-stripped-function | 0/326 | .text, .sdata2 | rejected and restored | +| count-with-length-local | 30/136 | .text | rejected and restored | +| count-with-terminator-index | 31/136 | .text | rejected and restored | +| count-before-terminator | 30/136 | .text | rejected and restored | +| count-with-narrowed-output-index | 31/136 | .text | rejected and restored | + +## Verification + +Final tiString and tiInputForm allocated section sizes and bytes equal the full-build baseline. +pool_diff: tiString and tiInputForm pools IDENTICAL. +ctxdiff: inputChar 136/136 instructions, diffs 0; calcCursorPos 326/326 instructions, diffs 0. +Focused diff and git diff --check passed. Final gate --quick passed with 0 regressions, 0 forbidden-pattern additions and 0 readability warnings. +Fresh build/43U/report.json and build/43U/ok passed; completion checker returned DECOMPLETE_OK. +Final tiString 42/42 and tiInputForm 221/221 instruction-exact; every reported section is 100%, both units fully linked. +Global report measures equal the fresh pre-cleanup baseline. DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. +Source commits: tiString 06b51c30; tiInputForm 77341408. Final gate output: /tmp/cleanup-c7-final-gate.txt. -- 2.49.1