| var Memory = require('src/memory'); | |||||
| var Memory = require('./memory'); | |||||
| class Bank extends Memory{ | class Bank extends Memory{ | ||||
| constructor(size, ro){ | constructor(size, ro){ | ||||
| this.__listeners[addr].push(fn); | 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){ | if (this.__map){ | ||||
| let dc = data; | let dc = data; | ||||
| if (address < 0 || address >= this.__map.length) | if (address < 0 || address >= this.__map.length) | ||||
| throw new RangeError("Memory address out of range."); | throw new RangeError("Memory address out of range."); | ||||
| if (this.__map.length - address < dc.length) | if (this.__map.length - address < dc.length) | ||||
| dc = dc.slice(0, this.__map.length - address); | dc = dc.slice(0, this.__map.length - address); | ||||
| this.__map.set(address, dc); | |||||
| this.__map.set(dc, address); | |||||
| return dc.length; | 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); | |||||
| } | |||||
| } | } | ||||