From b052fdda13eb6cee28daeccd003f32360e891608 Mon Sep 17 00:00:00 2001 From: Supremekirb <99102603+Supremekirb@users.noreply.github.com> Date: Sun, 27 Apr 2025 17:43:07 +0930 Subject: [PATCH] EBP support --- index.html | 9 ++-- index.js | 2 +- rom-patcher-js/RomPatcher.js | 4 +- rom-patcher-js/RomPatcher.webapp.js | 2 +- .../modules/RomPatcher.format.ips.js | 41 +++++++++++++++---- test.js | 11 +++++ 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index b615605..3338326 100644 --- a/index.html +++ b/index.html @@ -3,8 +3,8 @@ Rom Patcher JS - - + + @@ -27,7 +27,7 @@ - + @@ -83,7 +83,7 @@
- +
@@ -126,6 +126,7 @@ +
diff --git a/index.js b/index.js index c5a7535..69eace4 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ program .description('creates a patch based on two ROMs') .argument('', 'the original ROM') .argument('','the modified ROM') - .option('-f, --format ','patch format (allowed values: ips [default], bps, ppf, ups, aps, rup)') + .option('-f, --format ','patch format (allowed values: ips [default], bps, ppf, ups, aps, rup, ebp)') .action(function(originalRomPath, modifiedRomPath, options) { console.log(options); try{ diff --git a/rom-patcher-js/RomPatcher.js b/rom-patcher-js/RomPatcher.js index 3e312f1..f70ec66 100644 --- a/rom-patcher-js/RomPatcher.js +++ b/rom-patcher-js/RomPatcher.js @@ -242,8 +242,8 @@ const RomPatcher = (function () { format = 'ips'; var patch; - if (format === 'ips') { - patch = IPS.buildFromRoms(originalFile, modifiedFile); + if (format === 'ips' || format === 'ebp') { + patch = IPS.buildFromRoms(originalFile, modifiedFile, format === 'ebp'); } else if (format === 'bps') { patch = BPS.buildFromRoms(originalFile, modifiedFile, (originalFile.fileSize <= 4194304)); } else if (format === 'ppf') { diff --git a/rom-patcher-js/RomPatcher.webapp.js b/rom-patcher-js/RomPatcher.webapp.js index ae05dde..26b5c40 100644 --- a/rom-patcher-js/RomPatcher.webapp.js +++ b/rom-patcher-js/RomPatcher.webapp.js @@ -1175,7 +1175,7 @@ const ZIPManager = (function (romPatcherWeb) { const ZIP_MAGIC = '\x50\x4b\x03\x04'; - const FILTER_PATCHES = /\.(ips|ups|bps|aps|rup|ppf|mod|xdelta|vcdiff)$/i; + const FILTER_PATCHES = /\.(ips|ebp|ups|bps|aps|rup|ppf|mod|xdelta|vcdiff)$/i; //const FILTER_ROMS=/(?romFile.fileSize){ //expand (discussed here: https://github.com/marcrobledo/RomPatcher.js/pull/46) tempFile=new BinFile(this.truncate); romFile.copyTo(tempFile, 0, romFile.fileSize, 0); @@ -136,6 +157,8 @@ IPS.fromFile=function(file){ }else if((file.offset+3)===file.fileSize){ patchFile.truncate=file.readU24(); break; + }else if (file.readU8()===EBP_MAGIC_META_OPENER) { + break; } } @@ -151,10 +174,12 @@ IPS.fromFile=function(file){ } -IPS.buildFromRoms=function(original, modified){ +IPS.buildFromRoms=function(original, modified, asEBP=false){ var patch=new IPS(); - if(modified.fileSize=IPS_MAX_ROM_SIZE){ - throw new Error('Files are too big for IPS format'); + throw new Error(`Files are too big for ${'EBP' ? patch.isEBP : 'IPS'} format`); return null; } diff --git a/test.js b/test.js index 2250c71..e002b4c 100644 --- a/test.js +++ b/test.js @@ -14,6 +14,9 @@ - IPS test - Patch: https://www.romhacking.net/hacks/3784/ - ROM: Super Mario Land 2 - 6 Golden Coins (USA, Europe).gb [CRC32=d5ec24e4] + - EBP test + - Patch: https://forum.starmen.net/forum/Community/PKHack/NickBound/page/1#post2333521 + - ROM: EarthBound (USA).sfc [CRC32=dc9bb451] - BPS test - Patch: https://www.romhacking.net/translations/6297/ - ROM: Samurai Kid (Japan).gbc [CRC32=44a9ddfb] @@ -50,6 +53,14 @@ const TEST_PATCHES = [ patchCrc32: 0x0b742316, patchDownload: 'https://www.romhacking.net/hacks/3784/', outputCrc32: 0xf0799017 + }, { + title: 'EBP - Mother Rebound', + romFile: 'EarthBound (USA).sfc', + romCrc32: 0xdc9bb451, + patchFile: 'Mother_Rebound.ebp', + patchCrc32: 0x271719e1, + patchDownload: 'https://forum.starmen.net/forum/Community/PKHack/NickBound/page/1#post2333521', + outputCrc32: 0x5065b02f }, { title: 'BPS - Samurai Kid translation', romFile: 'Samurai Kid (Japan).gbc',