From b6f06005e938ea163cfd65d3a8ccd8c85ca3c4ea Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 2 Oct 2026 18:46:39 -0500 Subject: [PATCH 1/2] decomp(bs2): preserve update publications and repeated entry reads --- include/BS2/BS2Update.h | 2 +- src/BS2/BS2Update.c | 4 +- .../bs2-update-publication-20261002.md | 96 +++++++++++++++++++ 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 tools/decomp-assist/bs2-update-publication-20261002.md diff --git a/include/BS2/BS2Update.h b/include/BS2/BS2Update.h index 6ca1511a..e1ae825a 100644 --- a/include/BS2/BS2Update.h +++ b/include/BS2/BS2Update.h @@ -24,7 +24,7 @@ typedef struct BS2UpdateHeader { typedef struct BS2UpdateEntry { // Update Meta Data - u32 type; // 0x00 + vu32 type; // 0x00 u32 attr; // 0x04 u32 size; // 0x08 u32 depend; // 0x0C diff --git a/src/BS2/BS2Update.c b/src/BS2/BS2Update.c index 7dd6e7e5..35d41942 100644 --- a/src/BS2/BS2Update.c +++ b/src/BS2/BS2Update.c @@ -23,10 +23,10 @@ s32 WADImportDVDForBS(const char* path, void* buffer, u32 length); s32 WADImportDVDExForBS(const char* path, void* buffer, u32 length); static BS2UpdateEntry* pEntries = NULL; -static u32 EntriesCount = 0; +static volatile u32 EntriesCount = 0; static u32* pFlags = NULL; static void* MemAllocator = NULL; -int State = 0; +volatile int State = 0; BS2UpdateEntry* CurrentEntry = 0; static u32 RebootRequired = 0; static BOOL ContainsSeatTitles = 0; diff --git a/tools/decomp-assist/bs2-update-publication-20261002.md b/tools/decomp-assist/bs2-update-publication-20261002.md new file mode 100644 index 00000000..5b48df68 --- /dev/null +++ b/tools/decomp-assist/bs2-update-publication-20261002.md @@ -0,0 +1,96 @@ +# BS2 update-thread publication recovery, 2026-10-02 + +Baseline b26e248b. Source-only candidate in src/BS2/BS2Update.c. +The assignment's .cpp spelling was checked; this unit is C. + +## Retained target-proven declarations + +- EntriesCount: original UpdateThread object offsets 0xC2C/0xC30 store the + selected count then immediately reload it, with no intervening call or store. + The old source tests the still-live local count and omits that reload. + Definition-level volatile restores the published global read. +- State: target writes the failure state at 0x4F4 and 0xB4C before joining + selection completion. The zero-selection exit writes State=5 again at 0xC44. + The old source loses the first two store sequences because MWCC sees a later + overwrite without an intervening function call. Definition-level volatile + restores both observable failure-state publications. State is also exposed + through BS2UpdateState for polling by the boot state machine. + +These are real existing state objects. No use-site qualifier casts, added +storage, fabricated barriers, assembly, metadata, or linking changes. + +## Measurements + +| Source form | UpdateThread fuzzy | Instructions | +| --- | ---: | ---: | +| Baseline | 93.59803% | 904/913 | +| EntriesCount publication reread | 93.90471% | 905/913 | +| Also preserve State publications | 94.5575% | 909/913 | + +Unit fuzzy improves 94.23001% -> 95.094765%. Exact code remains 400/4052, +exact functions 9/10, data 10488/10488. This is partial source reconstruction, +not an exact function or linking candidate. + +Rejected independent source-structure experiments, based on the count-reread +candidate: explicit selected-entry byte progression (93.73275%, 905/913), +seatholder byte progression (93.47755%, 905/913), and separate disc-base +expressions in error logging (93.56955%, 905/913). All were restored. The +remaining four missing target instructions are a repeated entry.type read and +three address-materialization differences. Register allocation and scheduling +also differ. The type declaration requires separate shared-header review. + +## Fresh verification + +- Configured only 43U with ../toolchain/wibo-build/wibo +- WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja all_source build/43U/report.json build/43U/ok +- Pool: 55/55 identical +- Exact-name report and fresh ctxdiff preserve all nine exact functions +- Literal audit: 5 arguments across 9 exact functions, no skips/candidates/errors +- Every other unit's complete report unchanged; no per-function regression +- All four data sections still report 100% +- git diff --check passes +- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d + +GATE: source-only nonregression/build/pool/DOL checks pass. Awaiting independent +parent review; no complete decompilation, matching, or linking claim. + +## Separate shared entry-type declaration + +Parent authorized a separate experiment on the actual shared type declaration, +without a translation-unit-specific qualifier. Changed BS2UpdateEntry.type to +vu32 in include/BS2/BS2Update.h for every consumer. + +Original UpdateThread offsets 0xCE8 and 0xD00 read the same entry.type field. +Between them are only the type-zero branch and its skipped increment/continue +path: the nonzero path has no call or write that could require a normal reload. +The shared declaration restores that second observable read. No new guard or +use-site qualifier cast was introduced. + +- UpdateThread: 94.5575% -> 94.66265%, 909 -> 910/913 instructions +- Overall from initial baseline: 93.59803% -> 94.66265%, 904 -> 910/913 +- Unit fuzzy: 94.23001% -> 95.18954% +- Exact functions remain 9/10 and code remains 400/4052 +- Data remains 10488/10488, with every allocated non-text byte unchanged + +All generated source objects were deleted and rebuilt with the configured 43U +all_source/report/ok targets. The prior cache had 1028 objects, including an +obsolete keyboard/tiManager.o absent from build.ninja, objdiff.json, and +configure.py. The current build graph cleanly rebuilt all 1027 configured +objects. Hash comparison of those objects against the source-only checkpoint +found only BS2Update.o changed. All 1026 other unit reports are identical. +This includes every shared-header consumer; none needed source adjustment. + +Fresh final pool: 55/55 identical. Literal audit: 5 arguments across 9 exact +functions, no skips/candidates/errors. Fresh ctxdiff preserves all 9 exact +functions. DOL SHA1 remains 26116613f624061ba99c8d1a299aaa6efa85670d. +git diff --check passes. + +The final three missing target instructions are address materializations: +seatholder table construction uses separate load/add in the target, and both +error-log calls materialize their own disc-table base. These are not omitted +source operations; register and scheduling differences remain as well. No +register sweep or artificial materialization was retained. + +GATE: clean all-source build, cross-unit/object nonregression, complete data, +pool, exact-function preservation, and DOL checks pass. Leaf frozen for +independent parent review. Both commits are partial reconstruction gains. -- 2.49.1 From cc812ad30edcb00d2181a3980be7d6a7b7dba18b Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 2 Oct 2026 18:47:05 -0500 Subject: [PATCH 2/2] ci: live README progress badges from a progress-data branch (#994) The README progress table only changed when a landing commit rewrote it, so merges outside land.sh left it stale, and the decomp.dev badges showed upstream's numbers. The progress workflow now publishes shields.io endpoint JSON to an orphan progress-data branch (one force-pushed commit), so the badges refresh on every push to main without extra commits on main. The build badge now points at the workflow that actually builds (Build is disabled: it needs upstream's private container). --- .github/workflows/readme-progress.yml | 20 +++++++-- README.md | 37 ++++++---------- tools/progress_badges.py | 63 +++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 27 deletions(-) create mode 100644 tools/progress_badges.py diff --git a/.github/workflows/readme-progress.yml b/.github/workflows/readme-progress.yml index 70a1583e..21abb654 100644 --- a/.github/workflows/readme-progress.yml +++ b/.github/workflows/readme-progress.yml @@ -2,8 +2,8 @@ name: README progress # runs on the self-hosted runner on cole's server so it doesn't use hosted minutes. # only push/schedule/manual triggers, never pull_request, so fork PRs can't reach this machine. -# README progress is written inside each landing commit by the orchestrator, so this job never commits; -# it only rebuilds and publishes the current numbers to the job summary. +# it never commits to main: it rebuilds, publishes the numbers to the job summary, and force-pushes +# the README badge JSON as a single commit on the orphan progress-data branch. on: push: branches: [main] @@ -17,7 +17,7 @@ concurrency: cancel-in-progress: true permissions: - contents: read + contents: write jobs: progress: @@ -55,3 +55,17 @@ jobs: python3 tools/update_readme_progress.py build/43U/report.json README.md "$GITHUB_SHA" sed -n '/progress:start/,/progress:end/p' README.md >> "$GITHUB_STEP_SUMMARY" git checkout -- README.md + + - name: Publish badges + if: github.ref == 'refs/heads/main' + run: | + out="$RUNNER_TEMP/progress-data" + rm -rf "$out" + python3 tools/progress_badges.py build/43U/report.json "$out" + cd "$out" + git init -q -b progress-data + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -q -m "progress for $GITHUB_SHA" + git push -q -f "https://x-access-token:${{ github.token }}@github.com/$GITHUB_REPOSITORY.git" HEAD:refs/heads/progress-data diff --git a/README.md b/README.md index 50ad0451..076a5ffe 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,23 @@ -[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml/badge.svg -[actions]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml +[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml/badge.svg?branch=main +[actions]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml [Discord Badge]: https://img.shields.io/discord/727908905392275526?color=%237289DA&logo=discord&logoColor=%23FFFFFF [discord]: https://discord.gg/hKx3FJJgrV - + -[V43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U - - - -[DecompBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=code&label=Decompiled&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic -[LinkBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic -[FuncBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic +[progress]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml +[DecompiledBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdecompiled.json +[MatchedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fmatched.json +[LinkedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Flinked.json +[DataBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdata.json +[FunctionsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Ffunctions.json +[UnitsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Funits.json @@ -43,28 +43,17 @@ Live decomp status [![Build status]][actions] -Open the latest successful [Build workflow run][actions] and check its summary for the current objdiff metrics. It includes perfect-match/decompiled, fuzzy-match, fully linked, data, function, unit, and category breakdowns. The run also publishes the 43U report artifact and generated decomp-status report. +Every push to `main` rebuilds 4.3U, checks the DOL hash, and refreshes the progress badges below. Open the latest [README progress run][actions] for the full objdiff summary. Supported versions: - `43U` - Version **4.3U** (USA) Progress ======== - -| Decompiled | Matched | Linked | Data | -|:---:|:---:|:---:|:---:| -| 99.59% | 91.16% | 74.57% | 99.56% | - -units 964/1027 complete, functions 12378/12563 matched. +[![DecompiledBadge]][progress] [![MatchedBadge]][progress] [![LinkedBadge]][progress] [![DataBadge]][progress] +[![FunctionsBadge]][progress] [![UnitsBadge]][progress] decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data - - -| Version | Progress | -|-----------------------|------------------------------------------------------------------------------| -| [Wii Menu 4.3U][V43U] | [![FuncBadgeV43U]][V43U] [![DecompBadgeV43U]][V43U] [![LinkBadgeV43U]][V43U] | - -> You can see the full progress and its history by clicking on one of the versions in the table. Dependencies ============ diff --git a/tools/progress_badges.py b/tools/progress_badges.py new file mode 100644 index 00000000..9eba9cfe --- /dev/null +++ b/tools/progress_badges.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Write shields.io endpoint JSON files from an objdiff report. + +usage: progress_badges.py + +The README badges read these files from the progress-data branch, so the +numbers update without committing to main. +""" +import json +import os +import sys + +COLOR = "33b8ff" +DONE_COLOR = "brightgreen" + + +def badge(label, message, done): + return { + "schemaVersion": 1, + "label": label, + "message": message, + "color": DONE_COLOR if done else COLOR, + "labelColor": "7c7c7c", + "style": "plastic", + } + + +def percent(measures, key): + value = float(measures.get(key) or 0.0) + return f"{value:.2f}%", value >= 100.0 + + +def count(measures, done_key, total_key): + done = int(measures.get(done_key) or 0) + total = int(measures.get(total_key) or 0) + return f"{done:,} / {total:,}", total > 0 and done == total + + +def main(): + if len(sys.argv) != 3: + raise SystemExit(__doc__) + report_path, out_dir = sys.argv[1], sys.argv[2] + measures = json.load(open(report_path))["measures"] + + badges = { + "decompiled": ("Decompiled", percent(measures, "fuzzy_match_percent")), + "matched": ("Matched", percent(measures, "matched_code_percent")), + "linked": ("Linked", percent(measures, "complete_code_percent")), + "data": ("Data", percent(measures, "matched_data_percent")), + "functions": ("Functions", count(measures, "matched_functions", "total_functions")), + "units": ("Units", count(measures, "complete_units", "total_units")), + } + + os.makedirs(out_dir, exist_ok=True) + for name, (label, (message, done)) in badges.items(): + with open(os.path.join(out_dir, f"{name}.json"), "w", encoding="utf-8") as f: + json.dump(badge(label, message, done), f) + f.write("\n") + print(f"{label}: {message}") + + +if __name__ == "__main__": + main() -- 2.49.1