From d217e797f29b2d727bd7a45dcacd15603b739aa6 Mon Sep 17 00:00:00 2001 From: Michael M Date: Sat, 1 Jul 2017 13:17:18 -0700 Subject: [PATCH] move Movie::DoFrameStep to Core::DoFrameStep --- Source/Core/Core/Core.cpp | 25 +++++++++++++++++++++++++ Source/Core/Core/Core.h | 2 ++ Source/Core/Core/Movie.cpp | 24 ------------------------ Source/Core/Core/Movie.h | 1 - Source/Core/DolphinQt2/MainWindow.cpp | 2 +- Source/Core/DolphinWX/FrameTools.cpp | 2 +- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 422de26688..6cc3356c3f 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -103,6 +103,7 @@ static StoppedCallbackFunc s_on_stopped_callback; static std::thread s_cpu_thread; static bool s_request_refresh_info = false; static bool s_is_throttler_temp_disabled = false; +static bool s_frame_step = false; struct HostJob { @@ -473,6 +474,7 @@ static void EmuThread(std::unique_ptr boot) // For a time this acts as the CPU thread... DeclareAsCPUThread(); + s_frame_step = false; Movie::Init(*boot); Common::ScopeGuard movie_guard{Movie::Shutdown}; @@ -859,6 +861,12 @@ void Callback_VideoCopiedToXFB(bool video_update) s_drawn_frame++; Movie::FrameUpdate(); + + if (s_frame_step) + { + s_frame_step = false; + CPU::Break(); + } } void UpdateTitle() @@ -1024,4 +1032,21 @@ void HostDispatchJobs() } } +// NOTE: Host Thread +void DoFrameStep() +{ + if (GetState() == State::Paused) + { + // if already paused, frame advance for 1 frame + s_frame_step = true; + RequestRefreshInfo(); + SetState(State::Running); + } + else if (!s_frame_step) + { + // if not paused yet, pause immediately instead + SetState(State::Paused); + } +} + } // Core diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h index e604843a2c..7787023371 100644 --- a/Source/Core/Core/Core.h +++ b/Source/Core/Core/Core.h @@ -105,4 +105,6 @@ void QueueHostJob(std::function job, bool run_during_stop = false); // WM_USER_JOB_DISPATCH will be sent when something is added to the queue. void HostDispatchJobs(); +void DoFrameStep(); + } // namespace diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index b1d1e094a2..b9c6f9867d 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -63,7 +63,6 @@ namespace Movie { -static bool s_bFrameStep = false; static bool s_bReadOnly = true; static u32 s_rerecords = 0; static PlayMode s_playMode = MODE_NONE; @@ -192,11 +191,6 @@ void FrameUpdate() s_totalFrames = s_currentFrame; s_totalLagCount = s_currentLagCount; } - if (s_bFrameStep) - { - s_bFrameStep = false; - CPU::Break(); - } s_bPolled = false; } @@ -215,7 +209,6 @@ void Init(const BootParameters& boot) s_current_file_name.clear(); s_bPolled = false; - s_bFrameStep = false; s_bSaveConfig = false; if (IsPlayingInput()) { @@ -274,23 +267,6 @@ void SetPolledDevice() s_bPolled = true; } -// NOTE: Host Thread -void DoFrameStep() -{ - if (Core::GetState() == Core::State::Paused) - { - // if already paused, frame advance for 1 frame - s_bFrameStep = true; - Core::RequestRefreshInfo(); - Core::SetState(Core::State::Running); - } - else if (!s_bFrameStep) - { - // if not paused yet, pause immediately instead - Core::SetState(Core::State::Paused); - } -} - // NOTE: Host Thread void SetReadOnly(bool bEnabled) { diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index 08107f92c6..343790ccb3 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -148,7 +148,6 @@ bool IsUsingBongo(int controller); void ChangePads(bool instantly = false); void ChangeWiiPads(bool instantly = false); -void DoFrameStep(); void SetReadOnly(bool bEnabled); bool BeginRecordingInput(int controllers); diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 0331104e01..f4dee4f7e0 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -450,7 +450,7 @@ void MainWindow::Reset() void MainWindow::FrameAdvance() { - Movie::DoFrameStep(); + Core::DoFrameStep(); EmulationPaused(); } diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index d505ce14d3..89726223dc 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -446,7 +446,7 @@ void CFrame::OnFrameStep(wxCommandEvent& event) { bool wasPaused = Core::GetState() == Core::State::Paused; - Movie::DoFrameStep(); + Core::DoFrameStep(); bool isPaused = Core::GetState() == Core::State::Paused; if (isPaused && !wasPaused) // don't update on unpause, otherwise the status would be wrong when