From 0cf003999a922980e961375883e5bdd50d0bd2b9 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Fri, 14 Jun 2024 23:24:04 +0200 Subject: [PATCH] run Reset through EmuThread too --- src/frontend/qt_sdl/EmuThread.cpp | 28 ++++++++++++++++++++++------ src/frontend/qt_sdl/EmuThread.h | 3 ++- src/frontend/qt_sdl/Window.cpp | 14 ++++++-------- src/frontend/qt_sdl/Window.h | 1 + 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp index ad6485fd..49891c52 100644 --- a/src/frontend/qt_sdl/EmuThread.cpp +++ b/src/frontend/qt_sdl/EmuThread.cpp @@ -75,8 +75,7 @@ void EmuThread::attachWindow(MainWindow* window) connect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); connect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool))); - connect(this, SIGNAL(windowEmuReset()), window->actReset, SLOT(trigger())); - connect(this, SIGNAL(windowEmuFrameStep()), window->actFrameStep, SLOT(trigger())); + connect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset())); connect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger())); connect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int))); connect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled())); @@ -91,8 +90,7 @@ void EmuThread::detachWindow(MainWindow* window) disconnect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); disconnect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool))); - disconnect(this, SIGNAL(windowEmuReset()), window->actReset, SLOT(trigger())); - disconnect(this, SIGNAL(windowEmuFrameStep()), window->actFrameStep, SLOT(trigger())); + disconnect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset())); disconnect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger())); disconnect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int))); disconnect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled())); @@ -158,8 +156,8 @@ void EmuThread::run() if (emuInstance->hotkeyPressed(HK_FastForwardToggle)) emit windowLimitFPSChange(); if (emuInstance->hotkeyPressed(HK_Pause)) emuTogglePause(); - if (emuInstance->hotkeyPressed(HK_Reset)) emit windowEmuReset(); - if (emuInstance->hotkeyPressed(HK_FrameStep)) emit windowEmuFrameStep(); + if (emuInstance->hotkeyPressed(HK_Reset)) emuReset(); + if (emuInstance->hotkeyPressed(HK_FrameStep)) emuFrameStep(); if (emuInstance->hotkeyPressed(HK_FullscreenToggle)) emit windowFullscreenToggle(); @@ -541,6 +539,18 @@ void EmuThread::handleMessages() emuStatus = emuStatus_FrameStep; break; + case msg_EmuReset: + emuInstance->reset(); + + emuStatus = emuStatus_Running; + emuPauseStack = emuPauseStackRunning; + emuActive = true; + + emuInstance->audioEnable(); + emit windowEmuReset(); + emuInstance->osdAddMessage(0, "Reset"); + break; + case msg_InitGL: emuInstance->initOpenGL(); useOpenGL = true; @@ -620,6 +630,12 @@ void EmuThread::emuFrameStep() waitAllMessages(); } +void EmuThread::emuReset() +{ + sendMessage(msg_EmuReset); + waitMessage(); +} + bool EmuThread::emuIsRunning() { return emuStatus == emuStatus_Running; diff --git a/src/frontend/qt_sdl/EmuThread.h b/src/frontend/qt_sdl/EmuThread.h index 7d11b2d4..51b18562 100644 --- a/src/frontend/qt_sdl/EmuThread.h +++ b/src/frontend/qt_sdl/EmuThread.h @@ -64,6 +64,7 @@ public: msg_EmuUnpause, msg_EmuStop, msg_EmuFrameStep, + msg_EmuReset, msg_InitGL, msg_DeInitGL, @@ -97,6 +98,7 @@ public: void emuStop(bool external); void emuExit(); void emuFrameStep(); + void emuReset(); bool emuIsRunning(); bool emuIsActive(); @@ -116,7 +118,6 @@ signals: void windowEmuStop(); void windowEmuPause(bool pause); void windowEmuReset(); - void windowEmuFrameStep(); void windowLimitFPSChange(); diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index b9d6f6d9..fc4e0bb6 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -1605,14 +1605,7 @@ void MainWindow::onReset() { if (!emuThread->emuIsActive()) return; - emuThread->emuPause(); - - actUndoStateLoad->setEnabled(false); - - emuInstance->reset(); - - emuInstance->osdAddMessage(0, "Reset"); - emuThread->emuRun(); + emuThread->emuReset(); } void MainWindow::onStop() @@ -2088,6 +2081,11 @@ void MainWindow::onEmuPause(bool pause) actPause->setChecked(pause); } +void MainWindow::onEmuReset() +{ + actUndoStateLoad->setEnabled(false); +} + void MainWindow::onUpdateVideoSettings(bool glchange) { if (glchange) diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 4725c1bb..389599fb 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -209,6 +209,7 @@ private slots: void onEmuStart(); void onEmuStop(); void onEmuPause(bool pause); + void onEmuReset(); void onUpdateVideoSettings(bool glchange);