1
0
Fork 0
mirror of https://github.com/marcrobledo/RomPatcher.js.git synced 2025-06-27 16:25:54 +00:00

messed up and regressed ppf.js in latest commit for some reason, this should fix it

This commit is contained in:
Marc Robledo 2020-03-03 17:39:44 +01:00
parent 462b2b6b11
commit 8ab9516238
3 changed files with 36 additions and 15 deletions

View file

@ -30,7 +30,7 @@ caches.keys().then(function(cacheNames){
}); });
var PRECACHE_ID='rom-patcher-js'; var PRECACHE_ID='rom-patcher-js';
var PRECACHE_VERSION='v7b'; var PRECACHE_VERSION='v7c';
var PRECACHE_URLS=[ var PRECACHE_URLS=[
'/RomPatcher.js/','/RomPatcher.js/index.html', '/RomPatcher.js/','/RomPatcher.js/index.html',
'/RomPatcher.js/manifest.json', '/RomPatcher.js/manifest.json',

View file

@ -149,7 +149,7 @@
<!-- FOOTER --> <!-- FOOTER -->
<footer> <footer>
Rom Patcher JS <small>v2.2</small> by <a href="/">Marc Robledo</a> Rom Patcher JS <small>v2.2b</small> by <a href="/">Marc Robledo</a>
<br /> <br />
<i class="icon github"></i> <a href="https://github.com/marcrobledo/RomPatcher.js/" target="_blank">See on GitHub</a> <i class="icon github"></i> <a href="https://github.com/marcrobledo/RomPatcher.js/" target="_blank">See on GitHub</a>
<i class="icon heart"></i> <a href="https://www.paypal.me/marcrobledo/5" target="_blank" rel="nofollow">Donate</a> <i class="icon heart"></i> <a href="https://www.paypal.me/marcrobledo/5" target="_blank" rel="nofollow">Donate</a>

47
ppf.js
View file

@ -1,4 +1,4 @@
/* PPF module for Rom Patcher JS v20190401 - Marc Robledo 2019 - http://www.marcrobledo.com/license */ /* PPF module for Rom Patcher JS v20200221 - Marc Robledo 2019-2020 - http://www.marcrobledo.com/license */
/* File format specification: https://www.romhacking.net/utilities/353/ */ /* File format specification: https://www.romhacking.net/utilities/353/ */
@ -6,6 +6,7 @@
const PPF_MAGIC='PPF'; const PPF_MAGIC='PPF';
const PPF_IMAGETYPE_BIN=0x00; const PPF_IMAGETYPE_BIN=0x00;
const PPF_IMAGETYPE_GI=0x01; const PPF_IMAGETYPE_GI=0x01;
const PPF_BEGIN_FILE_ID_DIZ_MAGIC='@BEG';//@BEGIN_FILE_ID.DIZ
function PPF(){ function PPF(){
this.version=3; this.version=3;
@ -28,6 +29,8 @@ PPF.prototype.toString=function(){
s+='\nImage type: '+this.imageType; s+='\nImage type: '+this.imageType;
s+='\nBlock check: '+!!this.blockCheck; s+='\nBlock check: '+!!this.blockCheck;
s+='\nUndo data: '+this.undoData; s+='\nUndo data: '+this.undoData;
if(this.fileIdDiz)
s+='\nFILE_ID.DIZ: '+this.fileIdDiz;
return s return s
} }
PPF.prototype.export=function(fileName){ PPF.prototype.export=function(fileName){
@ -44,6 +47,9 @@ PPF.prototype.export=function(fileName){
if(this.blockCheck){ if(this.blockCheck){
patchFileSize+=1024; patchFileSize+=1024;
} }
if(this.fileIdDiz){
patchFileSize+=18+this.fileIdDiz.length+16+4;
}
tempFile=new MarcFile(patchFileSize); tempFile=new MarcFile(patchFileSize);
tempFile.fileName=fileName+'.ppf'; tempFile.fileName=fileName+'.ppf';
@ -60,11 +66,7 @@ PPF.prototype.export=function(fileName){
tempFile.writeU8(0x00); //dummy tempFile.writeU8(0x00); //dummy
}else if(this.version===2){ }else if(this.version===2){
//unknown data? tempFile.writeU32(this.inputFileSize);
tempFile.writeU8(0x00);
tempFile.writeU8(0x00);
tempFile.writeU8(0x00);
tempFile.writeU8(0x00);
} }
if(this.blockCheck){ if(this.blockCheck){
@ -76,17 +78,26 @@ PPF.prototype.export=function(fileName){
tempFile.littleEndian=true; tempFile.littleEndian=true;
for(var i=0; i<this.records.length; i++){ for(var i=0; i<this.records.length; i++){
tempFile.writeU32(this.records[i].offset & 0xffffffff); tempFile.writeU32(this.records[i].offset & 0xffffffff);
//tempFile.writeU32(0x00000000); //to-do: limited to 4GB right now
var offset2=this.records[i].offset; if(this.version===3){
for(var j=0; j<32; j++) var offset2=this.records[i].offset;
offset2=parseInt((offset2/2)>>>0); for(var j=0; j<32; j++)
tempFile.writeU32(offset2); offset2=parseInt((offset2/2)>>>0);
tempFile.writeU32(offset2);
}
tempFile.writeU8(this.records[i].data.length); tempFile.writeU8(this.records[i].data.length);
tempFile.writeBytes(this.records[i].data); tempFile.writeBytes(this.records[i].data);
if(this.undoData) if(this.undoData)
tempFile.writeBytes(this.records[i].undoData); tempFile.writeBytes(this.records[i].undoData);
} }
if(this.fileIdDiz){
tempFile.writeString('@BEGIN_FILE_ID.DIZ');
tempFile.writeString(this.fileIdDiz);
tempFile.writeString('@END_FILE_ID.DIZ');
tempFile.writeU16(this.fileIdDiz.length);
tempFile.writeU16(0x00);
}
@ -164,17 +175,27 @@ function parsePPFFile(patchFile){
patchFile.skip(1); patchFile.skip(1);
}else if(patch.version===2){ }else if(patch.version===2){
patch.blockCheck=true; patch.blockCheck=true;
patchFile.skip(4); patch.inputFileSize=patchFile.readU32();
} }
if(patch.blockCheck){ if(patch.blockCheck){
patchFile.blockCheck=patchFile.readBytes(1024); patch.blockCheck=patchFile.readBytes(1024);
} }
patchFile.littleEndian=true; patchFile.littleEndian=true;
while(!patchFile.isEOF()){ while(!patchFile.isEOF()){
if(patchFile.readString(4)===PPF_BEGIN_FILE_ID_DIZ_MAGIC){
patchFile.skip(14);
//console.log('found file_id.diz begin');
patch.fileIdDiz=patchFile.readString(3072);
patch.fileIdDiz=patch.fileIdDiz.substr(0, patch.fileIdDiz.indexOf('@END_FILE_ID.DIZ'));
break;
}
patchFile.skip(-4);
var offset; var offset;
if(patch.version===3){ if(patch.version===3){
var u64_1=patchFile.readU32(); var u64_1=patchFile.readU32();