mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
38 lines
684 B
TypeScript
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() {
|
||
|
}
|
||
|
}
|
||
|
|