|
|
@@ -1,5 +1,5 @@ |
|
|
|
|
|
|
|
var Memory = require('src/memory'); |
|
|
|
var Memory = require('./memory'); |
|
|
|
|
|
|
|
class Bank extends Memory{ |
|
|
|
constructor(size, ro){ |
|
|
@@ -41,19 +41,31 @@ class Bank extends Memory{ |
|
|
|
this.__listeners[addr].push(fn); |
|
|
|
} |
|
|
|
|
|
|
|
// This method is intended for the emulator to fill a Read-Only memory module with data prior to |
|
|
|
// the start of execution. This method should never be used in a running system. |
|
|
|
sysStore(address, data){ |
|
|
|
load(address, data){ |
|
|
|
if (this.__map){ |
|
|
|
let dc = data; |
|
|
|
if (address < 0 || address >= this.__map.length) |
|
|
|
throw new RangeError("Memory address out of range."); |
|
|
|
if (this.__map.length - address < dc.length) |
|
|
|
dc = dc.slice(0, this.__map.length - address); |
|
|
|
this.__map.set(address, dc); |
|
|
|
this.__map.set(dc, address); |
|
|
|
return dc.length; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
clearPage(page){ |
|
|
|
if (this.__map){ |
|
|
|
let addr = (page << 8) & 0xFF00; |
|
|
|
if (addr < 0 || addr >= this.__map.length) |
|
|
|
throw new RangeError("Memory address out of range."); |
|
|
|
this.__map.fill(0, addr, addr + 256); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
clear(){ |
|
|
|
if (this.__map) |
|
|
|
this.__map.fill(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|