From b0642131339633c731b73b6b271bf7912b7d4e32 Mon Sep 17 00:00:00 2001 From: vagnercruz Date: Thu, 13 Jun 2024 13:57:37 -0300 Subject: [PATCH 1/8] docs: Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 31deb5d..f1e6b7e 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,4 @@ A ROM patcher made in HTML5. * [Radical Red](https://patch.radicalred.net/) * [Rocket Edition](https://rocket-edition.com/download/) * [SnapCameraPreservation](https://snapchatreverse.jaku.tv/snap/) +* [Pokemon Clover](https://poclo.net/download) From cc3c5b971c5c266b5104b37183ec91da2de478ab Mon Sep 17 00:00:00 2001 From: vagnercruz Date: Tue, 18 Jun 2024 18:32:56 -0300 Subject: [PATCH 2/8] BSP Support --- js/RomPatcher.js | 5 ++- js/formats/BSP.js | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 js/formats/BSP.js diff --git a/js/RomPatcher.js b/js/RomPatcher.js index f174c74..76c0558 100644 --- a/js/RomPatcher.js +++ b/js/RomPatcher.js @@ -648,6 +648,8 @@ function _getHeaderChecksumInfo(file){ } +const BPS_MAGIC = "BPS1"; // Verifique o valor correto para a mágica do BPS + function _readPatchFile(){ setTabApplyEnabled(false); patchFile.littleEndian=false; @@ -679,9 +681,8 @@ function _readPatchFile(){ patch=parseVCDIFF(patchFile); }else{ patch=null; - setMessage('apply', 'error_invalid_patch', 'error'); + setMessage('apply', 'Unsupported patch format', 'error'); } - validateSource(); setTabApplyEnabled(true); } diff --git a/js/formats/BSP.js b/js/formats/BSP.js new file mode 100644 index 0000000..171a07c --- /dev/null +++ b/js/formats/BSP.js @@ -0,0 +1,101 @@ +/* BSP module for Rom Patcher JS v20220417 - Vagner Matheus 2016-2024 */ +const BSP_MAGIC = 'BSP'; +const BSP_VERSION = 1; +const BSP_MAX_SIZE = 0x1000000; // 16 megabytes + +function BSP() { + this.records = []; +} + +BSP.prototype.addRecord = function(o, d) { + this.records.push({offset: o, data: d}); +}; + +BSP.prototype.toString = function() { + let s = 'Records: ' + this.records.length; + return s; +}; + +BSP.prototype.export = function(fileName) { + let patchFileSize = 8; // BSP magic + version + for (let i = 0; i < this.records.length; i++) { + patchFileSize += 4 + this.records[i].data.length; // offset + data length + } + + let tempFile = new MarcFile(patchFileSize); + tempFile.fileName = fileName + '.bsp'; + tempFile.writeString(BSP_MAGIC); + tempFile.writeU32(BSP_VERSION); + + for (let i = 0; i < this.records.length; i++) { + let rec = this.records[i]; + tempFile.writeU32(rec.offset); + tempFile.writeBytes(rec.data); + } + + return tempFile; +}; + +BSP.prototype.apply = function(romFile) { + let tempFile = new MarcFile(romFile.fileSize); + romFile.copyToFile(tempFile, 0); + + for (let i = 0; i < this.records.length; i++) { + tempFile.seek(this.records[i].offset); + tempFile.writeBytes(this.records[i].data); + } + + return tempFile; +}; + +function parseBSPFile(file) { + let patchFile = new BSP(); + file.seek(4); // Skip magic + let version = file.readU32(); + + if (version !== BSP_VERSION) { + throw new Error('Unsupported BSP version'); + } + + while (!file.isEOF()) { + let offset = file.readU32(); + let length = file.fileSize - file.offset; // remaining bytes + let data = file.readBytes(length); + patchFile.addRecord(offset, data); + } + + return patchFile; +} + +function createBSPFromFiles(original, modified) { + let patch = new BSP(); + + while (!modified.isEOF()) { + let b1 = original.isEOF() ? 0x00 : original.readU8(); + let b2 = modified.readU8(); + + if (b1 !== b2) { + let differentData = []; + let startOffset = modified.offset - 1; + + while (b1 !== b2 && differentData.length < 0xffff) { + differentData.push(b2); + if (modified.isEOF() || differentData.length === 0xffff) { + break; + } + + b1 = original.isEOF() ? 0x00 : original.readU8(); + b2 = modified.readU8(); + } + + if (startOffset >= BSP_MAX_SIZE) { + throw new Error('Files are too big for BSP format'); + return null; + } + + patch.addRecord(startOffset, differentData); + } + } + + return patch; +} From 3863c9a877d62c3adc7cc62af8016fce0b0c99f0 Mon Sep 17 00:00:00 2001 From: Marc Robledo Date: Sat, 20 Jul 2024 16:19:45 +0200 Subject: [PATCH 3/8] reverted regressions --- js/RomPatcher.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/RomPatcher.js b/js/RomPatcher.js index 76c0558..fe8551c 100644 --- a/js/RomPatcher.js +++ b/js/RomPatcher.js @@ -648,8 +648,6 @@ function _getHeaderChecksumInfo(file){ } -const BPS_MAGIC = "BPS1"; // Verifique o valor correto para a mágica do BPS - function _readPatchFile(){ setTabApplyEnabled(false); patchFile.littleEndian=false; @@ -681,7 +679,7 @@ function _readPatchFile(){ patch=parseVCDIFF(patchFile); }else{ patch=null; - setMessage('apply', 'Unsupported patch format', 'error'); + setMessage('apply', 'error_invalid_patch', 'error'); } validateSource(); setTabApplyEnabled(true); From 725601d43fce532f1534cca1a4f9881d53157cfb Mon Sep 17 00:00:00 2001 From: Marc Robledo Date: Sat, 20 Jul 2024 16:25:33 +0200 Subject: [PATCH 4/8] fixed bsp date --- js/formats/BSP.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/formats/BSP.js b/js/formats/BSP.js index 171a07c..d5ffe92 100644 --- a/js/formats/BSP.js +++ b/js/formats/BSP.js @@ -1,4 +1,4 @@ -/* BSP module for Rom Patcher JS v20220417 - Vagner Matheus 2016-2024 */ +/* BSP module for Rom Patcher JS v20240613 - Vagner Matheus 2016-2024 */ const BSP_MAGIC = 'BSP'; const BSP_VERSION = 1; const BSP_MAX_SIZE = 0x1000000; // 16 megabytes From 0992132c5739d625f82c9ce66bed80cb1e5aa5c2 Mon Sep 17 00:00:00 2001 From: Marc Robledo Date: Sat, 20 Jul 2024 16:31:28 +0200 Subject: [PATCH 5/8] removed bsp.js file since it has nothing to do with Pokemon Prism --- js/formats/BSP.js | 101 ---------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 js/formats/BSP.js diff --git a/js/formats/BSP.js b/js/formats/BSP.js deleted file mode 100644 index d5ffe92..0000000 --- a/js/formats/BSP.js +++ /dev/null @@ -1,101 +0,0 @@ -/* BSP module for Rom Patcher JS v20240613 - Vagner Matheus 2016-2024 */ -const BSP_MAGIC = 'BSP'; -const BSP_VERSION = 1; -const BSP_MAX_SIZE = 0x1000000; // 16 megabytes - -function BSP() { - this.records = []; -} - -BSP.prototype.addRecord = function(o, d) { - this.records.push({offset: o, data: d}); -}; - -BSP.prototype.toString = function() { - let s = 'Records: ' + this.records.length; - return s; -}; - -BSP.prototype.export = function(fileName) { - let patchFileSize = 8; // BSP magic + version - for (let i = 0; i < this.records.length; i++) { - patchFileSize += 4 + this.records[i].data.length; // offset + data length - } - - let tempFile = new MarcFile(patchFileSize); - tempFile.fileName = fileName + '.bsp'; - tempFile.writeString(BSP_MAGIC); - tempFile.writeU32(BSP_VERSION); - - for (let i = 0; i < this.records.length; i++) { - let rec = this.records[i]; - tempFile.writeU32(rec.offset); - tempFile.writeBytes(rec.data); - } - - return tempFile; -}; - -BSP.prototype.apply = function(romFile) { - let tempFile = new MarcFile(romFile.fileSize); - romFile.copyToFile(tempFile, 0); - - for (let i = 0; i < this.records.length; i++) { - tempFile.seek(this.records[i].offset); - tempFile.writeBytes(this.records[i].data); - } - - return tempFile; -}; - -function parseBSPFile(file) { - let patchFile = new BSP(); - file.seek(4); // Skip magic - let version = file.readU32(); - - if (version !== BSP_VERSION) { - throw new Error('Unsupported BSP version'); - } - - while (!file.isEOF()) { - let offset = file.readU32(); - let length = file.fileSize - file.offset; // remaining bytes - let data = file.readBytes(length); - patchFile.addRecord(offset, data); - } - - return patchFile; -} - -function createBSPFromFiles(original, modified) { - let patch = new BSP(); - - while (!modified.isEOF()) { - let b1 = original.isEOF() ? 0x00 : original.readU8(); - let b2 = modified.readU8(); - - if (b1 !== b2) { - let differentData = []; - let startOffset = modified.offset - 1; - - while (b1 !== b2 && differentData.length < 0xffff) { - differentData.push(b2); - if (modified.isEOF() || differentData.length === 0xffff) { - break; - } - - b1 = original.isEOF() ? 0x00 : original.readU8(); - b2 = modified.readU8(); - } - - if (startOffset >= BSP_MAX_SIZE) { - throw new Error('Files are too big for BSP format'); - return null; - } - - patch.addRecord(startOffset, differentData); - } - } - - return patch; -} From c1293bb3ed6a206d799e18fafc5583939bb37d5a Mon Sep 17 00:00:00 2001 From: Marc Robledo Date: Sun, 21 Jul 2024 11:12:39 +0200 Subject: [PATCH 6/8] show expected ROM source if patch can validate source, for issue #69 --- index.html | 5 +++-- js/RomPatcher.js | 45 ++++++++++++++++++++++++++++++++++++++++++-- js/formats/bps.js | 8 +++++++- js/formats/pmsr.js | 8 +++++++- js/formats/rup.js | 12 +++++++++++- js/formats/ups.js | 6 +++++- js/locale.js | 14 ++++++++++++++ style/RomPatcher.css | 2 +- 8 files changed, 91 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 0e30fe1..12f7b2b 100644 --- a/index.html +++ b/index.html @@ -82,7 +82,7 @@ }] } ];*/ - --> + -->
@@ -125,6 +125,7 @@
+
@@ -180,7 +181,7 @@
- Rom Patcher JS v2.8.1 by Marc Robledo + Rom Patcher JS v2.9 by Marc Robledo
See on GitHub Donate diff --git a/js/RomPatcher.js b/js/RomPatcher.js index fe8551c..73ea8d1 100644 --- a/js/RomPatcher.js +++ b/js/RomPatcher.js @@ -1,4 +1,4 @@ -/* Rom Patcher JS v20230406 - Marc Robledo 2016-2023 - http://www.marcrobledo.com/license */ +/* Rom Patcher JS v20240721 - Marc Robledo 2016-2024 - http://www.marcrobledo.com/license */ const TOO_BIG_ROM_SIZE=67108863; const HEADERS_INFO=[ @@ -112,7 +112,13 @@ function parseCustomPatch(customPatch){ if(typeof customPatch.crc==='number'){ patch.validateSource=function(romFile,headerSize){ return customPatch.crc===crc32(romFile, headerSize) - } + }; + patch.getValidationInfo=function(){ + return [{ + 'type':'CRC32', + 'value':padZeroes(customPatch.crc,4) + }] + }; }else if(typeof customPatch.crc==='object'){ patch.validateSource=function(romFile,headerSize){ for(var i=0; i Date: Sun, 21 Jul 2024 11:13:09 +0200 Subject: [PATCH 7/8] version bump --- _cache_service_worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_cache_service_worker.js b/_cache_service_worker.js index c52dc42..f71307c 100644 --- a/_cache_service_worker.js +++ b/_cache_service_worker.js @@ -14,7 +14,7 @@ */ var PRECACHE_ID='rom-patcher-js'; -var PRECACHE_VERSION='v281'; +var PRECACHE_VERSION='v29'; var PRECACHE_URLS=[ '/RomPatcher.js/','/RomPatcher.js/index.html', '/RomPatcher.js/manifest.json', From 41174df6c5667fac717b5022e73f77bbc6ecdbf4 Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 21 Jul 2024 12:52:54 +0200 Subject: [PATCH 8/8] sort zipped files by name and folder --- _cache_service_worker.js | 2 +- index.html | 2 +- js/formats/zip.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/_cache_service_worker.js b/_cache_service_worker.js index f71307c..a10b242 100644 --- a/_cache_service_worker.js +++ b/_cache_service_worker.js @@ -14,7 +14,7 @@ */ var PRECACHE_ID='rom-patcher-js'; -var PRECACHE_VERSION='v29'; +var PRECACHE_VERSION='v291'; var PRECACHE_URLS=[ '/RomPatcher.js/','/RomPatcher.js/index.html', '/RomPatcher.js/manifest.json', diff --git a/index.html b/index.html index 12f7b2b..1f41641 100644 --- a/index.html +++ b/index.html @@ -181,7 +181,7 @@ - Rom Patcher JS v2.9 by Marc Robledo + Rom Patcher JS v2.9.1 by Marc Robledo
See on GitHub Donate diff --git a/js/formats/zip.js b/js/formats/zip.js index f5c28f0..46dba1e 100644 --- a/js/formats/zip.js +++ b/js/formats/zip.js @@ -1,4 +1,4 @@ -/* ZIP module for Rom Patcher JS v20220319 - Marc Robledo 2016-2022 - http://www.marcrobledo.com/license */ +/* ZIP module for Rom Patcher JS v20230721 - Marc Robledo 2016-2024 - http://www.marcrobledo.com/license */ const ZIP_MAGIC='\x50\x4b\x03\x04'; @@ -51,6 +51,16 @@ var ZIPManager=(function(){ filteredEntries.push(zipEntries[i]); } } + /* sort patch files by name and folder */ + filteredEntries + .sort(function(file1, file2){ + return file1.filename.toLowerCase().localeCompare(file2.filename.toLowerCase()); + }) + .sort(function(file1, file2){ + var file1Folder=file1.filename.indexOf('/')===-1? 0 : 1; + var file2Folder=file2.filename.indexOf('/')===-1? 0 : 1; + return file1Folder - file2Folder; + });