Merge pull request #19473 from hrydgard/frame-advance

Try to make Frame Advance a bit more reliable
This commit is contained in:
Henrik Rydgård 2024-09-18 15:31:30 +02:00 committed by GitHub
commit 68804ca539
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 11 deletions

View File

@ -715,16 +715,9 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
break; break;
case VIRTKEY_FRAME_ADVANCE: case VIRTKEY_FRAME_ADVANCE:
if (!Achievements::WarnUserIfHardcoreModeActive(false)) { // Can't do this reliably in an async fashion, so we just set a variable.
if (down) { if (down) {
// If game is running, pause emulation immediately. Otherwise, advance a single frame. doFrameAdvance_.store(true);
if (Core_IsStepping()) {
frameStep_ = true;
Core_EnableStepping(false);
} else if (!frameStep_) {
Core_EnableStepping(true, "ui.frameAdvance", 0);
}
}
} }
break; break;
@ -1426,6 +1419,19 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
Core_UpdateDebugStats((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops); 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(); bool blockedExecution = Achievements::IsBlockingExecution();
uint32_t clearColor = 0; uint32_t clearColor = 0;
if (!blockedExecution) { if (!blockedExecution) {

View File

@ -121,5 +121,7 @@ private:
std::string extraAssertInfoStr_; std::string extraAssertInfoStr_;
std::atomic<bool> doFrameAdvance_{};
ControlMapper controlMapper_; ControlMapper controlMapper_;
}; };

View File

@ -205,7 +205,9 @@ void GameScreen::CreateViews() {
rightColumnItems->SetSpacing(0.0f); rightColumnItems->SetSpacing(0.0f);
rightColumn->Add(rightColumnItems); 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_ = rightColumnItems->Add(new Choice(ga->T("Game Settings")));
btnGameSettings_->OnClick.Handle(this, &GameScreen::OnGameSettings); btnGameSettings_->OnClick.Handle(this, &GameScreen::OnGameSettings);