OSDN Git Service

[EMU_THREAD][Qt] Move some sequence funtions to EmuThreadClassBase:: .
authorK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 24 Feb 2023 04:36:13 +0000 (13:36 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 24 Feb 2023 04:36:13 +0000 (13:36 +0900)
- Also rename name of slot around romaji kana conversioning.

source/src/qt/common/emu_thread.cpp
source/src/qt/common/emu_thread.h
source/src/qt/common/qt_utils.cpp
source/src/qt/emu_thread/emu_thread_slots.cpp
source/src/qt/emu_thread/emu_thread_tmpl.cpp
source/src/qt/emu_thread/emu_thread_tmpl.h
source/src/qt/emu_thread/inputs.cpp
source/src/qt/emu_thread/sequences.cpp [new file with mode: 0644]
source/src/qt/emu_thread/utils.cpp
source/src/qt/gui/CMakeLists.txt

index 8920176..d0d697f 100644 (file)
@@ -56,65 +56,10 @@ EmuThreadClass::~EmuThreadClass()
 {
 }
 
-
-int EmuThreadClass::get_interval(void)
-{
-       static int64_t accum = 0;
-       accum += (p_emu->get_frame_interval() / 2);
-       int interval = accum >> 10;
-       accum -= interval << 10;
-       return interval;
-}
-
 #include <QStringList>
 #include <QFileInfo>
 
 
-void EmuThreadClass::resetEmu()
-{
-       clear_key_queue();
-       p_emu->reset();
-}
-
-void EmuThreadClass::specialResetEmu(int num)
-{
-       if(p_emu == nullptr) return;
-       std::shared_ptr<USING_FLAGS> p = using_flags;
-       if(p.get() == nullptr) return;
-
-       if(p->is_use_special_reset()) {
-               p_emu->special_reset(num);
-       }
-}
-
-void EmuThreadClass::loadState()
-{
-       if(p_emu == nullptr) return;
-       std::shared_ptr<USING_FLAGS> p = using_flags;
-       if(p.get() == nullptr) return;
-
-       if(!(p->is_use_state())) return;
-
-       if(!lStateFile.isEmpty()) {
-               p_emu->load_state(lStateFile.toLocal8Bit().constData());
-               lStateFile.clear();
-       }
-}
-
-void EmuThreadClass::saveState()
-{
-       if(p_emu == nullptr) return;
-       std::shared_ptr<USING_FLAGS> p = using_flags;
-       if(p.get() == nullptr) return;
-
-       if(!(p->is_use_state())) return;
-
-       if(!sStateFile.isEmpty()) {
-               p_emu->save_state(sStateFile.toLocal8Bit().constData());
-               sStateFile.clear();
-       }
-
-}
 
 void EmuThreadClass::doWork(const QString &params)
 {
index 59825ce..26bf1df 100644 (file)
@@ -46,22 +46,15 @@ QT_BEGIN_NAMESPACE
 class EmuThreadClass : public EmuThreadClassBase {
        Q_OBJECT
 protected:
-       const _TCHAR *get_device_name(void);
-
-       void resetEmu();
-       void specialResetEmu(int num);
-       void loadState();
-       void saveState();
+       const _TCHAR *get_device_name(void) override;
 
 public:
        EmuThreadClass(Ui_MainWindowBase *rootWindow, std::shared_ptr<USING_FLAGS> p, QObject *parent = 0);
        ~EmuThreadClass();
-       void run() { doWork("");}
-       int get_interval(void);
+       void run() override { doWork("");}
 
 public slots:
        void doWork(const QString &param);
-
 };
 
 QT_END_NAMESPACE
index 1830632..894bf9b 100644 (file)
@@ -392,7 +392,7 @@ void Ui_MainWindow::LaunchEmuThread(EmuThreadClassBase *m)
 #ifdef USE_AUTO_KEY
        connect(this, SIGNAL(sig_start_auto_key(QString)), hRunEmu, SLOT(do_start_auto_key(QString)), Qt::QueuedConnection);
        connect(this, SIGNAL(sig_stop_auto_key()), hRunEmu, SLOT(do_stop_auto_key()), Qt::QueuedConnection);
-       connect(this, SIGNAL(sig_set_roma_kana(bool)), hRunEmu, SLOT(set_romakana(bool)), Qt::QueuedConnection);
+       connect(this, SIGNAL(sig_set_roma_kana(bool)), hRunEmu, SLOT(do_set_roma_kana(bool)), Qt::QueuedConnection);
 #endif
 
        csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "EmuThread : Start.");
index 05020fe..ace07e5 100644 (file)
@@ -726,16 +726,6 @@ void EmuThreadClassBase::do_close_debugger(void)
        }
 }
 
