zelda64
Version:
Zelda64.js is a library that can compress, decompress and patch Nintendo 64 Zelda game ROMs.
77 lines (76 loc) • 2.47 kB
TypeScript
/**
* ZPF Patcher Class
*/
export default class Patcher {
/**
* The ArrayBuffer holding the uncompressed ZPF file's data.
* @private
*/
private readonly _patchData;
/**
* DataView over the ZPF patch data.
* @private
*/
private readonly _patchView;
/**
* The Patch configuration information con
* @private
*/
private readonly _conf;
/**
* Constructs a patcher instance.
* @param patchData An ArrayBuffer instance containing the patch file data.
*/
constructor(patchData: ArrayBuffer);
/**
* Patches the input ROM.
* @param romData Input data to patch on. Readonly.
* @returns ArrayBuffer containing the patched ROM data.
*/
patch(romData: ArrayBuffer): ArrayBuffer;
/**
* Validates the ZPF file header.
* @returns true if a valid ZPF file, false if not.
* @private
*/
private _validateHeader;
/**
* Reads the patch configuration from the patch data.
* @returns The patch configuration data.
* @private
*/
private _readPatchConfiguration;
/**
* Updates the DMA table from the input ROM with the patch data.
* @param patch Reader instance containing the Patch file data.
* @param dst Writer instance containing the destination buffer.
* @param rom Rom instance containing the input ROM data.
* @private
*/
private _updateDmaTable;
/**
* Writes a DMA record to the output buffer.
* @param dst Writer instance containing the output buffer.
* @param index The index of the DMA record in the DMA table.
* @param record The DMA data to write to the table.
* @private
*/
private _writeDmaRecord;
/**
* Writes data blocks from the patch file to the target ROM.
* @param patch Reader instance containing the patch file data.
* @param dst Writer instance containing the output ROM buffer.
* @param rom Rom instance of the input ROM.
* @private
*/
private _patchDataBlocks;
/**
* Seeks the next XOR key.
* @param rom Rom instance containing the input ROM.
* @param address XOR address to start searching from.
* @param addressRange XOR address range to seek in.
* @returns Object containing the next key and address of the key.
* @private
*/
private _getNextXorKey;
}