Exemplo n.º 1
0
        /// <summary>
        /// Executes a single PPU step.
        /// </summary>
        public void Step()
        {
            // Trigger an NMI at the start of _scanline 241 if VBLANK NMI's are enabled
            if (Scanline == 241)            // && Cycle == 1)
            {
                _nmiOccurred = 1;
                if (_nmiOutput != 0)
                {
                    _console.Cpu.TriggerNmi();
                }
                Scanline = 242;
                //Cycle = 0;
            }
            Cycle += 8;
            //Cycle++;

            // Reset cycle (and scanline if scanline == 260)
            // Also set to next frame if at end of last _scanline
            if (Cycle > 340)
            {
                if (Scanline >= 261)                 // Last scanline, reset to upper left corner
                {
                    f       ^= 1;
                    Scanline = 0;
                    Cycle    = -1;
                    _console.DrawFrame();
                }
                else                 // Not on last scanline
                {
                    Cycle = -1;
                    Scanline++;
                }
            }
        }
Exemplo n.º 2
0
        // Updates scanline and cycle counters, triggers NMI's if needed.
        void UpdateCounters()
        {
            // Trigger an NMI at the start of _scanline 241 if VBLANK NMI's are enabled
            if (Scanline == 241 && Cycle == 1)
            {
                _nmiOccurred = 1;
                if (_nmiOutput != 0)
                {
                    _console.Cpu.TriggerNmi();
                }
            }

            bool renderingEnabled = (_flagShowBackground != 0) || (_flagShowSprites != 0);

            // Skip last cycle of prerender scanline on odd frames
            if (renderingEnabled)
            {
                if (Scanline == 261 && f == 1 && Cycle == 339)
                {
                    f       ^= 1;
                    Scanline = 0;
                    Cycle    = -1;
                    _console.DrawFrame();
                    return;
                }
            }
            Cycle++;

            // Reset cycle (and scanline if scanline == 260)
            // Also set to next frame if at end of last _scanline
            if (Cycle > 340)
            {
                if (Scanline == 261) // Last scanline, reset to upper left corner
                {
                    f       ^= 1;
                    Scanline = 0;
                    Cycle    = -1;
                    _console.DrawFrame();
                }
                else // Not on last scanline
                {
                    Cycle = -1;
                    Scanline++;
                }
            }
        }