Skip to content

Commit f573b0c

Browse files
authored
Merge pull request #20215 from hrydgard/fix-reset-regression
Fix resetting through the keyboard shortcut
2 parents 0f6886b + 6961a9f commit f573b0c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

UI/EmuScreen.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ bool EmuScreen::bootAllowStorage(const Path &filename) {
244244
return false;
245245
}
246246

247-
void EmuScreen::bootGame(const Path &filename) {
247+
void EmuScreen::ProcessGameBoot(const Path &filename) {
248248
if (Achievements::IsBlockingExecution()) {
249249
// Keep waiting.
250250
return;
@@ -334,7 +334,7 @@ void EmuScreen::bootGame(const Path &filename) {
334334
// PSP_InitStart can't really fail anymore, unless it's called at the wrong time. It just starts the loader thread.
335335
if (!PSP_InitStart(coreParam)) {
336336
bootPending_ = false;
337-
ERROR_LOG(Log::Boot, "InitStart bootGame error: %s", errorMessage_.c_str());
337+
ERROR_LOG(Log::Boot, "InitStart ProcessGameBoot error: %s", errorMessage_.c_str());
338338
return;
339339
}
340340

@@ -520,19 +520,31 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
520520
screenManager()->push(new GamePauseScreen(gamePath_));
521521
} else if (message == UIMessage::REQUEST_GAME_STOP) {
522522
// We will push MainScreen in update().
523+
if (bootPending_) {
524+
ERROR_LOG(Log::Loader, "Can't stop during a pending boot");
525+
return;
526+
}
523527
PSP_Shutdown(true);
524528
bootPending_ = false;
525529
System_Notify(SystemNotification::DISASSEMBLY);
526530
} else if (message == UIMessage::REQUEST_GAME_RESET) {
531+
if (bootPending_) {
532+
ERROR_LOG(Log::Loader, "Can't reset during a pending boot");
533+
return;
534+
}
527535
PSP_Shutdown(true);
528536
bootPending_ = true;
529-
System_Notify(SystemNotification::DISASSEMBLY);
537+
_dbg_assert_(coreState == CORE_POWERDOWN);
530538
if (!PSP_InitStart(PSP_CoreParameter())) {
531539
ERROR_LOG(Log::Loader, "Error resetting");
532540
screenManager()->switchScreen(new MainScreen());
533541
return;
534542
}
535543
} else if (message == UIMessage::REQUEST_GAME_BOOT) {
544+
if (bootPending_) {
545+
ERROR_LOG(Log::Loader, "Can't boot a new game during a pending boot");
546+
return;
547+
}
536548
// TODO: Ignore or not if it's the same game that's already running?
537549
if (gamePath_ == Path(value)) {
538550
WARN_LOG(Log::Loader, "Game already running, ignoring");
@@ -764,7 +776,9 @@ void EmuScreen::onVKey(VirtKey virtualKeyCode, bool down) {
764776
break;
765777

766778
case VIRTKEY_RESET_EMULATION:
767-
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
779+
if (down) {
780+
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
781+
}
768782
break;
769783

770784
#ifndef MOBILE_DEVICE
@@ -1466,7 +1480,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
14661480
if (bootPending_) {
14671481
// Keep trying the boot until bootPending_ is lifted.
14681482
// It may be delayed due to RetroAchievements or any other cause.
1469-
bootGame(gamePath_);
1483+
ProcessGameBoot(gamePath_);
14701484
}
14711485

14721486
ScreenRenderFlags flags = ScreenRenderFlags::NONE;

UI/EmuScreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class EmuScreen : public UIScreen {
7878
UI::EventReturn OnChat(UI::EventParams &params);
7979
UI::EventReturn OnResume(UI::EventParams &params);
8080

81-
void bootGame(const Path &filename);
81+
void ProcessGameBoot(const Path &filename);
8282
bool bootAllowStorage(const Path &filename);
8383
void bootComplete();
8484
bool hasVisibleUI();

0 commit comments

Comments
 (0)