UNPKG

broken-neees

Version:

A really broken NEEES emulator that introduces glitches and random bugs on purpose!

44 lines (38 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _byte = _interopRequireDefault(require("./lib/byte")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const RAM_SIZE = 2048; class CPUMemory { constructor() { this.ram = new Uint8Array(RAM_SIZE); } onLoad(ppu, apu, mapper, controllers) { this.ppu = ppu; this.apu = apu; this.mapper = mapper; this.controllers = controllers; } read(address) { // 2 KiB internal RAM if (address <= 0x07ff) return this.ram[address]; // Mirrors of $0000-$07FF if (address >= 0x0800 && address <= 0x1fff) return this.read(0x0000 + (address - 0x0800) % 0x0800); /* 🐒 The rest of the components are mapped in `NEEES` */ return 0; } write(address, value) { // 2 KiB internal RAM if (address <= 0x07ff) return this.ram[address] = value; // Mirrors of $0000-$07FF if (address >= 0x0800 && address <= 0x1fff) return this.write(0x0000 + (address - 0x0800) % 0x0800, value); /* 🐒 The rest of the components are mapped in `NEEES` */ } read16(address) { return _byte.default.buildU16(this.read(address + 1), this.read(address)); } } exports.default = CPUMemory;