Skip to content

Add multi-ROM base detection and EU1.1 bring-up infrastructure - #1

Merged
Zection6V merged 97 commits into
developfrom
agent/eu11-multirom-bringup
Aug 17, 2026
Merged

Add multi-ROM base detection and EU1.1 bring-up infrastructure#1
Zection6V merged 97 commits into
developfrom
agent/eu11-multirom-bringup

Conversation

@Zection6V

@Zection6V Zection6V commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds multi-ROM base detection and the first non-USA exact-content bring-up path for Europe revision 1 (AMHP, revision 1), while separating runtime compatibility from exact ROM content identity.

Also integrates the current upstream mstan/MetroidPrimeHuntersRecomp codex/mph-online-first-run branch through 5abcfee6187d572e752985ede2364f165d62dd6a (4 commits beyond this PR's original upstream base), including:

  • HD Rendering launcher support and its launcher tests
  • v0.4.0-alpha project/release metadata
  • persistent MPH Wi-Fi / firmware profiles across launches
  • updated WFC probes and first-run persistence QA
  • required ndsrecomp pin 6c6a03bdcf99093f64555c4d05d16e522dc58634

The upstream code is integrated without restoring its old US1.0 whole-ROM-SHA runtime assumptions.

Identity architecture

The architecture separates three identities:

  1. Runtime Base Profile — one of the seven retail RAM/code layouts
  2. Executable Compatibility Identity — melonPrimeDS-compatible header+ARM9+ARM7 CRC32
  3. Actual Content Identity — exact whole-ROM SHA-1 used by build/capture/generated artifacts

Whole-ROM SHA-1 is not the runtime address selector.

Runtime detector

Runtime source of truth is melonPrimeDS develop_hud:

  • src/frontend/qt_sdl/MelonPrimeGameRomDetect.cpp
  • src/frontend/qt_sdl/MelonPrimeGameRomAddrTable.h
  • src/NDSCart/CartCommon.cpp::Checksum()

Detection is:

  1. authoritative executable checksum: CRC32 over header 0x00..0x3F, then ARM9, then ARM7
  2. exact gameCode @0x0C + revision @0x1E fallback

Recomp tightens the fallback to the seven explicitly supported tuples. A header-only match identifies a candidate base profile but does not authorize host RAM/code writes.

The registry is live-cross-checked against the current melonPrimeDS detector and carries its current 17 executable checksums, including clean/encrypted variants plus EU1.1 Balanced, Balanced v1.2.11 and Russian variants.

Seven runtime layouts

Runtime base Game code Rev Morph / Alt Form Direct Aim X Direct Aim Y
US1_0 AMHE 0 0x020DA818 0x020DE526 0x020DE52E
US1_1 AMHE 1 0x020DB098 0x020DEDA6 0x020DEDAE
EU1_0 AMHP 0 0x020DB0B8 0x020DEDC6 0x020DEDCE
EU1_1 AMHP 1 0x020DB138 0x020DEE46 0x020DEE4E
JP1_0 AMHJ 0 0x020DC6D8 0x020E03E6 0x020E03EE
JP1_1 AMHJ 1 0x020DC698 0x020E03A6 0x020E03AE
KR1_0 AMHK 0 0x020D3EE4 0x020D7C0E 0x020D7C16

Adaptive Widescreen: all seven runtime profiles

Adaptive Widescreen is no longer hidden for EU1.1. The implementation uses melonPrimeDS MelonPrimePatchAspectRatio.cpp / MelonPrimeGameRomAddrTable.h, cross-checked against mphCodex/_Commons/Widescreen.md.

Runtime base Projection patch 1 Projection patch 2 Q12 culling aspect
US1_0 0x02110FFC 0x0211C638 0x02110820
US1_1 0x02111ABC 0x0211D168 0x021112E0
EU1_0 0x02111ADC 0x0211D114 0x02111300
EU1_1 0x02111B5C 0x0211D208 0x02111380
JP1_0 0x0211313C 0x0211E7E8 0x02112960
JP1_1 0x021130FC 0x0211E7A8 0x02112920
KR1_0 0x02109B64 0x02114838 0x021091A4

The 21:9 patch verifies all three stock preimages before doing any write:

  • projection 1: 0xE5991664
  • projection 2: 0xE59A1664
  • Q12 aspect: 0x1555

Then applies melonPrimeDS's 21:9 values:

  • projection instruction: 0xE3A0106D
  • Q12 aspect: 0x2555

A known executable checksum may authorize these writes. A header-only fallback keeps the candidate base identity but forces the actual Adaptive Widescreen host patch off. Guest reset is handled by re-checking the guarded stock words so the patch can be reapplied when appropriate.

Whole-ROM SHA-1 and mod safety

Whole-ROM SHA-1 remains authoritative for exact build input identity, coverage, generated banks, checkpoints and FMV/runtime captures. Generated title banks remain keyed to the actual ROM SHA-1, so clean/MOD-A content cannot silently be reused for MOD-B.

Startup remains conservative:

  • exact expected whole-ROM SHA → normal exact-content build
  • different whole-ROM SHA + same canonical clean executable checksum → data-only variant may reuse the clean build
  • known code-modified executable checksum → runtime layout may be trusted, but clean generated content is not automatically reused
  • unknown executable checksum + supported header → candidate base only; Aim/Morph/Widescreen host access and clean-SHA bypass remain disabled
  • malformed/unknown/contradictory identities → fail closed

Last Raven is not currently in the audited melonPrimeDS checksum table and therefore remains fail-closed for host writes until explicitly validated.

Content profiles

Registry schema 5 separates content profiles from runtime bases through base_profile and known_clean.

A future exact mod profile can use a distinct key such as US1_0_LAST_RAVEN, point to base_profile: US1_0, and keep its own SHA-1, coverage, banks, checkpoints and FMV captures.

Current exact build/capture profiles are:

  • US1_0 clean retail
  • EU1_1 clean retail

The other five retail revisions still need exact ROM extraction/coverage/generated artifacts before being considered fully player-facing supported.

Upstream launcher / Wi-Fi / HD integration

launcher/recomp-ui/launcher_main.cpp and launcher/recomp-ui/tests/launcher_mod_provider_test.cpp are kept byte-identical to upstream 5abcfee and CI verifies that property. The launcher therefore retains all three upstream gameplay features:

  • Adaptive Widescreen
  • Prime Controls
  • HD Rendering

The profile-generation CMake layer performs only the multi-ROM-specific transformations:

  • clean SHA metadata substitution for the selected content profile
  • region label substitution
  • default ROM filename substitution
  • launcher ROM SHA acceptance gate disabled (known_sha1_hex = nullptr, num_known_sha1 = 0)

This lets modified ROMs reach the runner's stronger CRC/header/content detector instead of being rejected by recomp-ui first.

Upstream Wi-Fi persistence is also retained:

  • mutable firmware/WFC state under %APPDATA%\\MetroidPrimeHuntersRecomp
  • separate firmware-generated.bin / firmware-retail.bin
  • --firmware-state-path passed to the runner
  • persisted firmware-profile MAC shown by the dashboard when available
  • probe_mph_online_first_run.py plus updated WFC/screen QA tools

The pinned ndsrecomp revision is 6c6a03bdcf99093f64555c4d05d16e522dc58634. Its baseline still contains US1.0 exact-SHA/address assumptions; the local multi-ROM patch stack replaces those at build time.

Validation

Current HEAD: e3f0f9959f5d22b2547740689ed3a3c69c6cf1c8.

MPH Multi-ROM Static Checks run #78: PASS.

Validated on the final HEAD:

  • Python / shell / PowerShell syntax
  • upstream 5abcfee launcher, launcher-test and QA-tool byte sync
  • live melonPrimeDS develop_hud detector/address-table cross-check
  • all seven Aim/Morph runtime profiles
  • all seven Adaptive Widescreen address triples
  • all 17 current executable checksum entries
  • profile-aware coverage routing
  • exact pinned ndsrecomp fetch at 6c6a03b...
  • US1.0 and EU1.1 launcher generation with SHA acceptance disabled
  • upstream 3-mod launcher state on both generated profiles
  • Wi-Fi firmware-state argument on both generated profiles
  • runtime patch idempotency
  • compile of patched title_patches.cpp, frontend.cpp and main.cpp
  • synthetic seven-version executable-CRC dispatch
  • header-only fail-closed behavior
  • US1.0 and EU1.1 exact-content ROM checker builds
  • diff sanity

Remaining real-ROM work

Static architecture is prepared, but full player-facing support still requires per-content validation:

  • add verified clean content profiles for US1.1, EU1.0, JP1.0, JP1.1 and KR1.0
  • real ROM extraction and generated-bank execution
  • deterministic coverage capture/promotion
  • firmware-to-cartridge boot/title checkpoints
  • Adventure, pause, save/load and multiplayer validation
  • Prime Controls / Direct Mouse Aim / Adaptive Widescreen semantic validation on real execution
  • native/reference checkpoint comparison
  • revision/mod-specific FMV capture where needed
  • final US1.0 regression validation
  • explicit executable-layout validation for additional code-modified variants such as Last Raven

Detailed procedures are in docs/EU1_1_BRINGUP.md.

@Zection6V
Zection6V changed the base branch from main to develop August 17, 2026 01:33
@Zection6V Zection6V changed the title Bring up EU1.1 multi-ROM profile infrastructure Add multi-ROM base detection and EU1.1 bring-up infrastructure Aug 17, 2026
@Zection6V
Zection6V marked this pull request as ready for review August 17, 2026 06:00
@Zection6V
Zection6V merged commit e50d2dc into develop Aug 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant