private void StartButton_Click(object sender, RoutedEventArgs e) { var interruptController = new InterruptController(); var ram = new RandomAccessMemoryController(1 * 1024 * 1024); var bootManager = new BootManager(MainPage.BootImage()); this.processor = new Processor(); this.system = new SystemBusController() { Processor = this.processor, InterruptController = interruptController }; this.system.AddDevice(ram); this.system.AddDevice(bootManager); this.system.AddDevice(this.processor); this.system.AddDevice(interruptController); var stream = MainPage.DiskImage(); stream.SetLength(8 * 1024 * 1024); this.system.AddDevice(new DiskDrive(stream)); this.keyboard = new Keyboard(); this.InputTextBox.KeyDown += this.OnKeyDown; this.InputTextBox.KeyUp += this.OnKeyUp; this.system.AddDevice(this.keyboard); this.display = new Display((ulong)this.ScreenImage.Width, (ulong)this.ScreenImage.Height); this.system.AddDevice(this.display); this.processor.DebugHandler = (a, b, c) => a.Value = (ulong)DateTime.UtcNow.Ticks; this.processor.BreakHandler = async() => await this.Dispatcher.InvokeTaskAsync(() => { this.BreakButton.IsEnabled = false; this.ContinueButton.IsEnabled = true; this.StepButton.IsEnabled = true; this.RefreshDebug(); }); this.system.Reset(); this.RefreshDebug(); this.StartButton.IsEnabled = false; this.StopButton.IsEnabled = true; this.BreakButton.IsEnabled = false; this.ContinueButton.IsEnabled = true; this.StepButton.IsEnabled = true; this.RefreshButton.IsEnabled = true; }
private void StopButton_Click(object sender, RoutedEventArgs e) { this.displayRefreshTimer.Stop(); this.RefreshDebug(); this.system.Dispose(); this.system = null; this.processor = null; this.StartButton.IsEnabled = true; this.StopButton.IsEnabled = false; this.BreakButton.IsEnabled = false; this.ContinueButton.IsEnabled = false; this.StepButton.IsEnabled = false; this.RefreshButton.IsEnabled = false; this.InputTextBox.KeyDown -= this.OnKeyUp; this.InputTextBox.KeyUp -= this.OnKeyDown; this.currentPressedKeys.Clear(); }