diff --git a/RomPatcher.js b/RomPatcher.js
index 3d47f90..c085f2a 100644
--- a/RomPatcher.js
+++ b/RomPatcher.js
@@ -1,6 +1,16 @@
-/* RomPatcher.js v20171102 - Marc Robledo 2016-2017 - http://www.marcrobledo.com/license */
-var MAX_ROM_SIZE=33554432;
-var romFile, patch, romFile1, romFile2, tempFile, romHashes={};
+/* RomPatcher.js v20171107 - Marc Robledo 2016-2017 - http://www.marcrobledo.com/license */
+var MAX_ROM_SIZE=33554432;var SNES_HEADERED_ROMS_SIZE=[
+ 262144+512,
+ 524288+512,
+ 1048576+512,
+ 2097152+512,
+ 4194304+512,
+ 8388608+512,
+ 16777216+512,
+ 33554432+512,
+ 50331648+512
+];
+var romFile, headeredRomFile, unheaderedRomFile, patch, romFile1, romFile2, tempFile;
/* Shortcuts */
function addEvent(e,ev,f){e.addEventListener(ev,f,false)}
function el(e){return document.getElementById(e)}
@@ -17,16 +27,16 @@ addEvent(window,'load',function(){
addEvent(el('input-file-rom'), 'change', function(){
romFile=new MarcBinFile(this, function(){
- el('rom-info').innerHTML='';
- sha1(romFile);
- romHashes.crc32=crc32(romFile);
- romHashes.md5=md5(romFile);
+ el('checkbox-removeheader').checked=false;
+ unheaderedRomFile=null;
- var crc32str=romHashes.crc32.toString(16);
- while(crc32str.length<8)
- crc32str='0'+crc32str;
- el('rom-info').innerHTML+='CRC32: '+crc32str+'
';
- el('rom-info').innerHTML+='MD5: '+romHashes.md5+'
';
+ if(SNES_HEADERED_ROMS_SIZE.indexOf(romFile.fileSize)>=0){
+ el('row-removeheader').style.display='flex';
+ }else{
+ el('row-removeheader').style.display='none';
+ }
+
+ updateChecksums(romFile);
});
});
addEvent(el('input-file-patch'), 'change', function(){
@@ -38,10 +48,36 @@ addEvent(window,'load',function(){
addEvent(el('input-file-rom2'), 'change', function(){
romFile2=new MarcBinFile(this);
});
+
+ addEvent(el('checkbox-removeheader'), 'change', function(){
+ if(!unheaderedRomFile){
+ headeredRomFile=romFile;
+ unheaderedRomFile=new MarcBinFile(headeredRomFile.fileSize-512);
+ unheaderedRomFile.writeBytes(0, headeredRomFile.readBytes(512, headeredRomFile.fileSize-512));
+ unheaderedRomFile.fileName=headeredRomFile.fileName;
+ }
+
+ if(this.checked)
+ romFile=unheaderedRomFile;
+ else
+ romFile=headeredRomFile;
+
+
+ updateChecksums(romFile);
+ });
});
+function updateChecksums(file){
+ el('rom-info').style.display='block';
+ sha1(file);
+ var crc32str=crc32(file).toString(16);
+ while(crc32str.length<8)
+ crc32str='0'+crc32str;
+ el('crc32').innerHTML=crc32str;
+ el('md5').innerHTML=md5(file);
+}
@@ -130,8 +166,7 @@ function sha1(file){
hexString+='0'+bytes[i].toString(16);
else
hexString+=bytes[i].toString(16);
- romHashes.sha1=hexString;
- el('rom-info').innerHTML+='SHA-1: '+romHashes.sha1+'
';
+ el('sha1').innerHTML=hexString;
}).catch(function(error){
console.error(error);
});
diff --git a/aps.js b/aps.js
index 70b58b0..099e3b9 100644
--- a/aps.js
+++ b/aps.js
@@ -1,4 +1,4 @@
-/* APS (N64) module for RomPatcher.js v20170723 - Marc Robledo 2017 - http://www.marcrobledo.com/license */
+/* APS (N64) module for RomPatcher.js v20171112 - Marc Robledo 2017 - http://www.marcrobledo.com/license */
/* File format specification: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64) */
var RECORD_RLE=0x0000;
@@ -90,7 +90,7 @@ APS.prototype.export=function(){
APS.prototype.apply=function(romFile){
if(this.headerType===1){
if(romFile.readString(0x3c, 3)!==this.header.cartId){
- MarcDialogs.alert('Invalid ROM cart id');
+ MarcDialogs.alert('Error: invalid ROM cart id');
return false;
}
var crc=romFile.readBytes(0x10, 8);
@@ -100,7 +100,7 @@ APS.prototype.apply=function(romFile){
crcOk=false;
}
if(!crcOk){
- MarcDialogs.alert('Invalid ROM checksum');
+ MarcDialogs.alert('Error: invalid ROM checksum');
return false;
}
}
diff --git a/bps.js b/bps.js
index 0522b5c..1c1f9d0 100644
--- a/bps.js
+++ b/bps.js
@@ -1,4 +1,4 @@
-/* BPS module for RomPatcher.js v20171103 - Marc Robledo 2016-2017 - http://www.marcrobledo.com/license */
+/* BPS module for RomPatcher.js v20171112 - Marc Robledo 2016-2017 - http://www.marcrobledo.com/license */
/* File format specification: https://www.romhacking.net/documents/746/ */
var BPS_MAGIC='BPS1';
@@ -30,7 +30,8 @@ BPS.prototype.toString=function(){
}*/
BPS.prototype.apply=function(romFile){
if(this.sourceChecksum!==crc32(romFile,false)){
- MarcDialogs.alert('Warning: invalid source ROM checksum');
+ MarcDialogs.alert('Error: invalid source ROM checksum');
+ return false;
}
diff --git a/index.html b/index.html
index c882ef6..c5b55ff 100644
--- a/index.html
+++ b/index.html
@@ -43,7 +43,17 @@