Skip to content

feat: port over the dolphin junk seed recovery code - #25

Merged
encounter merged 3 commits into
encounter:mainfrom
rom-weaver:upstream-junk-seed-recovery
Jul 17, 2026
Merged

encounter merged 3 commits into
encounter:mainfrom
rom-weaver:upstream-junk-seed-recovery

Conversation

@brandonocasey

Copy link
Copy Markdown
Contributor

👋🏻 Hi again, most of this code is based on what dolphin does. I ran into an issue using nod where I was getting some strand compression results on a rom hack (Kururin Squash Translation). Basically after the rom hack was applied the rom would not compress at all. narrowed it down to the junk data detection recovery.

For reference:
The LFG seed-recovery implementation is substantially ported to Rust from Dolphin’s LaggedFibonacciGenerator::GetSeed
(https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/DiscIO/LaggedFibonacciGenerator.cpp), originally introduced by JosJuice in
dolphin-emu/dolphin@4b74993 (dolphin-emu/dolphin@4b74993). That source is licensed under
CC0-1.0

RVZ junk detection seeded the LFG solely from the disc header's game ID.
When a patch changes the game ID (e.g. region retagging in translation
patches), no junk matches and ~1.2 GB of pseudo-random junk gets stored
raw, ballooning output (observed 110 MB -> 1.32 GB).

Port Dolphin's LaggedFibonacciGenerator::GetSeed (CC0-1.0): when the
disc-ID-derived seed doesn't match, reconstruct the seed by running the
generator backward over the junk bytes themselves, verify it through the
reader code path, and store the recovered seed in the RVZ packed data.
check_block seeded junk detection with the outer disc header's game ID
for all sectors, but read-time junk regeneration uses the partition's
own disc header for sectors inside a partition. If the two ever differ
(e.g. a modified disc), a block detected as junk at write time would be
regenerated with different bytes at read time, silently corrupting
CISO/WBFS round-trips. Use the partition header for partition data,
matching read-side behavior and WIA/RVZ's per-partition JunkInfo.
@encounter

Copy link
Copy Markdown
Owner

Would you mind merging main? CI should pass then

@brandonocasey

Copy link
Copy Markdown
Contributor Author

Done @encounter

@encounter

Copy link
Copy Markdown
Owner

Looks great, thanks!

@encounter
encounter merged commit ac12dba into encounter:main Jul 17, 2026
44 checks 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.

2 participants