From aee0e0db8822bc36d74c4d116dc1085073b82d5b Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 9 Oct 2026 09:19:55 +0000 Subject: [PATCH] decomp(tistring): inputChar output builder newline handling (73 -> 13) (worker 05e02e12) --- src/keyboard/tiString.cpp | 5 +- tools/decomp-assist/g-keyboard.attempts.md | 69 ++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/keyboard/tiString.cpp b/src/keyboard/tiString.cpp index 177f70b7..aaace1c6 100644 --- a/src/keyboard/tiString.cpp +++ b/src/keyboard/tiString.cpp @@ -149,6 +149,9 @@ public: } void append(wchar_t ch) { + if (ch == L'\n') { + mCount = 0; + } mpOutput[mCount++] = ch; } @@ -159,7 +162,7 @@ public: private: wchar_t* mpOutput; - u32 mCount; + u16 mCount; }; } diff --git a/tools/decomp-assist/g-keyboard.attempts.md b/tools/decomp-assist/g-keyboard.attempts.md index e7bf365b..431a7455 100644 --- a/tools/decomp-assist/g-keyboard.attempts.md +++ b/tools/decomp-assist/g-keyboard.attempts.md @@ -37,3 +37,72 @@ Initial gate after retained changes: GATE PASS, zero regressions, zero forbidden Final GATE PASS: full 43U build ok; DOL 26116613f624061ba99c8d1a299aaa6efa85670d; identical pools; all owned data sections 100%; 0 regressions; 0 forbidden-pattern additions; 0 readability warnings. No exact function gains. Units remain NonMatching. Height helper chaining gave 81 differences and was rejected. Final instruction counts remain calcCursorPos 8/326, create 120/356, inputChar 73/136. + + +## Round b, MAX, 2026-10-09 + +Assigned worktree data-d4, branch agent/w1009/g2-keyboard, HEAD 5046adc6. +Read opus-common.md and this log again. Preserved preexisting untracked files. +Fetched origin under /tmp/wii-git.lock; origin/main moved to ad5b9dea during setup. +Round-a source remains the starting point. Fresh full 43U build passed with DOL +26116613f624061ba99c8d1a299aaa6efa85670d. Both owned pools are identical. +Baseline report: tiInputForm 219/221 exact, data 3772/3772; tiString 41/42 exact, +data 288/288. calcCursorPos has 8/326 differences, all f29/f30 swapping scale.x +and the glyph zero constant. create has 120/356; inputChar has 73/136. +Reviewed the prior single/pair pragma sweep rather than repeating its unchanged +source candidates. Read the original-object Ghidra bodies, prior allocator trace, +levers, and saved inputChar diffs. Used graphify only to check cursor callers; +current source and object measurements remain the matching evidence. + +calcCursorPos: 240 new compiled forms covered rectangle-based width helpers, +scale-vector parameter forms, a nested axis-scaling helper, and explicit zero +arguments for glyph initialization. The best stays 8/326. Vector parameters put +the zero constant in f29, but swap scale.x/scale.y in f30/f31 and alter scheduling +at wrap transitions, leaving at least 25 differences. Explicit zero arguments +preserve the eight-difference baseline. None retained. + +create: 32 new detached-row and normal-button construction helper forms compiled. +The best remains 120/356; detached-row forms give 123, and copying button data +regresses code generation. None retained. Private compiler source paths rename +__sinit_\tiInputForm_cpp; that name-only difference was excluded from the private +regression counter. Final measurement uses the real source path. + +calcCursorPos: 32 additional value-returning glyph initialization helper trials; +30 compile and change stack placement/instruction count. Two harness-invalid +named-zero aggregate forms are excluded. None retained. + +inputChar: the saved R1 diff remeasures at 61/136 and 0x21c, not the historic 12, +on the current source. A real CharacterOutput::clear loop plus a u16 member count +reaches 13/136 with equal 0x220 size and no other function drops. It clears prior +buffer characters before resetting the count when a newline is appended. The +caller appends one character to a fresh output, so its observable output is the +same as the baseline. This is a lead under review, not an exact match. + +The clearing loop is unnecessary for the 13-difference result. Removed it and +kept only newline reset in the existing append method and a u16 member count. +This minimal form independently rebuilds to 0x220, 136/136 instructions, 13 diffs. +It reconstructs the newline test proved by target instruction 68, cmplwi r4,0xa. +The target has no consuming branch; our remaining bne/li and counter allocation +are explicitly unresolved. All 13 differences are at instructions 66-78. Both +cursor-add paths now match without extra helpers. The caller constructs an empty +output and appends one character; resetting its count on newline preserves the +output for every character, including newline and the ignored 0xfffe sentinel. +The count is bounded by the 8-element buffer and is narrowed in the target. + +32 finish/count/index forms, 48 cursor-advance forms, 24 further real clear-loop +forms, 48 output-write helper forms, and 180 scoped single/pair pragma forms do +not beat 13. No loops, output-write helpers, cursor helpers, or pragmas retained. +48 coupled scale-vector/height-helper forms do not beat calcCursorPos 8; their +best is 25. Every rejected source/header experiment stays outside the worktree. +Private trial records: 712 attempts, 710 compiled. Two named-zero aggregate factory trials fail to compile and are excluded. Raw records are in /tmp/g-keyboard-b-results.jsonl. + +Final round-b verification: GATE PASS, full 43U build ok, DOL SHA1 +26116613f624061ba99c8d1a299aaa6efa85670d. Pools identical; all owned data sections +100%; 0 regressions; 0 forbidden-pattern additions; 0 readability warnings. +Gate output: /tmp/g-keyboard-b-final-gate.txt. +Fresh exact-name objdiff: calcCursorPos 99.877304%, create 98.16011%, inputChar +90.757355% -> 93.55882%. odiff/ctxdiff inputChar 73 -> 13, size 0x220 both, +136/136 instructions. tiInputForm stays 219/221 exact and tiString stays 41/42. +No new exact functions. Both units remain NonMatching; no Matching flip is valid. +Retained changes: src/keyboard/tiString.cpp and this log only. No push, PR, merge, +rebase, other-worktree edit, or modification of preexisting untracked files. -- 2.49.1