From a88330fe41f98c0b5ae7c5dd254ec870a120a017 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Sat, 28 Dec 2024 12:37:33 -0700 Subject: [PATCH] don't unpause emulator when resetting --- src/Application.cpp | 6 ++++++ src/Fsm.cpp | 36 ++++++++++++++---------------------- src/Fsm.fsm | 8 ++++++-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 75490992..73725a63 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -2359,6 +2359,9 @@ void Application::handle(const SDL_SysWMEvent* syswm) case IDM_RESET_GAME: _fsm.resetGame(); + + if (isPaused()) + _fsm.step(); break; case IDM_SAVE_STATE_1: @@ -2685,6 +2688,9 @@ void Application::handle(const KeyBinds::Action action, unsigned extra) case KeyBinds::Action::kReset: _fsm.resetGame(); + + if (isPaused()) + _fsm.step(); break; case KeyBinds::Action::kScreenshot: diff --git a/src/Fsm.cpp b/src/Fsm.cpp index 11db8aed..2ff6e089 100644 --- a/src/Fsm.cpp +++ b/src/Fsm.cpp @@ -682,21 +682,17 @@ bool Fsm::resetGame() { return false; } - bool __ok = resumeGame() && - resetGame(); - if (__ok) { - after(__state); - after(); + ctx.resetGame(); + + __state = State::GamePaused; + after(__state); + after(); - } - else { #ifdef DEBUG_FSM - ctx.printf("FSM %s:%u Failed to switch to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); + ctx.printf("FSM %s:%u Switched to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); #endif - } - - return __ok; + return true; } break; @@ -717,21 +713,17 @@ bool Fsm::resetGame() { return false; } - bool __ok = resumeGame() && - resetGame(); - if (__ok) { - after(__state); - after(); + ctx.resetGame(); + + __state = State::GamePausedNoOvl; + after(__state); + after(); - } - else { #ifdef DEBUG_FSM - ctx.printf("FSM %s:%u Failed to switch to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); + ctx.printf("FSM %s:%u Switched to %s", __FUNCTION__, __LINE__, stateName(State::GameRunning)); #endif - } - - return __ok; + return true; } break; diff --git a/src/Fsm.fsm b/src/Fsm.fsm index 0b606e19..2e265ba5 100644 --- a/src/Fsm.fsm +++ b/src/Fsm.fsm @@ -129,7 +129,9 @@ fsm Fsm { GamePaused { resumeGame() => GameRunning; - resetGame() => resumeGame() => resetGame(); + resetGame() => GamePaused { + ctx.resetGame(); + } step() => FrameStep { if (ctx.hardcore()) { @@ -155,7 +157,9 @@ fsm Fsm { resumeGame() => GameRunning; - resetGame() => resumeGame() => resetGame(); + resetGame() => GamePausedNoOvl { + ctx.resetGame(); + } step() => FrameStep { if (ctx.hardcore()) {