WIP decomp(kpad): preserve read refinements alongside exact DPD #1014

Merged
coah80 merged 1 commits from agent/bittle/kpad-filter-flow into main 2026-10-03 01:58:37 +00:00
coah80 commented 2026-10-03 01:29:57 +00:00 (Migrated from github.com)

Review follow-up

Rebased on 7b8dbf2c and removed the calc_dpd_variable rewrite. Main's newly exact function is preserved byte-for-byte (250 instructions, 100%). This remains draft/WIP: it does not yet meet the requested new-exact-function review bar.

Retained source reconstruction

Smoothing sign flow and extension-sample guard boundaries in read_kpad_acc; pre-clear copy counter, gravity validation order and narrowed extension-button data flow in KPADRead.

Independent verification

  • read_kpad_acc: 99.85%, 400/400 instructions; the remaining cmpwi/cmplwi equality difference is unresolved. Natural guard variants were tested and discarded rather than forcing the opcode
  • KPADRead: 98.09151%
  • Unit: 99.22794% → 99.515625%; 26/29 exact functions, 8880 exact code bytes and 8032 data bytes preserved
  • Parent comparison confirms calc_dpd_variable remains identical and no report regressions
  • Guard/button model checks: 4096 and 196608 cases; previousButtons is u16, with arbitrary 32-bit extension/cached values covered
  • Gravity fields are s16; pair products fit signed32 and both evaluation orders are defined exactly when the same triple product fits; 729 boundary triples checked
  • Full 43U all_source/report/progress/DOL, literal and worktree checks pass

No new exact function, header, metadata, compiler flag or linking change. The removed DPD rewrite is not part of this revision.

Parent baseline: 7b8dbf2c96
Tested tree: 85cda4ce7c
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d

No merge performed or requested by this author.

Note

Restructure KPAD read and smoothing code in KPAD.c for exact DPD match

  • Decompiling work in KPAD.c to match the original assembly while keeping behavior identical
  • Rewrites the inline smoothing helper in smooth_acc_value with explicit declarations and a conditional branch instead of a ternary
  • Splits the error, device, and data-format checks in read_kpad_acc into separate statements, with a switch for format 5
  • Reorders validation and assignments in KPADRead, and computes the 16-bit extension button truncation once before the hold-state update and XOR
  • Behavioral Change: only source-level operand ordering and statement reordering; shown data flow and integer results are preserved

Macroscope summarized 87c58cc.

## Review follow-up Rebased on 7b8dbf2c and removed the calc_dpd_variable rewrite. Main's newly exact function is preserved byte-for-byte (250 instructions, 100%). This remains draft/WIP: it does not yet meet the requested new-exact-function review bar. ## Retained source reconstruction Smoothing sign flow and extension-sample guard boundaries in read_kpad_acc; pre-clear copy counter, gravity validation order and narrowed extension-button data flow in KPADRead. ## Independent verification - read_kpad_acc: 99.85%, 400/400 instructions; the remaining cmpwi/cmplwi equality difference is unresolved. Natural guard variants were tested and discarded rather than forcing the opcode - KPADRead: 98.09151% - Unit: 99.22794% → 99.515625%; 26/29 exact functions, 8880 exact code bytes and 8032 data bytes preserved - Parent comparison confirms calc_dpd_variable remains identical and no report regressions - Guard/button model checks: 4096 and 196608 cases; previousButtons is u16, with arbitrary 32-bit extension/cached values covered - Gravity fields are s16; pair products fit signed32 and both evaluation orders are defined exactly when the same triple product fits; 729 boundary triples checked - Full 43U all_source/report/progress/DOL, literal and worktree checks pass No new exact function, header, metadata, compiler flag or linking change. The removed DPD rewrite is not part of this revision. Parent baseline: 7b8dbf2c96aa9b4490df35932850c59886f76be3 Tested tree: 85cda4ce7c0a206308ae830e23c68248e1885566 DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d 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] > ### Restructure KPAD read and smoothing code in `KPAD.c` for exact DPD match > - Decompiling work in [KPAD.c](https://github.com/coah80/wii-ipl/pull/1014/files#diff-ceae62ef73ab70e3d54cbce1f59e5557d54bc68de679f1a99027a9dff0b29766) to match the original assembly while keeping behavior identical > - Rewrites the inline smoothing helper in `smooth_acc_value` with explicit declarations and a conditional branch instead of a ternary > - Splits the error, device, and data-format checks in `read_kpad_acc` into separate statements, with a switch for format 5 > - Reorders validation and assignments in `KPADRead`, and computes the 16-bit extension button truncation once before the hold-state update and XOR > - Behavioral Change: only source-level operand ordering and statement reordering; shown data flow and integer results are preserved > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 87c58cc.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 01:32:09 +00:00 (Migrated from github.com)

Orchestrator review: the gate passes (DOL hash OK, 0 regressions), but this no longer rebases. #1012 just landed calc_dpd_variable at 100% (midpoint factor, in-place distance gain, projected-coordinate stages). Please rebase onto current main and keep main's calc_dpd_variable as is; the daemon re-gates on every new head.

Your read_kpad_acc at 99.85% with one signed/unsigned compare left is close. Check the declared type of the compared field/local (u8 vs s8, or u16 vs s16): cmplw vs cmpw follows the operand types. Note that fuzzy-only improvements don't land on their own: the PR needs at least one new exact function and no drops.

Orchestrator review: the gate passes (DOL hash OK, 0 regressions), but this no longer rebases. #1012 just landed `calc_dpd_variable` at **100%** (midpoint factor, in-place distance gain, projected-coordinate stages). Please rebase onto current `main` and keep main's `calc_dpd_variable` as is; the daemon re-gates on every new head. Your `read_kpad_acc` at 99.85% with one signed/unsigned compare left is close. Check the declared type of the compared field/local (u8 vs s8, or u16 vs s16): `cmplw` vs `cmpw` follows the operand types. Note that fuzzy-only improvements don't land on their own: the PR needs at least one new exact function and no drops.
coah80 commented 2026-10-03 01:58:35 +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.