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

don't unpause emulator when resetting #432

Merged
merged 1 commit into from
Jan 4, 2025
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
6 changes: 6 additions & 0 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
36 changes: 14 additions & 22 deletions src/Fsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
8 changes: 6 additions & 2 deletions src/Fsm.fsm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ fsm Fsm {
GamePaused {
resumeGame() => GameRunning;

resetGame() => resumeGame() => resetGame();
resetGame() => GamePaused {
ctx.resetGame();
}

step() => FrameStep {
if (ctx.hardcore()) {
Expand All @@ -155,7 +157,9 @@ fsm Fsm {

resumeGame() => GameRunning;

resetGame() => resumeGame() => resetGame();
resetGame() => GamePausedNoOvl {
ctx.resetGame();
}

step() => FrameStep {
if (ctx.hardcore()) {
Expand Down
Loading