Tsukihimates / Tsukihime-Translation

Open source translation of Tsukihime -A Piece of Blue Glass Moon- prepared by Tsukihimates
https://tsukihimates.com/
The Unlicense
149 stars 25 forks source link

[Question] NSP patch build/packing process. #602

Closed cajheto closed 1 year ago

cajheto commented 2 years ago

Hello, I noticed that on the website, the patch is available as an NSP update. I have been able to find building NSPs for homebrew, but seeing an unofficial NSP built as an update for an official game is extremely rare, I haven't seen that done elsewhere yet (although I've been away from the Switch Homebrew scene for a while now).

Do you mind if I ask how the NSP is built?

Thanks.

rschlaikjer commented 1 year ago

Now that our project is effectively complete, we are releasing mkbktr, the tool we built to handle creating BKTR update NCAs for switch titles. As far as we could tell, no tools already existed for creating these archives, only reading them. Since they provide a compact and inherently supported mechanism for distributing binary patches, we elected to use them as our patch distribution mechanism.

The tool uses an Adler rolling checksum + strong MD5 checksum to detect reusable sections across the base NCA and patch NCA, generating relocation/patch entries as needed. The implementation is based entirely off of information gleaned from the SwitchBrew Wiki and the implementations for reading BKTR files found in hactool and Yuzu.

The program certainly has room for improvement - I didn't bother to handle patches large enough to require more than a single relocation bucket, there is no backtracking on md5 match to minimize copying within chunks - but it seems to work correctly, at least for this title. We hope that it proves useful for others in the community.