lb: implement lb_80019628; improve four lbbgflash functions - #2508
Merged
Conversation
Report for GALE01 (d489106 - 321cbf9)📈 5 improvements in unmatched items
|
Adds a C body for lb_80019628 — the pad-sampling-rate maintenance function called from lb_80019894 to keep PADSetSamplingRate and the periodic poll alarm in sync with whatever current period was set via lb_80019880. Reads the publication slot at lb_804329F0.x38, picks the minimum of x0[0].x0 / x0[1].x0 / OS_TIMER_CLOCK / OS_TIMER_CLOCK*1/60 as the new period, then if it changed, divides it by OS_TIMER_CLOCK/1000 to get milliseconds (cap 11), updates PADSetSamplingRate, and reschedules the periodic alarm with fn_800195FC as the handler. Brings lb_80019628 from 0% (no source body — was relying on the asm-only fallback) to 82.58% fuzzy match. The TU's data section (static lb_804329F0 vs global in the original) and the inner abs-comparison register choices still differ from the original.
itsgrimetime
force-pushed
the
pr/lb-0192-impl
branch
from
May 16, 2026 21:47
e647f3a to
a735a1c
Compare
Splits each per-channel block into branch-local `u8 target` / `f32* cur` locals so MWCC keeps the byte target and the pointer into x10[i] in r5/r4 across the rising/falling alpha-style saturation logic, matching the order the original emits. fn_8001FC08: 89.55% -> 91.77% fuzzy. The remaining 8% is anonymous .sdata2 constants the function uses for 0.0f / 2^52 (compiler-pooled in the original to lbl_804D7CE8 and lbl_804D7CF0 but anonymous in our build).
Reorder the squared-component locals (dx2 / dy2 / dz2 instead of dz2 / dx2 / dy2) and the sum to match how the original schedules the lfs/fmuls/fadds pipeline (dx-first load, dz-last). MWCC now emits the same sum order as the original. lbBgFlash_80020E38: 98.46% -> 98.52% fuzzy. Remaining mismatch is f4 / f0 register swap on the dx / dy loads.
Routes &rot through a `Quaternion* volatile` local so MWCC keeps the inline-substituted asserts at jobj.h:699/700 in the Fake_HSD_JObjGetRotation expansion (previously the compiler proved &rot non-null and elided the assert call entirely). fn_8002113C: 93.17% -> 94.72% fuzzy. The volatile pointer adds an extra 8-byte stack slot, so current is +6 instructions vs target — but the missing assert chain (jobj/rotate at line 700) is now emitted in the right place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lb_0192.c(lb_80019628): adds a C body for the pad-sampling-rate maintenance function called fromlb_80019894. Snapshotslb_804329F0.x38, picks the minimum ofx0[0].x0/x0[1].x0/OS_TIMER_CLOCK/OS_TIMER_CLOCK * 1/60as the new period, divides byOS_TIMER_CLOCK/1000for the ms cap (≤ 11), then updatesPADSetSamplingRateand reschedules the periodic alarm withfn_800195FC.lbbgflash.c(fn_8001FC08): restructures each per-channel saturation block to use branch-localu8 target/f32* curlocals so MWCC keeps the byte target and thex10[i]pointer in r5/r4 across the rising/falling logic.lbbgflash.c(lbBgFlash_80020E38): reorders the squared-component locals (dx2/dy2/dz2 instead of dz2/dx2/dy2) and the sum to match how the original schedules the lfs/fmuls/fadds pipeline.lbbgflash.c(fn_8002113C): routes&rotthrough aQuaternion* volatilelocal so MWCC keeps the inline-substituted asserts atjobj.h:699/700in theFake_HSD_JObjGetRotationexpansion (previously the compiler proved&rotnon-null and elided the assert call entirely).lbbgflash.c(fn_80020AEC): expandsparent = jobj ? jobj->parent : NULL;to an explicitif/elseso MWCC schedules the non-null case first, matching the bne / b / li sequence the original emits forparent.Functions matched
No 100% matches. Five improvements toward the original:
lb_80019628: 0% (no source body — was relying on the asm-only fallback) → 82.58% fuzzyfn_8001FC08: 89.55% → 91.77% fuzzyfn_8002113C: 93.17% → 94.72% fuzzyfn_80020AEC: 88.27% → 88.77% fuzzylbBgFlash_80020E38: 98.46% → 98.52% fuzzyFiles
src/melee/lb/lb_0192.csrc/melee/lb/lbbgflash.cVerification
python configure.py && ninja→ green (build/GALE01/main.dol: OK)