mirror of
https://github.com/marcrobledo/RomPatcher.js.git
synced 2025-06-27 16:25:54 +00:00
show expected ROM source if patch can validate source, for issue #69
This commit is contained in:
parent
0992132c57
commit
c1293bb3ed
8 changed files with 91 additions and 9 deletions
|
@ -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<customPatch.crc.length; i++)
|
||||
|
@ -120,6 +126,14 @@ function parseCustomPatch(customPatch){
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
patch.getValidationInfo=function(){
|
||||
return customPatch.crc.map(function(crc){
|
||||
return {
|
||||
'type':'CRC32',
|
||||
'value':padZeroes(crc,4)
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
validateSource();
|
||||
}
|
||||
|
@ -681,6 +695,33 @@ function _readPatchFile(){
|
|||
patch=null;
|
||||
setMessage('apply', 'error_invalid_patch', 'error');
|
||||
}
|
||||
if(patch && patch.getValidationInfo){
|
||||
const validationInfos=patch.getValidationInfo();
|
||||
el('row-expected-source-info').className='row m-b';
|
||||
el('row-expected-source-info').innerHTML='';
|
||||
|
||||
validationInfos.forEach(function(validationInfo){
|
||||
var leftCol=document.createElement('div');
|
||||
leftCol.className='leftcol text-right';
|
||||
leftCol.innerHTML=_('expected_source').replace('%s', validationInfo.type);
|
||||
var rightCol=document.createElement('div');
|
||||
rightCol.className='rightcol';
|
||||
/*
|
||||
var a=document.createElement('a');
|
||||
a.href='https://www.google.com/search?q=%22'+validationInfo.value+'%22';
|
||||
a.target='_blank';
|
||||
a.className='clickable';
|
||||
a.innerHTML=validationInfo.value;
|
||||
rightCol.appendChild(a);
|
||||
*/
|
||||
rightCol.innerHTML=validationInfo.value;
|
||||
el('row-expected-source-info').appendChild(leftCol);
|
||||
el('row-expected-source-info').appendChild(rightCol);
|
||||
});
|
||||
}else{
|
||||
el('row-expected-source-info').className='row m-b hide';
|
||||
el('row-expected-source-info').innerHTML='';
|
||||
}
|
||||
validateSource();
|
||||
setTabApplyEnabled(true);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* BPS module for Rom Patcher JS v20180930 - Marc Robledo 2016-2018 - http://www.marcrobledo.com/license */
|
||||
/* BPS module for Rom Patcher JS v20240721 - Marc Robledo 2016-2024 - http://www.marcrobledo.com/license */
|
||||
/* File format specification: https://www.romhacking.net/documents/746/ */
|
||||
|
||||
const BPS_MAGIC='BPS1';
|
||||
|
@ -25,6 +25,12 @@ BPS.prototype.toString=function(){
|
|||
return s
|
||||
}
|
||||
BPS.prototype.validateSource=function(romFile,headerSize){return this.sourceChecksum===crc32(romFile, headerSize)}
|
||||
BPS.prototype.getValidationInfo=function(){
|
||||
return [{
|
||||
'type':'CRC32',
|
||||
'value':padZeroes(this.sourceChecksum,4)
|
||||
}]
|
||||
}
|
||||
BPS.prototype.apply=function(romFile, validate){
|
||||
if(validate && !this.validateSource(romFile)){
|
||||
throw new Error('error_crc_input');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* PMSR (Paper Mario Star Rod) module for Rom Patcher JS v20200225 - Marc Robledo 2020 - http://www.marcrobledo.com/license */
|
||||
/* PMSR (Paper Mario Star Rod) module for Rom Patcher JS v20240721 - Marc Robledo 2020-2024 - http://www.marcrobledo.com/license */
|
||||
/* File format specification: http://origami64.net/attachment.php?aid=790 (dead link) */
|
||||
|
||||
const PMSR_MAGIC='PMSR';
|
||||
|
@ -25,6 +25,12 @@ PMSR.prototype.toString=function(){
|
|||
PMSR.prototype.validateSource=function(romFile){
|
||||
return romFile.fileSize===PAPER_MARIO_USA10_FILE_SIZE && crc32(romFile)===PAPER_MARIO_USA10_CRC32;
|
||||
}
|
||||
PMSR.prototype.getValidationInfo=function(){
|
||||
return [{
|
||||
'type':'CRC32',
|
||||
'value':'a7f5cd7e'
|
||||
}]
|
||||
}
|
||||
PMSR.prototype.apply=function(romFile, validate){
|
||||
if(validate && !this.validateSource(romFile)){
|
||||
throw new Error('error_crc_input');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* RUP module for Rom Patcher JS v20180930 - Marc Robledo 2018 - http://www.marcrobledo.com/license */
|
||||
/* RUP module for Rom Patcher JS v20240721 - Marc Robledo 2018-2024 - http://www.marcrobledo.com/license */
|
||||
/* File format specification: http://www.romhacking.net/documents/288/ */
|
||||
|
||||
const RUP_MAGIC='NINJA2';
|
||||
|
@ -54,6 +54,16 @@ RUP.prototype.validateSource=function(romFile,headerSize){
|
|||
}
|
||||
return false;
|
||||
}
|
||||
RUP.prototype.getValidationInfo=function(){
|
||||
var ret=[];
|
||||
for(var i=0; i<this.files.length; i++){
|
||||
ret.push({
|
||||
'type':'MD5',
|
||||
'value':this.files[i].sourceMD5
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
RUP.prototype.apply=function(romFile, validate){
|
||||
var validFile;
|
||||
if(validate){
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* UPS module for Rom Patcher JS v20220315 - Marc Robledo 2017-2022 - http://www.marcrobledo.com/license */
|
||||
/* UPS module for Rom Patcher JS v20240721 - Marc Robledo 2017-2024 - http://www.marcrobledo.com/license */
|
||||
/* File format specification: http://www.romhacking.net/documents/392/ */
|
||||
|
||||
const UPS_MAGIC='UPS1';
|
||||
|
@ -52,6 +52,10 @@ UPS.prototype.export=function(fileName){
|
|||
return tempFile
|
||||
}
|
||||
UPS.prototype.validateSource=function(romFile,headerSize){return crc32(romFile,headerSize)===this.checksumInput}
|
||||
UPS.prototype.getValidationInfo=function(){return [{
|
||||
'type':'CRC32',
|
||||
'value':padZeroes(this.checksumInput,4)
|
||||
}];}
|
||||
UPS.prototype.apply=function(romFile, validate){
|
||||
if(validate && !this.validateSource(romFile)){
|
||||
throw new Error('error_crc_input');
|
||||
|
|
14
js/locale.js
14
js/locale.js
|
@ -9,6 +9,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Apply patch',
|
||||
'rom_file': 'ROM file:',
|
||||
'patch_file': 'Patch file:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Remove header',
|
||||
'add_header': 'Add temporary header',
|
||||
'compatible_formats': 'Compatible formats:',
|
||||
|
@ -41,6 +42,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Aplicar parche',
|
||||
'rom_file': 'Archivo ROM:',
|
||||
'patch_file': 'Archivo parche:',
|
||||
'expected_source': '%s esperado de ROM:',
|
||||
'remove_header': 'Quitar cabecera',
|
||||
'add_header': 'Añadir cabecera temporal',
|
||||
'compatible_formats': 'Formatos compatibles:',
|
||||
|
@ -72,6 +74,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Pas patch toe',
|
||||
'rom_file': 'ROM bestand:',
|
||||
'patch_file': 'Patch bestand:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Verwijder rubriek',
|
||||
'add_header': 'Voeg tijdelijk rubriek toe',
|
||||
'compatible_formats': 'Compatibele formaten:',
|
||||
|
@ -102,6 +105,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Tillämpa korrigeringsfil',
|
||||
'rom_file': 'ROM-fil:',
|
||||
'patch_file': 'Korrigeringsfil:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Ta bort rubrik',
|
||||
'add_header': 'Lägg till tillfällig rubrik',
|
||||
'compatible_formats': 'Kompatibla format:',
|
||||
|
@ -132,6 +136,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Aplicar pedaç',
|
||||
'rom_file': 'Arxiu ROM:',
|
||||
'patch_file': 'Arxiu pedaç:',
|
||||
'expected_source': '%s esperat de ROM:',
|
||||
'remove_header': 'Treure capçalera',
|
||||
'add_header': 'Afegir capçalera temporal',
|
||||
'compatible_formats': 'Formats compatibles:',
|
||||
|
@ -162,6 +167,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Aplicar pedaç',
|
||||
'rom_file': 'Arxiu ROM:',
|
||||
'patch_file': 'Arxiu pedaç:',
|
||||
'expected_source': '%s esperat de ROM:',
|
||||
'remove_header': 'Llevar capçalera',
|
||||
'add_header': 'Afegir capçalera temporal',
|
||||
'compatible_formats': 'Formats compatibles:',
|
||||
|
@ -192,6 +198,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Применить патч',
|
||||
'rom_file': 'Файл ROM:',
|
||||
'patch_file': 'Файл патча:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Удалить заголовок перед применением',
|
||||
'add_header': 'Добавить временный заголовок',
|
||||
'compatible_formats': 'Совместимые форматы:',
|
||||
|
@ -223,6 +230,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Patch anwenden',
|
||||
'rom_file': 'ROM-Datei:',
|
||||
'patch_file': 'Patch-Datei:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Header entfernen',
|
||||
'add_header': 'Header temporär hinzufügen',
|
||||
'compatible_formats': 'Unterstützte Formate:',
|
||||
|
@ -255,6 +263,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Aplicar patch',
|
||||
'rom_file': 'Arquivo da ROM:',
|
||||
'patch_file': 'Arquivo do patch:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Remover cabeçalho',
|
||||
'add_header': 'Adicionar cabeçalho temporário',
|
||||
'compatible_formats': 'Formatos compatíveis:',
|
||||
|
@ -286,6 +295,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'パッチを当て',
|
||||
'rom_file': 'ROMファィル:',
|
||||
'patch_file': 'パッチファイル:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'ヘッダーを削除',
|
||||
'add_header': '一時的なヘッダーを追加',
|
||||
'compatible_formats': '互換性のあるフォーマット:',
|
||||
|
@ -316,6 +326,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Appliquer le patch',
|
||||
'rom_file': 'Fichier ROM:',
|
||||
'patch_file': 'Fichier patch:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Supprimer l\'en-tête',
|
||||
'add_header': 'Ajouter une en-tête temporaire',
|
||||
'compatible_formats': 'Formats compatibles:',
|
||||
|
@ -346,6 +357,7 @@ const LOCALIZATION={
|
|||
'apply_patch': '打补丁',
|
||||
'rom_file': 'ROM文件:',
|
||||
'patch_file': '补丁文件:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': '删除文件头',
|
||||
'add_header': '增加临时文件头',
|
||||
'compatible_formats': '兼容补丁格式:',
|
||||
|
@ -377,6 +389,7 @@ const LOCALIZATION={
|
|||
'apply_patch': '套用patch',
|
||||
'rom_file': 'ROM檔:',
|
||||
'patch_file': 'patch檔:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': '刪除檔頭',
|
||||
'add_header': '增加臨時檔頭',
|
||||
'compatible_formats': '相容格式:',
|
||||
|
@ -407,6 +420,7 @@ const LOCALIZATION={
|
|||
'apply_patch': 'Applica patch',
|
||||
'rom_file': 'File ROM:',
|
||||
'patch_file': 'File patch:',
|
||||
'expected_source': 'Expected ROM %s:',
|
||||
'remove_header': 'Rimuovi header',
|
||||
'add_header': 'Aggiungi header temporaneo',
|
||||
'compatible_formats': 'Formati:',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue