marcrobledo / RomPatcher.js

An IPS/UPS/APS/BPS/RUP/PPF/xdelta ROM patcher made in HTML5.
https://www.marcrobledo.com/RomPatcher.js/
Other
656 stars 133 forks source link

[New format request] xdelta3 support #5

Open marcrobledo opened 5 years ago

marcrobledo commented 5 years ago

I added .xdelta support, borrowed from https://github.com/google/xdelta3-decoder-js.

It works with http://www.romhacking.net/hacks/3810/, but seems to fail with https://www.romhacking.net/hacks/2871/. It creates a 8mb file full of garbage, when it should be 32mb (like the source ROM).

I commented all xdelta code for now, but I commited the needed files for anyone who wants to take a look.

NintendoManiac64 commented 5 years ago

I myself cannot help, but for a second reference I noticed that the following web patcher supports xdelta (among a bunch of other formats as well):

https://hack64.net/Thread-Web-based-ROM-patcher-APS-BPS-IPS-MOD-Star-Rod-PPF-UPS-VCDiff-xdelta

marcrobledo commented 5 years ago

Oh, I found that patcher some time ago. Works great, but cannot create patches and the web workers are coded in a way that makes the patcher slower than it should be.

Anyway, xdelta support is coming ;-) I've been working on it for some time, but cannot promise when it will be ready.

marcrobledo commented 5 years ago

xdelta (patching only) support has been added in e7d2bcc

However, I'm having problems with Firefox and cache service worker and the site is not showing the latest version, despite files have been comitted correctly. I'll look into it asap since this is giving me headaches in all my projects here in GitHub Pages+Firefox.

mariomadproductions commented 2 years ago

it seems like only xdelta2 is supported, not xdelta3. with an xdelta3 patch, i get the error "not implemented: secondary decompressor"

marcrobledo commented 2 years ago

From @DeadSkullzJr #45

I have no idea why you used nine year old code, incomplete based on some short glances, from a school related project as a base for Xdelta3 format support, but I recommend you use official source material instead. v3.1.0 is an appropriate version to use, majority of offline Xdelta patching solutions use this version already. The secondary compression formats are important here given some patches out in the wild actually use them, not to mention are backwards compatible with older versions of Xdelta3 when using front end solutions like Xdelta UI (uses v3.0u). Patches made with newer versions of Xdelta3 do not work with the online patcher since the code used doesn't understand the newer algorithm format that these newer patches are in. Due to this issue, it actually makes it difficult for some users out there who do not have access to a computer or uses an operating system that doesn't have a compiled patcher solution of sorts to work with.

Side note, v3.1.1 exists under the current source page, but it's kind of buggy, hence why v3.1.0 is a more appropriate version to use, so chances are you'll want to examine the GPL based source.

Sources: https://github.com/jmacd/xdelta (Current) https://github.com/jmacd/xdelta-gpl (Original)

I am aware :-( Due to lack of time, I borrowed the only xdelta port I found for Javascript. Javascript is not exactly the best language for binary data processing and porting xdelta3 would take some time. It is not impossible, but I'm currently focused on other projects. Wish I really had time for this!

kotcrab commented 2 years ago

For what it's worth it's not necessary to port the Xdelta to Javascript. It's possible to compile the library directly into web assembly with Emscripten and it works pretty nicely, see https://github.com/kotcrab/xdelta-wasm

marcrobledo commented 2 years ago

Sounds good! Unfortunately, I'm not used to Emscripten and Web Assembly (and got little time to get into it right now :-( ). Do you think you could do a PR with the implementation?

kotcrab commented 2 years ago

Sorry, I won't be making a PR. Adding this is somewhat tricky since you need to figure how to include compiling native code into your build process. Also my approach isn't directly compatible with this project because I'm using StreamSaver library to process the file in chunks and this seems to be processing files in memory.