diff --git a/_cache_service_worker.js b/_cache_service_worker.js
index 1cf24ec..b16a7a4 100644
--- a/_cache_service_worker.js
+++ b/_cache_service_worker.js
@@ -6,7 +6,7 @@
*/
var PRECACHE_ID = 'rom-patcher-js';
-var PRECACHE_VERSION = 'v30finalfix2';
+var PRECACHE_VERSION = 'v31';
var PRECACHE_URLS = [
'/RomPatcher.js/', '/RomPatcher.js/index.html',
'/RomPatcher.js/manifest.json',
diff --git a/index.html b/index.html
index 1715c9c..b615605 100644
--- a/index.html
+++ b/index.html
@@ -151,7 +151,7 @@
- Rom Patcher JS v3.0 by Marc Robledo
+ Rom Patcher JS v3.1 by Marc Robledo
See on GitHub
Donate
diff --git a/rom-patcher-js/RomPatcher.js b/rom-patcher-js/RomPatcher.js
index f28f95a..3e312f1 100644
--- a/rom-patcher-js/RomPatcher.js
+++ b/rom-patcher-js/RomPatcher.js
@@ -219,6 +219,8 @@ const RomPatcher = (function () {
if (options.outputSuffix) {
patchedRom.fileName = romFile.fileName.replace(/\.([^\.]*?)$/, ' (patched).$1');
+ if(patchedRom.unpatched)
+ patchedRom.fileName = patchedRom.fileName.replace(' (patched)', ' (unpatched)');
} else if (patch._originalPatchFile) {
patchedRom.fileName = patch._originalPatchFile.fileName.replace(/\.\w+$/i, (/\.\w+$/i.test(romFile.fileName) ? romFile.fileName.match(/\.\w+$/i)[0] : ''));
} else {
diff --git a/rom-patcher-js/modules/RomPatcher.format.rup.js b/rom-patcher-js/modules/RomPatcher.format.rup.js
index 5b0ed2b..322c841 100644
--- a/rom-patcher-js/modules/RomPatcher.format.rup.js
+++ b/rom-patcher-js/modules/RomPatcher.format.rup.js
@@ -1,4 +1,4 @@
-/* RUP module for Rom Patcher JS v20240721 - Marc Robledo 2018-2024 - http://www.marcrobledo.com/license */
+/* RUP module for Rom Patcher JS v20241102 - Marc Robledo 2018-2024 - http://www.marcrobledo.com/license */
/* File format specification: http://www.romhacking.net/documents/288/ */
const RUP_MAGIC='NINJA2';
@@ -40,7 +40,11 @@ RUP.prototype.toString=function(){
s+='\nTarget file size: '+file.targetFileSize;
s+='\nSource MD5: '+file.sourceMD5;
s+='\nTarget MD5: '+file.targetMD5;
- s+='\nOverflow text: '+file.overflowText;
+ if(file.overflowMode==='A'){
+ s+='\nOverflow mode: Append ' + file.overflowData.length + ' bytes';
+ }else if(file.overflowMode==='M'){
+ s+='\nOverflow mode: Minify ' + file.overflowData.length + ' bytes';
+ }
s+='\n#records: '+file.records.length;
}
return s
@@ -50,8 +54,11 @@ RUP.prototype.toString=function(){
RUP.prototype.validateSource=function(romFile,headerSize){
var md5string=romFile.hashMD5(headerSize);
for(var i=0; i byte ^ 0xff));
+ }else if(patch.overflowMode==='M' && undo){ /* minify */
+ tempFile.seek(patch.targetFileSize);
+ tempFile.writeBytes(patch.overflowData.map((byte) => byte ^ 0xff));
+ }
- if(validate && tempFile.hashMD5()!==validFile.targetMD5){
+
+ if(
+ validate &&
+ (
+ (!undo && tempFile.hashMD5()!==patch.targetMD5) ||
+ (undo && tempFile.hashMD5()!==patch.sourceMD5)
+ )
+ ){
throw new Error('Target ROM checksum mismatch');
}
+ if(undo)
+ tempFile.unpatched=true;
+
return tempFile
}
@@ -161,8 +190,10 @@ RUP.fromFile=function(file){
if(nextFile.sourceFileSize!==nextFile.targetFileSize){
- file.skip(1); //skip 'M' (source>target) or 'A' (sourcetarget) or 'A' (sourcefile.targetFileSize?'M':'A');
- patchFile.writeVLV(file.overflowText.length);
- patchFile.writeString(file.overflowText);
+ patchFile.writeVLV(file.overflowData.length);
+ patchFile.writeBytes(file.overflowData);
}
for(var j=0; j byte ^ 0xff);
+ modified=modified.slice(0, file.sourceFileSize);
+ }else if(file.sourceFileSize>file.targetFileSize){
+ original.seek(file.targetFileSize);
+ file.overflowMode='M';
+ file.overflowData=original.readBytes(file.sourceFileSize-file.targetFileSize).map((byte) => byte ^ 0xff);
+ original=original.slice(0, file.targetFileSize);
+ }
+
original.seek(0);
modified.seek(0);