예제 #1
0
 public void LoadRom(MemoryBlock rom)
 {
     emulationStatus = EmulationStatus.Stopped;
     bus.LoadRom(rom);
     emulationStatus = EmulationStatus.Paused;
     OnRomChanged(EventArgs.Empty);
 }
예제 #2
0
 public void StopEmulation()
 {
     Emulation = EmulationStatus.Off;
     foreach (var thread in _runnedElementsThreads)
     {
         thread.Abort();
     }
     _runnedElementsThreads.Clear();
     foreach (var element in ElementsList)
     {
         element.Stop();
     }
     EmulationTime         = 0;
     timerLabel.Content    = "0:00:00,00";
     startButton.IsEnabled = true;
     pauseButton.IsEnabled = false;
     stopButton.IsEnabled  = false;
     pauseButton.Content   = "Pause";
     errorShow             = false;
     foreach (var connect in Connectors)
     {
         connect.MakePointGreen();
     }
     ResultWindow.Generated2 = "0";
     ResultWindow.Complite2  = "0";
     MainWindow.SeriesCollection[0].Values.Clear();
     MainWindow.SeriesCollection[1].Values.Clear();
     MainWindow.ResultList.Clear();
     resultWindow.Hide();
 }
예제 #3
0
 public EmulatedGameBoy()
 {
     synchronizationContext = SynchronizationContext.Current;
     bus                   = new GameBoyMemoryBus();
     frameStopwatch        = new Stopwatch();
     frameRateStopwatch    = new Stopwatch();
     bus.EmulationStarted += OnEmulationStarted;
     bus.EmulationStopped += OnEmulationStopped;
     bus.BorderChanged    += OnBorderChanged;
     bus.ClockManager      = this;
     emulationStatus       = bus.UseBootRom ? EmulationStatus.Paused : EmulationStatus.Stopped;
 }
예제 #4
0
 private void pauseButton_Click(object sender, RoutedEventArgs e)
 {
     if (Emulation == EmulationStatus.Pause)
     {
         Emulation           = EmulationStatus.On;
         pauseButton.Content = "Pause";
     }
     else
     {
         Emulation           = EmulationStatus.Pause;
         pauseButton.Content = "Resume";
     }
 }
예제 #5
0
		public EmulatedGameBoy(IContainer container)
		{
			bus = new GameBoyMemoryBus();
			frameStopwatch = new Stopwatch();
			frameRateStopwatch = new Stopwatch();
#if WITH_THREADING
			bus.EmulationStarted += OnEmulationStarted;	
			bus.EmulationStopped += OnEmulationStopped;
			bus.ClockManager = this;
#else
			Application.Idle += OnApplicationIdle;
#endif
			bus.ReadKeys += new EventHandler<ReadKeysEventArgs>(OnReadKeys);
			emulationStatus = bus.UseBootRom ? EmulationStatus.Paused : EmulationStatus.Stopped;
			if (container != null) container.Add(this);
		}
예제 #6
0
        public static void ErrorStop(IElement element, Image errorPoint)
        {
            Emulation = EmulationStatus.Pause;
            errorShow = true;
            string name = "";

            (element.Image).Dispatcher.Invoke((Action)(() =>
            {
                name = ((Image)element.Image).Name;
            }));
            foreach (var connect in Connectors)
            {
                if (connect.HavePoint(errorPoint))
                {
                    connect.MakePointRed();
                }
            }
            MessageBox.Show("Следующий элемент переполнен", "Error in " + name, MessageBoxButton.OK, MessageBoxImage.Error);
        }
예제 #7
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            Emulation             = EmulationStatus.On;
            startButton.IsEnabled = false;
            pauseButton.IsEnabled = true;
            stopButton.IsEnabled  = true;

            foreach (var element in ElementsList)
            {
                Thread newThread = new Thread(
                    o =>
                {
                    while (true)
                    {
                        while (Emulation == EmulationStatus.Pause)
                        {
                            Thread.Sleep(1);
                        }
                        Thread.Sleep(SynchronizationCoefficient);
                        element.Run();
                    }
                });
                _runnedElementsThreads.Add(newThread);
            }
            Thread timerThread = new Thread(
                o =>
            {
                while (true)
                {
                    while (Emulation == EmulationStatus.Pause)
                    {
                        if (errorShow == true)
                        {
                            pauseButton.Dispatcher.Invoke(
                                (Action)(() =>
                            {
                                pauseButton.IsEnabled = false;
                            }
                                         ));
                        }
                        Thread.Sleep(1);
                    }
                    if (speedCoefficient < 0)
                    {
                        Thread.Sleep(SynchronizationCoefficient * Math.Abs(speedCoefficient));
                    }
                    else
                    {
                        Thread.Sleep(SynchronizationCoefficient);
                    }
                    timerLabel.Dispatcher.Invoke(
                        (Action)(() =>
                    {
                        if (MainWindow.Emulation == EmulationStatus.Off)
                        {
                            return;
                        }
                        if (speedCoefficient > 0)
                        {
                            timerLabel.Content =
                                TimeSpan.FromMilliseconds((MainWindow.EmulationTime = (MainWindow.EmulationTime + (1 * speedCoefficient))) * SynchronizationCoefficient)
                                .ToString("g");
                        }
                        else
                        {
                            timerLabel.Content =
                                TimeSpan.FromMilliseconds((MainWindow.EmulationTime++) * SynchronizationCoefficient)
                                .ToString("g");
                        }
                    }));
                }
            });

            _runnedElementsThreads.Add(timerThread);
            foreach (var thread in _runnedElementsThreads)
            {
                thread.Start();
            }
            resultWindow = new ResultWindow(this);
            resultWindow.SeriesCollection = SeriesCollection;
            resultWindow.Show();
        }
