mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2026-05-15 07:29:46 -05:00
Path 2 of the pattern-fragment dispatch architecture: each variant of a [[input.decompressed_section_pattern]] now gets a unique link-time ram_addr from a synthetic vram pool (0xC0000000+, KSEG2/KSEG3 — unused by N64 software so it can't collide with engine-resident sections like RSP at 0xA4000000+). Why: when multiple variants share a single canonical link bucket (e.g. all stadium_models pattern variants at 0x8FF00000), runtime fragment-vaddr resolution via gFragments[id] is single-pointer and ambiguous when more than one variant is host-resident at the same time. Per-variant synthetic ram_addrs make each variant's RELOC_HI16 / RELOC_LO16 emit produce a unique 0xCXXXXXXX literal at runtime, giving variant-internal references unambiguous identity without depending on caller PC, host stack walks, or data-context tracking. Implementation: - add_decompressed_section accepts an override_link_ram_addr param. The bytes-encoded `vram` (= canonical link bucket) is passed to parse_fragment_relocs and discover_function_bounds (so jump tables resolve correctly against the body's encoded references), while section.ram_addr is set to the override. The two roles of vram are cleanly separated. - New original_pattern_id field on Section. Populated for synthetic- link variants with the original game-side fragment id derived from the pattern's canonical bucket (e.g. 0xEF for stadium_models). Lets the runtime candidate filter know which game id should include this synthetic section as a candidate, eliminating cross- pattern hash-collision misregistration. - main.cpp emit: section_load_table now writes original_pattern_id into the SectionTableEntry initializer. - decompressed.cpp pattern loop: every unique variant now gets synthetic ram_addr = 0xC0000000 + variant_idx * 0x100000 (1 MB stride, ~286 KB largest observed variant). For Stadium's 279 unique variants the pool occupies 0xC0000000..0xCDB00000, well within the runtime-side 512-bucket capacity. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| recompiler | ||
| recomp.h | ||