zelda64
Version:
Zelda64.js is a library that can compress, decompress and patch Nintendo 64 Zelda game ROMs.
67 lines (66 loc) • 2.77 kB
TypeScript
/**
* Byte swaps the endianness of a 32-bit integer.
* @param value The 32-bit integer to swap.
*/
export declare function swap32(value: number): number;
/**
* Byte swaps the endianness of a 16-bit integer.
* @param value The 16-bit integer to swap.
*/
export declare function swap16(value: number): number;
export declare function parse32(src: Uint8Array, offset: number): number;
/**
* This function exists to pwn JavaScript's untyped 64-bit signed integers to 32-bit unsigned GIGACHAD integers.
* @param value Weak virgin 64-bit signed integer.
* @returns Strong GIGACHAD 32-bit unsigned integer.
*/
export declare function u32(value: number): number;
/**
* SeekableBuffer implements a wrapper over ArrayBuffer that implements seeking capabilities for sequential read/writes.
*/
declare class SeekableBuffer {
protected _buffer: ArrayBuffer;
protected _view: DataView;
protected _cursor: number;
/**
* Constructs instance of SeekableBuffer.
* @param buffer The ArrayBuffer to operate on.
*/
constructor(buffer: ArrayBuffer);
/**
* Moves the cursor to a position on the buffer.
* @param pos The amount of places to move the cursor relative to the whence argument.
* @param whence Specifies the relation of where the cursor moves. "begin" moves it from the beginning of the
* buffer, "current" moves it relative to the cursor's current position, and "end" moves it relative
* to the end of the buffer. Defaults to "current".
* @returns The old position of the cursor.
*/
seek(pos: number, whence?: "begin" | "current" | "end"): number;
/**
* Checks whether the cursor has passed the end of the buffer.
* @returns true if the end of buffer is reached, false if not.
*/
eof(): boolean;
}
/**
* Reader implements sequential read operations on an ArrayBuffer.
*/
export declare class Reader extends SeekableBuffer {
constructor(buffer: ArrayBuffer);
readUint8(offset?: number): number;
readUint16(offset?: number): number;
readUint24(offset?: number): number;
readInt32(offset?: number, littleEndian?: boolean): number;
readUint32(offset?: number, bigEndian?: boolean): number;
readBytes(length: number, offset?: number): ArrayBuffer;
}
/**
* Writer implements sequential write operations on an ArrayBuffer.
*/
export declare class Writer extends SeekableBuffer {
constructor(buffer: ArrayBuffer);
writeUint32(value: number, offset?: number, littleEndian?: boolean): void;
writeBytes(data: ArrayBuffer, offset?: number, size?: number): void;
fill(value: number, size: number, offset?: number): void;
}
export {};