/* 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'; const YAY0_MAGIC='Yay0'; const PAPER_MARIO_USA10_CRC32=0xa7f5cd7e; const PAPER_MARIO_USA10_FILE_SIZE=41943040; function PMSR(){ this.targetSize=0; this.records=[]; } PMSR.prototype.addRecord=function(offset, data){ this.records.push({offset:offset, data:data}) } PMSR.prototype.toString=function(){ var s='Star Rod patch'; s+='\nTarget file size: '+this.targetSize; s+='\n#Records: '+this.records.length; return s; } 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'); } console.log('a'); if(this.targetSize===romFile.fileSize){ tempFile=romFile.slice(0, romFile.fileSize); }else{ tempFile=new MarcFile(this.targetSize); romFile.copyToFile(tempFile,0); } console.log('b'); for(var i=0; ipatch.targetSize) patch.targetSize=offset+length; } return patch; } /* to-do */ //MOD.prototype.export=function(fileName){return null} //function createMODFromFiles(original, modified){return null} /* https://github.com/pho/WindViewer/wiki/Yaz0-and-Yay0 */ PMSR.YAY0_decode=function(file){ /* to-do */ }