-void EmuThreadClassBase::set_romakana(bool flag)
-{
-       if(p_emu == nullptr) return;
-       std::shared_ptr<USING_FLAGS> p = using_flags;
-       if(p.get() == nullptr) return;
-
-       if(p->is_use_auto_key()) {
-               p_emu->set_auto_key_char(flag ? 1 : 0);
-       }
-}
 
 void EmuThreadClassBase::do_notify_power_off()
 {
index 9b304b0..70c7f98 100644 (file)
@@ -28,9 +28,6 @@
 #include "virtualfileslist.h"
 #include "menu_metaclass.h"
 
-//#include "../../romakana.h"
-
-//#include "csp_logger.h"
 #include "menu_flags.h"
 
 EmuThreadClassBase::EmuThreadClassBase(Ui_MainWindowBase *rootWindow, std::shared_ptr<USING_FLAGS> p, QObject *parent) : QThread(parent)
index 3d6c7d6..94315da 100644 (file)
@@ -178,11 +178,13 @@ protected:
        int get_message_count(void);
        void dec_message_count(void);
 
+       int get_interval(void);
+
        virtual const _TCHAR *get_device_name(void);
-       virtual void resetEmu() { }
-       virtual void specialResetEmu(int num) { }
-       virtual void loadState() { }
-       virtual void saveState() { }
+       void resetEmu();
+       void specialResetEmu(int num);
+       void loadState();
+       void saveState();
 
        void enqueue_key_up(key_queue_t s) {
                QMutexLocker n(&keyMutex);
@@ -281,7 +283,6 @@ public:
        bool is_bubble_casette_protected(int drive);
        void set_bubble_casette_protected(int drive, bool flag);
        QString get_b77_file_path(int drive);
-
 public slots:
        void doExit(void);
 
@@ -365,7 +366,7 @@ public slots:
 
        void do_start_auto_key(QString text);
        void do_stop_auto_key(void);
-       void set_romakana(bool flag);
+       void do_set_roma_kana(bool flag);
        void do_close_debugger(void);
 
 
index 8f50cbe..753a5c0 100644 (file)
@@ -14,6 +14,7 @@
 #include <QTextCodec>
 
 #include "config.h"
+#include "emu_template.h"
 #include "emu_thread_tmpl.h"
 #include "mainwidget_base.h"
 #include "common.h"
@@ -266,3 +267,14 @@ void EmuThreadClassBase::do_stop_auto_key(void)
                p_emu->stop_auto_key();
        }
 }
+
+void EmuThreadClassBase::do_set_roma_kana(bool flag)
+{
+       if(p_emu == nullptr) return;
+       std::shared_ptr<USING_FLAGS> p = using_flags;
+       if(p.get() == nullptr) return;
+
+       if(p->is_use_auto_key()) {
+               p_emu->set_auto_key_char(flag ? 1 : 0);
+       }
+}
diff --git a/source/src/qt/emu_thread/sequences.cpp b/source/src/qt/emu_thread/sequences.cpp
new file mode 100644 (file)
index 0000000..f2d738e
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+       Skelton for retropc emulator
+       Author : Takeda.Toshiya
+    Port to Qt : K.Ohta <whatisthis.sowhat _at_ gmail.com>
+       Date   : 2015.11.10
+       History: 2023.02.24 Split from emu_thread_tmpl.cpp
+       Note: This class must be compiled per VM, must not integrate shared units.
+       [ win32 main ] -> [ Qt main ] -> [Emu Thread] -> [Sequences around emulation]
+*/
+
+#include <QWidget>
+
+#include "config.h"
+#include "emu_template.h"
+#include "emu_thread_tmpl.h"
+#include "mainwidget_base.h"
+#include "common.h"
+#include "../../osdcall_types.h"
+
+#include "virtualfileslist.h"
+#include "menu_metaclass.h"
+
+#include "menu_flags.h"
+
+int EmuThreadClassBase::get_interval(void)
+{
+       static int64_t accum = 0;
+       if(p_emu == nullptr) return 0;
+       accum += (p_emu->get_frame_interval() / 2);
+       int interval = accum >> 10;
+       accum -= interval << 10;
+       return interval;
+}
+
+void EmuThreadClassBase::resetEmu()
+{
+       clear_key_queue();
+       if(p_emu == nullptr) return;
+       p_emu->reset();
+}
+
+void EmuThreadClassBase::specialResetEmu(int num)
+{
+       if(p_emu == nullptr) return;
+       std::shared_ptr<USING_FLAGS> p = using_flags;
+       if(p.get() == nullptr) return;
+
+       if(p->is_use_special_reset()) {
+               p_emu->special_reset(num);
+       }
+}
+
+void EmuThreadClassBase::loadState()
+{
+       if(p_emu == nullptr) return;
+       std::shared_ptr<USING_FLAGS> p = using_flags;
+       if(p.get() == nullptr) return;
+
+       if(!(p->is_use_state())) return;
+
+       if(!lStateFile.isEmpty()) {
+               p_emu->load_state(lStateFile.toLocal8Bit().constData());
+               lStateFile.clear();
+       }
+}
+
+void EmuThreadClassBase::saveState()
+{
+       if(p_emu == nullptr) return;
+       std::shared_ptr<USING_FLAGS> p = using_flags;
+       if(p.get() == nullptr) return;
+       if(!(p->is_use_state())) return;
+
+       if(!sStateFile.isEmpty()) {
+               p_emu->save_state(sStateFile.toLocal8Bit().constData());
+               sStateFile.clear();
+       }
+}
index 2c325f4..c506896 100644 (file)
@@ -11,6 +11,7 @@
 #include <QWidget>
 
 #include "config.h"
+#include "emu_template.h"
 #include "emu_thread_tmpl.h"
 #include "mainwidget_base.h"
 #include "common.h"
@@ -50,6 +51,7 @@ const _TCHAR *EmuThreadClassBase::get_device_name(void)
        return (const _TCHAR *)_T("TEST");
 }
 
+
 #if defined(Q_OS_LINUX)
 //#define _GNU_SOURCE
 #include <unistd.h>
index 452239f..9e5ac6b 100644 (file)
@@ -145,6 +145,7 @@ set(s_qt_gui_srcs
          ../emu_thread/emu_thread_tmpl.cpp
          ../emu_thread/utils.cpp
          ../emu_thread/inputs.cpp
+         ../emu_thread/sequences.cpp
          ../emu_thread/emu_thread_slots.cpp
 )
 add_definitions(-D__GUI_LIBRARY_NAME=\"libCSPgui.${THIS_LIB_VERSION}\")