/// <summary>
        /// Responds to virtual machine state changes
        /// </summary>
        private async void MachineViewModelOnVmStateChanged(object sender, VmStateChangedEventArgs args)
        {
            if (args.NewState == VmState.Running || args.NewState == VmState.Stopped)
            {
                // --- Remove the highlight from the last breakpoint
                var prevFile = CurrentBreakpointFile;
                var prevLine = CurrentBreakpointLine;

                // --- Remove current breakpoint information
                CurrentBreakpointFile = null;
                CurrentBreakpointLine = -1;
                UpdateBreakpointVisuals(prevFile, prevLine, false);
            }
            if (args.NewState == VmState.Paused &&
                Package.MachineViewModel.RunsInDebugMode &&
                !Package.Options.DisableSourceNavigation)
            {
                // --- Set up breakpoint information
                var address = Package.MachineViewModel.SpectrumVm.Cpu.Registers.PC;
                if (CompiledOutput?.SourceMap != null &&
                    CompiledOutput.SourceMap.TryGetValue(address, out var fileInfo))
                {
                    // --- Add highlight to the current source code line
                    CurrentBreakpointFile = CompiledOutput
                                            .SourceFileList[fileInfo.FileIndex].Filename;
                    CurrentBreakpointLine = fileInfo.Line - 1;
                    Package.ApplicationObject.Documents.Open(CurrentBreakpointFile);
                    await Task.Delay(10);

                    UpdateBreakpointVisuals(CurrentBreakpointFile, CurrentBreakpointLine, true);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Respond to the state changes of the Spectrum virtual machine
        /// </summary>
        private void OnVmStateChanged(object sender, VmStateChangedEventArgs args)
        {
            Dispatcher.Invoke(() =>
            {
                switch (args.NewState)
                {
                case VmState.Stopped:
                    Vm.Machine.BeeperProvider?.KillSound();
                    Vm.Machine.SoundProvider?.KillSound();
                    Vm.FastLoadCompleted -= OnFastLoadCompleted;
                    ShowUlaRaster();
                    break;

                case VmState.Running:
                    Vm.Machine.BeeperProvider?.PlaySound();
                    Vm.Machine.SoundProvider?.PlaySound();
                    Vm.FastLoadCompleted += OnFastLoadCompleted;
                    ShowUlaRaster();
                    StopShadowScreenRendering();
                    break;

                case VmState.Paused:
                    Vm.Machine.BeeperProvider?.PauseSound();
                    Vm.Machine.SoundProvider?.PauseSound();
                    MachineOnRenderFrameCompleted(this,
                                                  new RenderFrameEventArgs(Vm.Machine.SpectrumVm.ScreenDevice.GetPixelBuffer()));
                    StartShadowScreenRendering();
                    ShowUlaRaster();
                    break;
                }
            },
                              DispatcherPriority.Send);
        }
Пример #3
0
 /// <summary>
 /// Refrehs the stack view when the machine is paused.
 /// </summary>
 private void OnVmStateChanged(object sender, VmStateChangedEventArgs args)
 {
     if (args.NewState == VmState.Paused)
     {
         DispatchOnUiThread(() => Vm.Refresh());
     }
 }
        private void OnVmStateChanged(object sender, VmStateChangedEventArgs args)
        {
            Dispatcher.Invoke(() =>
            {
                switch (args.NewState)
                {
                case VmState.Stopped:
                    _dispatchTimer.Stop();
                    Vm.SpectrumVm.BeeperProvider.KillSound();
                    Vm.SpectrumVm.SoundProvider?.KillSound();
                    break;

                case VmState.Running:
                    _dispatchTimer.Stop();
                    Vm.SpectrumVm.BeeperProvider.PlaySound();
                    Vm.SpectrumVm.SoundProvider?.PlaySound();
                    break;

                case VmState.Paused:
                    Vm.SpectrumVm.BeeperProvider.PauseSound();
                    Vm.SpectrumVm.SoundProvider?.PauseSound();
                    _dispatchTimer.Start();
                    break;
                }
            },
                              DispatcherPriority.Send);
        }
 private void OnVmStateChanged(object sender, VmStateChangedEventArgs args)
 {
     if (args.NewState == VmState.Running)
     {
         Vm.MachineViewModel.SpectrumVm.TapeDevice.LoadCompleted += OnLoadCompleted;
     }
     else if (args.NewState == VmState.Stopped)
     {
         Vm.MachineViewModel.SpectrumVm.TapeDevice.LoadCompleted -= OnLoadCompleted;
     }
     RefreshBasicList();
 }
        private async void OnVmStateChanged(object sender, VmStateChangedEventArgs args)
        {
            if (args.NewState == VmState.Running || args.NewState == VmState.Stopped)
            {
                // --- Remove current breakpoint information
                var oldFile = CurrentBreakpointFile;
                var oldLine = CurrentBreakpointLine;

                CurrentBreakpointFile = null;
                CurrentBreakpointLine = -1;

                if (oldFile != null)
                {
                    Z80AsmViewTaggerProvider.UpdateBreakpointVisuals(oldFile, oldLine);
                }
            }

            var package = SpectNetPackage.Default;

            if (args.NewState == VmState.Paused &&
                package.EmulatorViewModel.Machine.RunsInDebugMode &&
                !package.Options.DisableSourceNavigation)
            {
                // --- Set up breakpoint information
                var address = package.EmulatorViewModel.Machine.SpectrumVm.Cpu.Registers.PC;
                if (CompiledOutput?.SourceMap != null &&
                    CompiledOutput.SourceMap.TryGetValue(address, out var fileInfo))
                {
                    // --- Add highlight to the current source code line
                    CurrentBreakpointFile = CompiledOutput
                                            .SourceFileList[fileInfo.FileIndex].Filename;
                    CurrentBreakpointLine = fileInfo.Line;
                    if (package.Options.ForceShowSourceCode)
                    {
                        package.ShowToolWindow <SpectrumEmulatorToolWindow>();
                        var document = package.ApplicationObject.Documents.Open(CurrentBreakpointFile);
                        document.Activate();
                    }
                    else
                    {
                        package.ApplicationObject.Documents.Open(CurrentBreakpointFile);
                        package.ShowToolWindow <SpectrumEmulatorToolWindow>();
                    }
                    await Task.Delay(10);

                    Z80AsmViewTaggerProvider.UpdateBreakpointVisuals(CurrentBreakpointFile, CurrentBreakpointLine);
                }
            }
        }
        /// <summary>
        /// Respond to the state changes of the Spectrum virtual machine
        /// </summary>
        private void OnVmStateChanged(object sender, VmStateChangedEventArgs args)
        {
            Dispatcher.Invoke(() =>
            {
                switch (args.NewState)
                {
                case VmState.Stopped:
                    Vm.SpectrumVm.BeeperProvider.KillSound();
                    Vm.SpectrumVm.TapeDevice.LoadCompleted -= OnFastLoadCompleted;
                    break;

                case VmState.Running:
                    Vm.SpectrumVm.BeeperProvider.PlaySound();
                    Vm.SpectrumVm.TapeDevice.LoadCompleted += OnFastLoadCompleted;
                    break;

                case VmState.Paused:
                    Vm.SpectrumVm.BeeperProvider.PauseSound();
                    break;
                }
            },
                              DispatcherPriority.Send);
        }
Пример #8
0
 /// <summary>
 /// Changes the caption whenever the VM state changes
 /// </summary>
 private void VmOnVmStateChanged(object sender, VmStateChangedEventArgs args)
 {
     ChangeCaption(args.NewState);
 }
 /// <summary>
 /// Dispatch the vm state changed message on the UI thread
 /// </summary>
 private void OnInternalVmStateChanged(object sender, VmStateChangedEventArgs args)
 {
     DispatchOnUiThread(() => OnVmStateChanged(args.OldState, args.NewState));
 }
Пример #10
0
 /// <summary>
 /// Changes the caption whenever the VM state changes
 /// </summary>
 private void VmOnVmStateChanged(object sender, VmStateChangedEventArgs e)
 {
     ChangeCaption();
 }