Exemple #1
0
        public void OnInput(InputUtil inputUtil)
        {
            if (_InputTimer < _InputWaitTime)
            {
                return;
            }

            // Toggle emulation mode on/off
            if (inputUtil.IsKeyPressed((byte)' '))
            {
                // If we are currently running to the next LDA instruction, then cancel that first
                // otherwise, toggle emulation mode on/off
                if (_runToNextLDA)
                {
                    _runToNextLDA = false;
                    _InputTimer   = 0;
                }
                else
                {
                    _EmulationMode = !_EmulationMode;
                    _InputTimer    = 0;

                    if (_EmulationMode)
                    {
                        _InputStepCycle = false;
                        _InputStepFrame = false;
                        _InputReset     = false;
                    }
                }
            }

            // Step one CPU instruction
            if (!_EmulationMode && inputUtil.IsKeyPressed((byte)'C'))
            {
                _InputStepCycle = true;
                _InputTimer     = 0;
            }

            // Run the ROM until the next occurance of the LDA instruction, then halt
            if (!_EmulationMode && inputUtil.IsKeyPressed((byte)'L'))
            {
                _runToNextLDA = true;
                _InputTimer   = 0;
            }

            // Cycle through the available palettes.
            if (inputUtil.IsKeyPressed((byte)'P'))
            {
                _selectedPalette++;
                _selectedPalette &= 0x07;
            }

            // Step one PPU frame
            if (!_EmulationMode && inputUtil.IsKeyPressed((byte)'F'))
            {
                _InputStepFrame = true;
                _InputTimer     = 0;
            }

            // Reset the NES
            if (inputUtil.IsKeyPressed((byte)'R'))
            {
                _InputReset     = true;
                _InputStepCycle = false;
                _InputStepFrame = false;
                _runToNextLDA   = false;
                _InputTimer     = 0;
            }
        }