zelda64
Version:
Zelda64.js is a library that can compress, decompress and patch Nintendo 64 Zelda game ROMs.
83 lines (82 loc) • 2.25 kB
TypeScript
import { Reader } from "./util";
export declare const CRC_OFFSET = 16;
export declare const CRC_SIZE = 8;
export declare const DMA_RECORD_SIZE = 16;
export declare const COMPRESSED_ROM_SIZE = 33554432;
export declare const DECOMPRESSED_ROM_SIZE = 67108864;
export declare const DMA_INFO_RECORD_INDEX = 2;
export interface DmaRecord {
virtualStart: number;
virtualEnd: number;
physicalStart: number;
physicalEnd: number;
}
export declare enum RomType {
COMPRESSED = 0,
BIG_ENDIAN_COMPRESSED = 1,
DECOMPRESSED = 2,
INVALID = 3
}
/**
* The Rom class provides a read only wrapper around an input ROM, providing a few convenience features to read data
* from the file with ease.
*/
export default class Rom extends Reader {
/**
* The type of ROM.
* @private
*/
private readonly _type;
/**
* Offset in bytes of the DMA table.
* @private
*/
private readonly _dmaOffset;
/**
* The size of the DMA table in bytes.
* @private
*/
private readonly _dmaSize;
/**
* The amount of entries in the DMA table.
* @private
*/
private readonly _dmaCount;
/**
* Constructs a Rom instance.
* @param buffer Instance of ArrayBuffer containing the input ROM.
*/
constructor(buffer: ArrayBuffer);
private _findRomType;
/**
* Converts endianness of the ROM data.
* @private
*/
private _fixEndianness;
/**
* Finds the start of the DMA table on the ROM.
* @returns The byte offset of the DMA table.
* @private
*/
private _findDmaTableOffset;
/**
* Reads the DMA record at the specific
* @param index
*/
readDmaRecord(index: number): {
virtualStart: number;
virtualEnd: number;
physicalStart: number;
physicalEnd: number;
};
/**
* Finds the DMA record for a given file key.
* @param key The file key to search for.
*/
readDmaRecordByKey(key: number): DmaRecord | undefined;
get dmaOffset(): number;
get dmaCount(): number;
get dmaSize(): number;
get type(): RomType;
get bigEndian(): boolean;
}