diff --git a/qt/src/EmuApplication.cpp b/qt/src/EmuApplication.cpp index 046dca84..fb6698cd 100644 --- a/qt/src/EmuApplication.cpp +++ b/qt/src/EmuApplication.cpp @@ -71,7 +71,15 @@ void EmuApplication::startGame() core->screen_output_function = [&](uint16_t *data, int width, int height, int stride_bytes, double frame_rate) { if (window->canvas) - window->canvas->output((uint8_t *)data, width, height, QImage::Format_RGB16, stride_bytes, frame_rate); + { + QMetaObject::invokeMethod(window.get(), "output", Qt::ConnectionType::QueuedConnection, + Q_ARG(uint8_t *, (uint8_t *)data), + Q_ARG(int, width), + Q_ARG(int, height), + Q_ARG(QImage::Format, QImage::Format_RGB16), + Q_ARG(int, stride_bytes), + Q_ARG(double, frame_rate)); + } }; core->updateSettings(config.get()); @@ -350,3 +358,18 @@ void EmuApplication::powerCycle() { core->reset(); } + +void EmuApplication::loadUndoState() +{ + core->loadUndoState(); +} + +std::string EmuApplication::getStateFolder() +{ + return core->getStateFolder(); +} + +bool EmuApplication::isCoreActive() +{ + return core->active; +} \ No newline at end of file diff --git a/qt/src/EmuApplication.hpp b/qt/src/EmuApplication.hpp index fc3da3e2..5f91a0f0 100644 --- a/qt/src/EmuApplication.hpp +++ b/qt/src/EmuApplication.hpp @@ -38,10 +38,13 @@ struct EmuApplication void loadState(std::string filename); void saveState(int slot); void saveState(std::string filename); + std::string getStateFolder(); + void loadUndoState(); void startGame(); void startIdleLoop(); void stopIdleLoop(); void idleLoop(); + bool isCoreActive(); enum Handler { diff --git a/qt/src/EmuMainWindow.cpp b/qt/src/EmuMainWindow.cpp index 05869b14..d155e000 100644 --- a/qt/src/EmuMainWindow.cpp +++ b/qt/src/EmuMainWindow.cpp @@ -165,7 +165,7 @@ void EmuMainWindow::createWidgets() auto load_state_undo_item = load_state_menu->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo Load State")); connect(load_state_undo_item, &QAction::triggered, [&] { - app->core->loadUndoState(); + app->loadUndoState(); }); core_actions.push_back(load_state_undo_item); @@ -332,7 +332,7 @@ void EmuMainWindow::chooseState(bool save) QFileDialog dialog(this, tr("Choose a State File")); - dialog.setDirectory(QString::fromStdString(app->core->getStateFolder())); + dialog.setDirectory(QString::fromStdString(app->getStateFolder())); dialog.setNameFilters({ tr("Save States (*.sst *.oops *.undo *.0?? *.1?? *.2?? *.3?? *.4?? *.5?? *.6?? *.7?? *.8?? *.9*)"), tr("All Files (*)") }); if (!save) @@ -562,5 +562,11 @@ void EmuMainWindow::pauseContinue() bool EmuMainWindow::isActivelyDrawing() { - return (!app->isPaused() && app->core->active); + return (!app->isPaused() && app->isCoreActive()); +} + +void EmuMainWindow::output(uint8_t *buffer, int width, int height, QImage::Format format, int bytes_per_line, double frame_rate) +{ + if (canvas) + canvas->output(buffer, width, height, format, bytes_per_line, frame_rate); } \ No newline at end of file diff --git a/qt/src/EmuMainWindow.hpp b/qt/src/EmuMainWindow.hpp index fc4f405c..e26b41fd 100644 --- a/qt/src/EmuMainWindow.hpp +++ b/qt/src/EmuMainWindow.hpp @@ -9,6 +9,11 @@ class EmuApplication; class EmuMainWindow : public QMainWindow { + Q_OBJECT + + public Q_SLOTS: + void output(uint8_t *buffer, int width, int height, QImage::Format format, int bytes_per_line, double frame_rate); + public: EmuMainWindow(EmuApplication *app); ~EmuMainWindow(); diff --git a/qt/src/resources/snes9x.svg b/qt/src/resources/snes9x.svg new file mode 100644 index 00000000..74368f10 --- /dev/null +++ b/qt/src/resources/snes9x.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + +