Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to make Frame Advance a bit more reliable #19473

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,16 +715,9 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
break;

case VIRTKEY_FRAME_ADVANCE:
if (!Achievements::WarnUserIfHardcoreModeActive(false)) {
if (down) {
// If game is running, pause emulation immediately. Otherwise, advance a single frame.
if (Core_IsStepping()) {
frameStep_ = true;
Core_EnableStepping(false);
} else if (!frameStep_) {
Core_EnableStepping(true, "ui.frameAdvance", 0);
}
}
// Can't do this reliably in an async fashion, so we just set a variable.
if (down) {
doFrameAdvance_.store(true);
}
break;

Expand Down Expand Up @@ -1422,6 +1415,19 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {

Core_UpdateDebugStats((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops);

if (doFrameAdvance_.exchange(false)) {
if (!Achievements::WarnUserIfHardcoreModeActive(false)) {
// If game is running, pause emulation immediately. Otherwise, advance a single frame.
if (Core_IsStepping()) {
frameStep_ = true;
Core_EnableStepping(false);
} else if (!frameStep_) {
lastNumFlips = gpuStats.numFlips;
Core_EnableStepping(true, "ui.frameAdvance", 0);
}
}
}

bool blockedExecution = Achievements::IsBlockingExecution();
uint32_t clearColor = 0;
if (!blockedExecution) {
Expand Down
2 changes: 2 additions & 0 deletions UI/EmuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,7 @@ class EmuScreen : public UIScreen {

std::string extraAssertInfoStr_;

std::atomic<bool> doFrameAdvance_{};

ControlMapper controlMapper_;
};
4 changes: 3 additions & 1 deletion UI/GameScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ void GameScreen::CreateViews() {
rightColumnItems->SetSpacing(0.0f);
rightColumn->Add(rightColumnItems);

rightColumnItems->Add(new Choice(ga->T("Play")))->OnClick.Handle(this, &GameScreen::OnPlay);
if (!inGame_) {
rightColumnItems->Add(new Choice(ga->T("Play")))->OnClick.Handle(this, &GameScreen::OnPlay);
}

btnGameSettings_ = rightColumnItems->Add(new Choice(ga->T("Game Settings")));
btnGameSettings_->OnClick.Handle(this, &GameScreen::OnGameSettings);
Expand Down
Loading