UNPKG

igir

Version:

🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.

22 lines (21 loc) • 841 B
import APSGBAPatch from './apsGbaPatch.js'; import APSN64Patch from './apsN64Patch.js'; import Patch from './patch.js'; /** * @see https://github.com/btimofeev/UniPatcher/wiki/APS-(N64) */ export default class APSPatch extends Patch { static SUPPORTED_EXTENSIONS = ['.aps']; static FILE_SIGNATURE = Buffer.from('APS1'); static async patchFrom(file) { return file.extractToTempIOFile('r', async (patchFile) => { patchFile.seek(APSPatch.FILE_SIGNATURE.length); const byteFive = (await patchFile.readNext(1)).toString(); const byteSix = (await patchFile.readNext(1)).readUInt8(); if (byteFive === '0' && (byteSix === 0 || byteSix === 1)) { return APSN64Patch.patchFrom(file); } return APSGBAPatch.patchFrom(file); }); } }