UNPKG

nes-emu

Version:

A NES emulator

48 lines (45 loc) 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _Mapper = _interopRequireDefault(require("./Mapper")); var _memory = require("../../memory"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * The simplest mapper (also called "mapper 0"). * It can have either one or two PRG ROM of 16KB, that are mapped * at ranges $8000-$BFFF and $C000-$FFFF of the CPU memory. * It also has CHR ROM which contains the tile and sprite data. * This CHR ROM is mapped to the PPU memory at addresses $0000-$1FFF. */ class NROM extends _Mapper.default { static get id() { return 0; } /** Creates a memory segment for CPU range $4020-$FFFF. */ createCPUSegment(_ref) { let { cartridge } = _ref; const unused = new _memory.MemoryPadding(0x3fe0); const prgRomFirstPage = this._newPrgBank(); const prgRomLastPage = cartridge.header.prgRomPages === 2 ? this._newPrgBank(1) : new _memory.MemoryMirror(prgRomFirstPage, 0x4000); return _memory.WithCompositeMemory.createSegment([ // Address range Size Description unused, // $4020-$7FFF $3FE0 Unused space prgRomFirstPage, // $8000-$BFFF $4000 PRG ROM (first 16KB of ROM) prgRomLastPage // $C000-$FFFF $4000 PRG ROM (second 16KB of ROM or mirror) ]); } /** Creates a memory segment for PPU range $0000-$1FFF. */ createPPUSegment(_ref2) { let { cartridge } = _ref2; return this._newChrBank(cartridge); } } exports.default = NROM;