public bool LoadProgramFile(string filePath) { if (cartridge != null) { bus.RemoveComponent(cartridge); } cartridge = new Cartridge(filePath, bus); bus.AddComponent(cartridge, new BusAddressRange(0x4020, 0xFFFF)); ppu.SetCartridge(cartridge); return(true); }
public NES() { //clock = new SystemClock(200000); clock = new SystemClock(5369318); // 1/4 speed of real system, but emulate-able //clock = new SystemClock(21477272); // True speed bus = new SystemBus(0xFFFF); RAM ram = new RAM(2048); ppu = new PPU(clock, bus); cpu = new CPU_2A03(new ClockDivider(clock, 3), bus); // 3x slower than PPU apu = new APU(new ClockDivider(clock, 6)); // 6x slower than PPU controllers[0] = new Controller(0x4016); controllers[1] = new Controller(0x4017); bus.AddComponent(ram, new BusAddressRange(0x0000, 0x1FFF)); bus.AddComponent(ppu, new BusAddressRange(0x2000, 0x3FFF)); bus.AddComponent(apu, new BusAddressRange(0x4000, 0x4013)); bus.AddComponent(cpu, new BusAddressRange(0x4014, 0x4014)); bus.AddComponent(apu, new BusAddressRange(0x4015, 0x4015)); bus.AddComponent((Controller)controllers[0], new BusAddressRange(0x4016, 0x4016)); bus.AddComponent((Controller)controllers[1], new BusAddressRange(0x4017, 0x4017)); bus.AddComponent(apu, new BusAddressRange(0x4017, 0x4017)); }