Exemplo n.º 1
0
        public void FrameAdvance(IController controller, bool render, bool renderSound)
        {
            _controller = controller;

            // NOTE: Need to research differences between reset and power cycle
            if (_controller.IsPressed("Power"))
            {
                HardReset();
            }

            if (_controller.IsPressed("Reset"))
            {
                SoftReset();
            }

            _cpu.Debug = _tracer.Enabled;
            _frame++;
            _isLag = true;
            PSG.BeginFrame(_cpu.TotalExecutedCycles);

            if (_cpu.Debug && _cpu.Logger == null)             // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first
            {
                _cpu.Logger = (s) => _tracer.Put(s);
            }

            byte tempRet1 = ControllerDeck.ReadPort1(controller, true, true);
            byte tempRet2 = ControllerDeck.ReadPort2(controller, true, true);

            bool intPending = (!tempRet1.Bit(4)) | (!tempRet2.Bit(4));

            _vdp.ExecuteFrame(intPending);

            PSG.EndFrame(_cpu.TotalExecutedCycles);

            if (_isLag)
            {
                _lagCount++;
            }
        }