예제 #8
0
 public void UnloadRom()
 {
     emulationStatus = EmulationStatus.Stopped;
     bus.UnloadRom();
     emulationStatus = bus.UseBootRom ? EmulationStatus.Paused : EmulationStatus.Stopped;
 }
예제 #9
0
 /// <summary>
 /// Run the emulation loop while EmulationON is true.
 /// </summary>
 public static void EMUClock()
 {
     while (EmulationON)
     {
         if (!EmulationPaused)
         {
             CPUClock();
         }
         else
         {
             EmuStatus = EmulationStatus.PAUSED;
             if (AudioOut != null)
             {
                 AudioOut.Pause();
             }
             if (request_save_sram)
             {
                 EmuStatus         = EmulationStatus.SAVINGSRAM;
                 request_save_sram = false;
                 SaveSRAM();
                 EmulationPaused = false;
             }
             if (request_hardReset)
             {
                 EmuStatus         = EmulationStatus.HARDRESET;
                 request_hardReset = false;
                 hardReset();
                 EmulationPaused = false;
             }
             if (request_softReset)
             {
                 EmuStatus         = EmulationStatus.SOFTRESET;
                 request_softReset = false;
                 softReset();
                 EmulationPaused = false;
             }
             if (request_state_save)
             {
                 EmuStatus          = EmulationStatus.SAVINGSTATE;
                 request_state_save = false;
                 SaveStateAs(STATEFileName);
                 EmulationPaused = false;
             }
             if (request_state_load)
             {
                 EmuStatus          = EmulationStatus.LOADINGSTATE;
                 request_state_load = false;
                 LoadStateAs(STATEFileName);
                 EmulationPaused = false;
             }
             if (request_snapshot)
             {
                 EmuStatus        = EmulationStatus.SAVINGSNAP;
                 request_snapshot = false;
                 videoOut.TakeSnapshot(SNAPSFolder, SNAPSFileName, SNAPSFormat, SNAPSReplace);
                 EmulationPaused = false;
             }
             Thread.Sleep(100);
         }
     }
     // Shutdown
     ShutDown();
 }
예제 #10
0
파일: _NesEmu.cs 프로젝트: ywjno/mynes-code
 /// <summary>
 /// Run the emulation loop while EmulationON is true.
 /// </summary>
 public static void EMUClock()
 {
     while (EmulationON)
     {
         if (!EmulationPaused)
         {
             CPUClock();
         }
         else
         {
             EmuStatus = EmulationStatus.PAUSED;
             if (AudioOut != null)
             {
                 AudioOut.Pause();
             }
             if (request_save_sram)
             {
                 EmuStatus = EmulationStatus.SAVINGSRAM;
                 request_save_sram = false;
                 SaveSRAM();
                 EmulationPaused = false;
             }
             if (request_hardReset)
             {
                 EmuStatus = EmulationStatus.HARDRESET;
                 request_hardReset = false;
                 hardReset();
                 EmulationPaused = false;
             }
             if (request_softReset)
             {
                 EmuStatus = EmulationStatus.SOFTRESET;
                 request_softReset = false;
                 softReset();
                 EmulationPaused = false;
             }
             if (request_state_save)
             {
                 EmuStatus = EmulationStatus.SAVINGSTATE;
                 request_state_save = false;
                 SaveStateAs(STATEFileName);
                 EmulationPaused = false;
             }
             if (request_state_load)
             {
                 EmuStatus = EmulationStatus.LOADINGSTATE;
                 request_state_load = false;
                 LoadStateAs(STATEFileName);
                 EmulationPaused = false;
             }
             if (request_snapshot)
             {
                 EmuStatus = EmulationStatus.SAVINGSNAP;
                 request_snapshot = false;
                 videoOut.TakeSnapshot(SNAPSFolder, SNAPSFileName, SNAPSFormat, SNAPSReplace);
                 EmulationPaused = false;
             }
             Thread.Sleep(100);
         }
     }
     // Shutdown
     ShutDown();
 }
예제 #11
0
		public void UnloadRom()
		{
			emulationStatus = EmulationStatus.Stopped;
			bus.UnloadRom();
			emulationStatus = bus.UseBootRom ? EmulationStatus.Paused : EmulationStatus.Stopped;
		}
예제 #12
0
		public void LoadRom(MemoryBlock rom)
		{
			emulationStatus = EmulationStatus.Stopped;
			bus.LoadRom(rom);
			emulationStatus = EmulationStatus.Paused;
			OnRomChanged(EventArgs.Empty);
		}