internal MMC3Mapper(IImageReader reader, IMemoryBus cpuBus, IMemoryBus ppuBus, IProcessorInterrupt irq) : base(reader, cpuBus, ppuBus) { if (this.Reader.PrgRamSize > MMC3Mapper.PrgRamMaxSize) { throw new ArgumentOutOfRangeException("MMC3 supports a maximum of 8KB of PRG RAM"); } if (this.Reader.PrgRomSize > MMC3Mapper.PrgRomMaxSize) { throw new ArgumentOutOfRangeException("MMC3 supports a maximum of 512KB of PRG ROM"); } if (this.Reader.ChrRomSize > MMC3Mapper.ChrRomMaxSize) { throw new ArgumentOutOfRangeException("MMC3 supports a maximum of 256KB of CHR ROM"); } this.irq = irq; // Initialize ROM int prgRomSize = this.Reader.PrgRomSize; int prgRamSize = (this.Reader.PrgRamSize != 0) ? this.Reader.PrgRamSize : 0x2000; int chrRomSize = (this.Reader.ChrRomSize != 0) ? this.Reader.ChrRomSize : 0x2000; this.prgRomBanks = this.Reader.PrgRomSize / MMC3Mapper.PrgRomBankSize; this.chrRomBanks = (this.Reader.ChrRomSize != 0) ? (this.Reader.ChrRomSize / MMC3Mapper.ChrRomBankSize) : 8; this.prgRam = new byte[prgRamSize]; this.prgRom = new byte[prgRomSize]; this.chrRom = new byte[chrRomSize]; // Read PRG ROM this.Reader.GetPrgRom(0, this.prgRom, 0, prgRomSize); if (this.Reader.ChrRomSize != 0) { // Read CHR ROM this.Reader.GetChrRom(0, this.chrRom, 0, chrRomSize); } // 8K bank of PRG RAM at CPU 0x6000 this.MapCpuRange(this, 0x6000, 0x7FFF); // 2 16K banks of PRG ROM at CPU 0x8000 and 0xC000 this.MapCpuRange(this, 0x8000, 0xFFFF); // 2 2K banks and 4 1K banks of CHR ROM between PPU 0x0000 and 0x1000 this.MapPpuRange(this, 0x0000, 0x1FFF); // Initial state is undefined, except that the last bank of PRG ROM will be mapped from 0xE000 - 0xFFFF this.prgRomBank3Mask = (UInt32)(this.prgRomBanks - 1) << 13; // Set initial nametable mirroring from ROM data as a hack to fix some homebrew that doesn't properly // initialize the mapper base.SetNametableMirroring(this.Reader.Mirroring); }
internal NesApu(IMemoryBus cpuBus, IProcessorCore cpu) { this.cpuIrq = cpu.GetInterruptByName("IRQ"); this.pulse1 = new PulseChannel(true); this.pulse2 = new PulseChannel(false); this.triangle = new TriangleChannel(); this.noise = new NoiseChannel(); this.dmc = new DeltaChannel(cpuBus, cpuIrq); this.isApuCycle = false; this.buffer = new byte[NesApu.BUFFER_SIZE]; this.ptr = Marshal.AllocHGlobal(4); }
internal Ricoh2C02(IProcessorCore cpu, IMemoryBus cpuBus, IMemoryBus ppuBus) { this.ppuBus = ppuBus; this.vbi = cpu.GetInterruptByName("NMI"); this.vbiTimer = new Stopwatch(); this.paletteMemory = new byte[0x20]; this.primaryOam = new byte[0x100]; this.secondaryOam = new byte[0x20]; // PPU registers on CPU bus cpuBus.RegisterMappedDevice(this, 0x2000, 0x2007); // Palette data ppuBus.RegisterMappedDevice(this, 0x3F00, 0x3F1F); // Set up power-on state this.SetPpuCtrl(0x00); this.SetPpuMask(0x00); this.SetOamAddr(0x00); this.spriteZeroHit = false; this.spriteOverflow = false; this.isVBlank = false; this.oddFrame = false; this.scanline = -1; this.cycle = 0; this.registers = new ReadOnlyCollection <IRegister>( new IRegister[] { new RegisterWrapper("scanline", "PPU Scanline", 16, () => this.scanline, s => this.scanline = s), new RegisterWrapper("cycle", "PPU Cycle", 16, () => this.cycle, c => this.cycle = c) }); //this.vbiTimer.Start(); }
IMapper IMapperFactory.CreateInstance(IImageReader reader, IMemoryBus cpuBus, IMemoryBus ppuBus, IProcessorInterrupt irq) { return(new AxROMMapper(reader, cpuBus, ppuBus)); }
internal NesRomLoader(IMemoryBus cpuBus, IMemoryBus ppuBus, IProcessorInterrupt irq) { this.cpuBus = cpuBus; this.ppuBus = ppuBus; this.irq = irq; }
IMapper IMapperFactory.CreateInstance(IImageReader reader, IMemoryBus cpuBus, IMemoryBus ppuBus, IProcessorInterrupt irq) { return(new UxROMMapper(reader, cpuBus, ppuBus, UxRomVariant.Camerica71)); }
internal DeltaChannel(IMemoryBus cpuBus, IProcessorInterrupt irq) { this.cpuBus = cpuBus; this.dmcInterrupt = irq; }