apple2js/test/util/memory.ts
Will Scullin bb09a1ec33
Improve debug performance, abstract debugger. (#61)
Stop stringifying opcodes during runtime and only do so upon inspection. Moves all the debugging logic to a common place to allow building an interface.
2021-03-11 22:03:05 -08:00

38 lines
684 B
TypeScript

import { MemoryPages, byte } from '../../js/types';
import { assertByte } from './asserts';
export class TestMemory implements MemoryPages {
private data: Buffer;
constructor(private size: number) {
this.data = Buffer.alloc(size << 8);
}
start() {
return 0;
}
end() {
return this.size - 1;
}
read(page: byte, off: byte) {
assertByte(page);
assertByte(off);
return this.data[(page << 8) | off];
}
write(page: byte, off: byte, val: byte) {
assertByte(page);
assertByte(off);
assertByte(val);
this.data[(page << 8) | off] = val;
}
reset() {
}
}