예제 #1
0
        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);
        }
예제 #2
0
        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();
        }