/* APS (N64) module for Rom Patcher JS v20180930 - Marc Robledo 2017-2018 - http://www.marcrobledo.com/license */ /* File format specification: https://github.com/btimofeev/UniPatcher/wiki/APS-(N64) */ const APS_MAGIC='APS10'; const APS_RECORD_RLE=0x0000; const APS_RECORD_SIMPLE=0x01; const APS_N64_MODE=0x01; function APS(){ this.records=[]; this.headerType=0; this.encodingMethod=0; this.description='no description'; this.header={}; } APS.prototype.addRecord=function(o, d){ this.records.push({offset:o, type:APS_RECORD_SIMPLE, data:d}) } APS.prototype.addRLERecord=function(o, b, l){ this.records.push({offset:o, type:APS_RECORD_RLE, length:l, byte:b}) } APS.prototype.toString=function(){ var s='Total records: '+this.records.length; s+='\nHeader type: '+this.headerType; if(this.headerType===APS_N64_MODE){ s+=' (N64)'; } s+='\nEncoding method: '+this.encodingMethod; s+='\nDescription: '+this.description; s+='\nHeader: '+JSON.stringify(this.header); return s } APS.prototype.validateSource=function(sourceFile){ if(this.headerType===APS_N64_MODE){ sourceFile.seek(0x3c); if(sourceFile.readString(3)!==this.header.cartId) return false; sourceFile.seek(0x10); var crc=sourceFile.readBytes(8); for(var i=0; i<8; i++){ if(crc[i]!==this.header.crc[i]) return false } } return true } APS.prototype.export=function(fileName){ var patchFileSize=61; if(this.headerType===APS_N64_MODE) patchFileSize+=17; for(var i=0; i2){ patch.addRLERecord(offset, differentBytes[0], differentBytes.length); }else{ patch.addRecord(offset, differentBytes); } //NO se puede comentar??? why???? } } return patch }