Convert cpu6502 to Typescript

This commit is contained in:
Will Scullin 2023-08-05 19:43:03 -07:00
parent 23a1cb83a8
commit fc536fdb20
3 changed files with 3442 additions and 1626 deletions

File diff suppressed because it is too large Load Diff

3417
js/cpu6502.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -16,3 +16,28 @@ export type word = number;
export type address = word;
export type memory = Uint8Array | byte[];
export interface Memory {
/** Read a byte. */
read(page: byte, offset: byte): byte;
/** Write a byte. */
write(page: byte, offset: byte, value: byte): void;
}
/** A mapped region of memory. */
export interface MemoryPages extends Memory {
/** Start page. */
start(): byte;
/** End page, inclusive. */
end(): byte;
}
/**
* Extracts the members of a constant array as a type. Used as:
*
* @example
* const SOME_VALUES = ['a', 'b', 1, 2] as const;
* type SomeValues = MemberOf<typeof SOME_VALUES>; // 'a' | 'b' | 1 | 2
*/
export type MemberOf<T extends ReadonlyArray<unknown>> =
T extends ReadonlyArray<infer E> ? E : never;