Exemple #1
0
        public NesSystem(IHostGraphics hostGraphics)
        {
            _clock  = new Clock();
            _cpuBus = new Bus();

            // CPU
            _cpu = new CPU(_cpuBus.MasterClient);
            _clock.AddSink(_cpu);

            // 片上 RAM
            _cpuOnChipRAM = new OnChipRAM(OnChipRAMSize);
            _clock.AddSink(_cpuOnChipRAM);

            // APU
            _apu = new APU();

            // PPU
            _ppuBus = new Bus();
            _ppu    = new PPU(_ppuBus, _cpu, hostGraphics);
            _clock.Add3TimesSink(_ppu);

            _nametableMirrorController = new NametableMirrorController();

            // 板卡
            Cartridge = new Cartridge(_nametableMirrorController);

            SetupCPUMemoryMap();
            SetupPPUMemoryMap();
        }
Exemple #2
0
        private void SetupPPUMemoryMap()
        {
            _ppuBus.AddSlave(0x0000, Cartridge.ChrRom);
            _ppuBus.AddSlave(0x2000, _nametableMirrorController);
            _ppuBus.AddSlave(0x3000, _nametableMirrorController, memoryMapSize: 0xF00);

            var paletteRAM = new OnChipRAM(0x20);

            for (ushort i = 0x3F00; i < 0x3FFF; i += 0x20)
            {
                _ppuBus.AddSlave(i, paletteRAM);
            }
        }