Beispiel #1
0
        public void OnUpdate(TimeUtil timeUtil)
        {
            _InputTimer += (float)timeUtil.ElapsedGameTimeMilli;

            if (_InputReset)
            {
                _InputReset = false;
                _NESCore.Reset();
            }

            // update the NES
            if (_EmulationMode)
            {
                do
                {
                    _NESCore.clock();
                } while (!_NESCore.PPU().frameComplete);
                _NESCore.PPU().frameComplete = false;
            }
            else
            {
                if (_runToNextLDA)
                {
                    // Check the end condition (LDA (IMM)) reached
                    if (_NESCore.CPU().opcode == 0xA1 ||
                        _NESCore.CPU().opcode == 0xA5 ||
                        _NESCore.CPU().opcode == 0xA9 ||
                        _NESCore.CPU().opcode == 0xAD ||
                        _NESCore.CPU().opcode == 0xB1 ||
                        _NESCore.CPU().opcode == 0xB5 ||
                        _NESCore.CPU().opcode == 0xB6 ||
                        _NESCore.CPU().opcode == 0xBD)
                    {
                        _runToNextLDA = false;
                    }

                    // advance one complete frame
                    _NESCore.StepCPUInstruction();
                    _InputStepCycle = false;
                }

                if (_InputStepFrame)
                {
                    _NESCore.StepPPUFrame();
                    _NESCore.PPU().frameComplete = false;
                    _InputStepFrame = false;
                }

                if (_InputStepCycle)
                {
                    _NESCore.StepCPUInstruction();
                    _InputStepCycle = false;
                }
            }
        }