Example #1
0
        /// <summary>
        /// The input cycle.
        /// </summary>
        private static void InputCycle()
        {
            while (AsciiRenderer.IsWindowOpen())
            {
                // Wait until key is pressed.
                KeyPress press = Keyboard.WaitForKeyPress(true);

                // Convert byte to keycode.
                AsciiInput input = UserInput.FormatInput(press);

                // Invoke the key pressed event.
                OnKeyPressed?.Invoke(input);
            }
        }
Example #2
0
        public void KeyPressed(AsciiInput input)
        {
            if (input.Key == "=") // Increment page
            {
                if (page < 255)
                {
                    page++;
                }
                else
                {
                    page = 0;
                }
            }

            if (input.Key == "-") // Decrement page
            {
                if (page > 0)
                {
                    page--;
                }
                else
                {
                    page = 255;
                }
            }

            if (input.Key == "Space") // Execute next instruction
            {
                cycles += cpu.Execute(ref mem);
            }

            if (input.Key == "r") // Reset the cpu
            {
                cpu.Reset();
                cycles = 0;
            }
        }