/* APS (GBA) module for Rom Patcher JS v20230331 - Marc Robledo 2017-2023 - http://www.marcrobledo.com/license */ /* File format specification: https://github.com/btimofeev/UniPatcher/wiki/APS-(GBA) */ const APS_GBA_MAGIC='APS1'; const APS_GBA_BLOCK_SIZE=0x010000; //64Kb const APS_GBA_RECORD_SIZE=4 + 2 + 2 + APS_GBA_BLOCK_SIZE; function APSGBA(){ this.sourceSize=0; this.targetSize=0; this.records=[]; } APSGBA.prototype.addRecord=function(offset, sourceCrc16, targetCrc16, xorBytes){ this.records.push({ offset:offset, sourceCrc16:sourceCrc16, targetCrc16:targetCrc16, xorBytes:xorBytes} ); } APSGBA.prototype.toString=function(){ var s='Total records: '+this.records.length; s+='\nInput file size: '+this.sourceSize; s+='\nOutput file size: '+this.targetSize; return s } APSGBA.prototype.validateSource=function(sourceFile){ if(sourceFile.fileSize!==this.sourceSize) return false; var originalEndianness=sourceFile.littleEndian; sourceFile.littleEndian=true; for(var i=0; i