OSDN Git Service

[CONFIG][FMTOWNS] Add config.machine_features[32] to use machine configuration (w...
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 27 Jul 2021 18:45:20 +0000 (03:45 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 27 Jul 2021 18:45:20 +0000 (03:45 +0900)
Note: See vm/fmtowns/joystick.cpp, FMTOWNS::JOYSTICK::update_config().

24 files changed:
source/src/CMakeLists.txt
source/src/config.cpp
source/src/config.h
source/src/qt/CMakeLists.txt
source/src/qt/avio/CMakeLists.txt
source/src/qt/common/menu_flags.cpp
source/src/qt/emuutils/CMakeLists.txt
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/commonclasses.h
source/src/qt/gui/mainwidget_base.h
source/src/qt/gui/mainwindow_utils.cpp
source/src/qt/gui/menu_control.cpp
source/src/qt/gui/menu_flags.h
source/src/qt/gui/menu_flags_tmpl.cpp
source/src/qt/gui/menu_main.cpp
source/src/qt/machines/fmtowns/MainWindow.cpp
source/src/qt/machines/fmtowns/menuclasses.h
source/src/vm/common_vm/CMakeLists.txt
source/src/vm/fmgen/CMakeLists.txt
source/src/vm/fmtowns/fmtowns.cpp
source/src/vm/fmtowns/fmtowns.h
source/src/vm/fmtowns/joystick.cpp
source/src/vm/fmtowns/joystick.h
source/src/vm/fmtowns/js_template.h

index 0edcec4..b4b7e50 100644 (file)
@@ -1,7 +1,5 @@
 message("* common/common")
 
-#set(CMAKE_BUILD_SETTING_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -msse -mmmx")
-
 #add_library(common_emu
 #      emu.cpp
 #)
index 784d0cd..8a07138 100644 (file)
@@ -242,7 +242,12 @@ void initialize_config()
                config.numpad_enter_as_fullkey = true;
        #endif
                config.host_keyboard_type = CONFIG_HOST_KEYBOARD_AT_109JP;
-#endif 
+       #endif
+       #if defined(USE_MACHINE_FEATURES)
+               for(int i = 0; i < 32; i++) {
+                       config.machine_features[i] = 0;
+               }
+       #endif
 }
 
 void load_config(const _TCHAR *config_path)
@@ -261,6 +266,16 @@ void load_config(const _TCHAR *config_path)
        #ifdef USE_DIPSWITCH
                config.dipswitch = MyGetPrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
        #endif
+       #ifdef USE_MACHINE_FEATURES
+               for(int ii = 0; ii < USE_MACHINE_FEATURES; ii++) {
+                       if(ii >= 32) break;
+                       config.machine_features[ii] =
+                               MyGetPrivateProfileInt(_T("Control"),
+                                                                          create_string(_T("MachineFeatures%d"), ii),
+                                                                          config.machine_features[ii], config_path);
+                       
+               }
+       #endif
        #ifdef USE_DEVICE_TYPE
                config.device_type = MyGetPrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
        #endif
@@ -658,6 +673,15 @@ void save_config(const _TCHAR *config_path)
        #ifdef USE_DIPSWITCH
                MyWritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
        #endif
+       #ifdef USE_MACHINE_FEATURES
+               for(int ii = 0; ii < USE_MACHINE_FEATURES; ii++) {
+                       if(ii >= 32) break;
+                       MyWritePrivateProfileInt(_T("Control"),
+                                                                          create_string(_T("MachineFeatures%d"), ii),
+                                                                          config.machine_features[ii], config_path);
+                       
+               }
+       #endif
        #ifdef USE_DEVICE_TYPE
                MyWritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
        #endif
index b8fee16..0170624 100644 (file)
@@ -354,7 +354,11 @@ typedef struct {
 
        int virtual_media_position; // -1 = none, 1, 2, 3, 4 = LRUD
 #endif
-       
+       // 20210728 K.O
+       // Belows are machine features config (without DIPSW. I.E. joystick ports
+#if defined(USE_FIXED_CONFIG) || defined(USE_MACHINE_FEATURES)
+       uint32_t machine_features[32];
+#endif
 } config_t;
 
 extern config_t DLL_PREFIX_I config;
index 484beac..b2aad75 100644 (file)
@@ -1,5 +1,5 @@
 message("* qt/osd")
-SET(THIS_LIB_VERSION 3.6.0)
+SET(THIS_LIB_VERSION 3.7.0)
 
 set(s_qt_osd_headers
        osd_base.h
index 224a72f..f22d882 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/avio")
 
-SET(THIS_LIB_VERSION 3.3.0)
+SET(THIS_LIB_VERSION 3.4.0)
 set(s_qt_avio_headers
          movie_saver.h
          movie_loader.h
index 6828ed5..aa93645 100644 (file)
@@ -355,6 +355,9 @@ USING_FLAGS_EXT::USING_FLAGS_EXT(config_t *cfg) : USING_FLAGS(cfg)
 #if defined(USE_DIPSWITCH)
        use_dipswitch = true;
 #endif
+#if defined(USE_MACHINE_FEATURES)      
+       use_machine_features = USE_MACHINE_FEATURES;
+#endif
 #if defined(USE_DRIVE_TYPE)
        use_drive_type = USE_DRIVE_TYPE;
 #endif
index 9a0302c..f43c0fd 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/emuutils")
 
-SET(THIS_LIB_VERSION 3.0.0)
+SET(THIS_LIB_VERSION 3.1.0)
 
 set(s_qt_emuutils_headers
        ../gui/csp_logger.h
index e2cf0cc..c1b5af5 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/gui")
 
-set(THIS_LIB_VERSION 3.6.0)
+set(THIS_LIB_VERSION 3.7.0)
 
 set(s_qt_gui_headers
          qt_dialogs.h
index 00c2eb6..fe5e220 100644 (file)
@@ -123,6 +123,8 @@ public slots:
        void do_stop_saving_movie(void);
        void do_set_monitor_type();
        void do_select_fixed_cpu(void);
+
+       void do_select_machine_feature_single(void);
        
 signals:
        int on_boot_mode(int);   
@@ -143,7 +145,8 @@ signals:
        int sig_printer_device(int);
        int sig_drive_type(int);
        int sig_emu_update_config(void);
-
+       int sig_set_machine_feature(int, uint32_t);
+       
        int set_recent_quick_disk(int, int);
        int sig_write_protect_Qd(int, bool);
        int sig_eject_Qd(int);
@@ -180,7 +183,7 @@ signals:
        int sig_screen_size(int, int);
        int sig_screen_multiply(float);
        int sig_screen_rotate(int);
-       
+
        int sig_monitor_type(int);
        int sig_set_fixed_cpu(int);
        
index 60f5936..724ffbe 100644 (file)
@@ -443,6 +443,7 @@ protected:
        class Action_Control *actionSoundDevice[32]; //
        class Action_Control *actionPrintDevice[16];
        class Action_Control *action_SetRenderPlatform[MAX_RENDER_PLATFORMS];
+
        
        class Action_Control *actionStart_Record_Movie;
        class Action_Control *actionStop_Record_Movie;
@@ -656,8 +657,10 @@ public slots:
 
        void _open_cart(int drv, const QString fname);
        void eject_cmt(int drv);
+       
        void do_change_boot_mode(int mode);
        void do_change_cpu_type(int mode);
+       
        void do_write_protect_cmt(int drv, bool flag);
        int  set_recent_cmt(int drv, int num);
        void set_wave_shaper(int drive, bool f);
@@ -760,7 +763,9 @@ public slots:
        void do_show_ram_size_dialog(void);
        void do_block_task();
        void do_unblock_task();
-       
+
+       void do_select_machine_feature(int devnum, uint32_t value);
+
        void do_start_emu_thread();
        void do_start_draw_thread();
 signals:
index f48d7de..632348f 100644 (file)
@@ -285,6 +285,18 @@ void Ui_MainWindowBase::ConfigJoystickType(void)
        }
 }
 
+// Note: YOU MUST ADD OWN ACTION ENTRIES TO MENU; menuMachineFeatures[foo].
+void Ui_MainWindowBase::ConfigMachineFeatures(void)
+{
+       for(int i = 0; i < using_flags->get_use_machine_features(); i++) {
+               
+               menuMachineFeatures[i] = new QMenu(menuMachine);
+               menuMachineFeatures[i]->setObjectName(QString::fromUtf8("menuMachineFeatures"));
+               menuMachine->addAction(menuMachineFeatures[i]->menuAction());
+               menuMachineFeatures[i]->setToolTipsVisible(true);
+       }
+}
+
 void Ui_MainWindowBase::ConfigKeyboardType(void)
 {
        if(using_flags->get_use_keyboard_type() > 0) {
index 98030ef..3fbc58c 100644 (file)
@@ -19,6 +19,15 @@ void Object_Menu_Control::do_select_fixed_cpu(void)
        emit sig_set_fixed_cpu(getValue1());
 }
 
+// ToDo: Call dialogs.
+void Object_Menu_Control::do_select_machine_feature_single(void)
+{
+       int devnum = getNumber();
+       uint32_t value = (uint32_t)getValue1();
+       emit sig_set_machine_feature(devnum, value);
+       // Not NEED to call sig_emu_update_config()
+}
+
 void Object_Menu_Control::do_set_monitor_type()
 {
        emit sig_monitor_type(getValue1());
index 1ee83ab..b07a831 100644 (file)
@@ -67,7 +67,8 @@ protected:
        int use_device_type;
        int use_mouse_type;
        bool use_dipswitch;
-
+       int use_machine_features;
+       
        bool use_ram_size;
        int max_ram_size;
        int min_ram_size;
@@ -252,6 +253,8 @@ public:
        int get_use_device_type() { return use_device_type; }
        int get_use_mouse_type() { return use_mouse_type; }
        bool is_use_dipswitch() { return use_dipswitch; }
+       int get_use_machine_features() { return use_machine_features; }
+
 
        int get_use_drive_type() { return use_drive_type; }
 
index fe6902f..ddd44c6 100644 (file)
@@ -29,7 +29,7 @@ USING_FLAGS::USING_FLAGS(config_t *cfg)
        use_joystick_type = -1;
        use_keyboard_type = -1;
        use_dipswitch = false;
-
+       use_machine_features = 0;
        use_drive_type = 0;
 
        use_fd = false;
@@ -256,6 +256,7 @@ void USING_FLAGS::set_vm_node_name(int id, const _TCHAR *name)
 {
 }
 
+
 _TCHAR *USING_FLAGS::get_vm_node_name(int id)
 {
        return (_TCHAR *)"NODE";
index 57bc608..a6be8d3 100644 (file)
@@ -173,6 +173,7 @@ void Ui_MainWindowBase::do_set_window_focus_type(bool flag)
        }
 }
 
+
 void Ui_MainWindowBase::do_show_ram_size_dialog(void)
 {
        CSP_MemoryDialog *dlg = new CSP_MemoryDialog(using_flags, NULL);
@@ -342,6 +343,13 @@ void Ui_MainWindowBase::do_select_render_platform(int num)
        }
 }
 
+void Ui_MainWindowBase::do_set_machine_feature(int devnum, uint32_t value)
+{
+       if((devnum < 0) || (devnum >= using_flags->get_use_machine_features())) return;
+       p_config->machine_features[devnum] = value;
+       emit sig_emu_update_config();
+}
+
 void Ui_MainWindowBase::set_dipsw(int num, bool flag)
 {
        if((num < 0) || (num >= 32)) return;
index 24efb4e..d5333d2 100644 (file)
@@ -47,25 +47,34 @@ void META_MainWindow::retranslateUi(void)
        actionSpecial_Reset[10]->setToolTip(QApplication::translate("Machine", "Reset with boot from IC CARD #0", 0));
        actionSpecial_Reset[11]->setText(QApplication::translate("Machine", "Reset with DEBUG", 0));
        actionSpecial_Reset[11]->setToolTip(QApplication::translate("Machine", "Reset with DEBUGGING MODE", 0));
-# if defined(USE_MOUSE_TYPE)
-       menuMouseType->setTitle(QApplication::translate("Machine", "Mouse", 0));
-       menuMouseType->setToolTipsVisible(true);
-       actionMouseType[0]->setText(QApplication::translate("Machine", "none", 0));
-       actionMouseType[0]->setToolTip(QApplication::translate("Machine", "Not connect mouse.", 0));
-       actionMouseType[1]->setText(QApplication::translate("Machine", "PAD port1", 0));
-       actionMouseType[1]->setToolTip(QApplication::translate("Machine", "Connect mouse to PAD port #1.", 0));
-       actionMouseType[2]->setText(QApplication::translate("Machine", "PAD port2", 0));
-       actionMouseType[2]->setToolTip(QApplication::translate("Machine", "Connect mouse to PAD port #2.", 0));
-# endif        
-#if defined(USE_JOYSTICK_TYPE)
-       actionJoystickType[0]->setText(QApplication::translate("Machine", "None", 0));
-       actionJoystickType[0]->setToolTip(QApplication::translate("Machine", "NotConnected.", 0));
-       actionJoystickType[1]->setText(QApplication::translate("Machine", "2 buttons", 0));
-       actionJoystickType[1]->setToolTip(QApplication::translate("Machine", "Connect 2 buttons Towns PAD to PORTs.", 0));
-       actionJoystickType[2]->setText(QApplication::translate("Machine", "6 buttons", 0));
-       actionJoystickType[2]->setToolTip(QApplication::translate("Machine", "Connect 6 buttons Towns PAD to PORTs.", 0));
-       menuJoystickType->setTitle(QApplication::translate("Machine", "Towns PAD", 0));
+
+       menuMAchineFeatures[0]->setTitle(QApplication::translate("Machine", "Joystick Port #1", 0));
+       menuMAchineFeatures[1]->setTitle(QApplication::translate("Machine", "Joystick Port #2", 0));
+#if defined(USE_MACHINE_FEATURES)
+       for(int i = 0; i < 2; i++) {
+               actionJOYPORT_TYPE[i][0]->setText(QApplication::translate("Machine", "none", 0));
+               actionJOYPORT_TYPE[i][1]->setText(QApplication::translate("Machine", "2Buttons PAD", 0));
+               actionJOYPORT_TYPE[i][2]->setText(QApplication::translate("Machine", "6Buttons PAD", 0));
+               actionJOYPORT_TYPE[i][3]->setText(QApplication::translate("Machine", "Towns Mouse", 0));
+               actionJOYPORT_TYPE[i][4]->setText(QApplication::translate("Machine", "Analog Stick", 0));
+               actionJOYPORT_TYPE[i][5]->setText(QApplication::translate("Machine", "Joystick for Libble Rabble", 0));
+               for(int j = 0; j < 4; j++) {
+                       actionJOYPORT_TYPE[i][j]->setEnabled(true);
+               }
+               for(int j = 4; j < 6; j++) {
+                       actionJOYPORT_TYPE[i][j]->setEnabled(false);
+               }
+
+               actionJOYPORT_TYPE[i][0]->setToolTip(QApplication::translate("Machine", "No devices are connected to this port", 0));
+               actionJOYPORT_TYPE[i][1]->setToolTip(QApplication::translate("Machine", "Connect standard Towns PAD, 2Buttons.", 0));
+               actionJOYPORT_TYPE[i][2]->setToolTip(QApplication::translate("Machine", "Connect extended Towns PAD, 6Buttons.", 0));
+               actionJOYPORT_TYPE[i][3]->setToolTip(QApplication::translate("Machine", "Connect MOUSE", 0));
+               actionJOYPORT_TYPE[i][4]->setToolTip(QApplication::translate("Machine", "Connect analog joystick, this still be unimplemented", 0));
+               actionJOYPORT_TYPE[i][5]->setToolTip(QApplication::translate("Machine", "Connect hacked joystick for Libble Rabble, this still be unimplemented.", 0));
+               
+       }
 #endif
+                                                                                  
 #if defined(USE_CART)
        if(menu_Cart[0] != NULL) {
                menu_Cart[0]->setTitle(QApplication::translate("MainWindow", "IC1", 0));
@@ -88,6 +97,45 @@ void META_MainWindow::retranslateUi(void)
 
 void META_MainWindow::setupUI_Emu(void)
 {
+#if defined(USE_MACHINE_FEATURES)
+       // menuMachineFeatures[0] : Joystick Port #1
+       // menuMachineFeatures[1] : Joystick Port #2
+       // menuMachineFeatures[2] : Reserved
+       // menuMachineFeatures[3] : Reserved
+       // menuMachineFeatures[4] : Reserved
+       // menuMachineFeatures[5] : Reserved
+       for(int i = 0; i < 2; i++) {
+               actionGroup_JOYPortType[i] = new QActionGroup(this);
+               actionGroup_JOYPortType[i]->setExclusive(true);
+               actionGroup_JOYPortType[i]->setObjectName(QString("actionGroupJOYPort%1").arg(i + 1));
+               menuMachineFeatures[i]->addAction(actionGroup_JOYPortType[i]);
+               for(int j = 0; j < 8; j++) {
+                       actionJOYPORT_TYPE[i][j] = new Action_Control(this, using_flags);
+                       actionJOYPORT_TYPE[i][j]->setCheckable(true);
+                       actionJOYPORT_TYPE[i][j]->setVisible(false);
+                       if(p_config->machine_features[i] == (uint32_t)j) {
+                               actionJOYPORT_TYPE[i][j]->setChecked(true);
+                       } else {
+                               actionJOYPORT_TYPE[i][j]->setChecked(false);
+                       }
+                       actionJOYPORT_TYPE[i][j]->binds->setNumber(i);
+                       actionJOYPORT_TYPE[i][j]->binds->setValue1(j);
+                       actionGroup_JOYPortType[i]->addAction(actionJOYPORT_TYPE[i][j]);
+                       connect(actionJOYPORT_TYPE[i][j], SIGNAL(triggered()),
+                                       actionJOYPORT_TYPE[i][j]->binds, SLOT(do_select_machine_feature_single()));
+                       connect(actionJOYPORT_TYPE[i][j]->binds,
+                                       SIGNAL(sig_set_machine_feature(int, uint32_t)),
+                                       this, SLOT(do_set_machine_feature(int, uint32_t)));
+               }
+               for(int j = 0; j < 6; j++) {
+                       actionJOYPORT_TYPE[i][j]->setVisible(true);
+               }
+       }
+       for(int i = 2; i < 6; i++) {
+               menuMachineFeatures[i]->setVisible(false);
+               menuMachineFeatures[i]->setEnabled(false);
+       }               
+#endif
 }
 
 
index ee35813..5a53ba5 100644 (file)
@@ -14,11 +14,16 @@ class CSP_Logger;
 class META_MainWindow : public Ui_MainWindow {
        Q_OBJECT
 protected:
+       QActionGroup *actionGroup_JOYPortType[2];
+       Action_Control *actionJOYPORT_TYPE[2][8];
+       
        void setupUI_Emu(void);
        void retranslateUi(void);
 public:
        META_MainWindow(USING_FLAGS *p, CSP_Logger *logger, QWidget *parent = 0);
        ~META_MainWindow();
+
+public slots:
 };
 
 QT_END_NAMESPACE
index 26653e5..c29d269 100644 (file)
@@ -1,6 +1,6 @@
 message("* vm/common_vm")
 
-SET(THIS_LIB_VERSION 3.8.0)
+SET(THIS_LIB_VERSION 3.9.0)
 
 #include(cotire)
 set(s_vm_common_vm_srcs
index f1eff57..9d0173b 100644 (file)
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 2.6)
 
 message("* vm/fmgen")
-SET(THIS_LIB_VERSION 1.11.2)
+SET(THIS_LIB_VERSION 1.12.0)
 add_definitions(-D__LIBFMGEN_VERSION=\"libCSPfmgen.${THIS_LIB_VERSION}\")
 
 SET(s_vm_fmgen_srcs
index f0ecd97..c813676 100644 (file)
@@ -426,8 +426,15 @@ VM::VM(EMU_TEMPLATE* parent_emu) : VM_TEMPLATE(parent_emu)
        timer->set_context_halt_line(cpu, SIG_CPU_HALTREQ, 0xffffffff);
 
        for(int i = 0; i < 2; i++) {
+               // type =
+               // 0: Towns PAD 2buttons
+               // 1: Towns PAD 6buttons
+               // 2: Towns MOUSE
+               // 3: Analog Pad (reserved)
+               // 4: Libble Rabble stick (reserved)
                joystick->set_context_joystick(i, joypad_2btn[i]);
                joystick->set_context_joystick(i, joypad_6btn[i]);
+               
        }
        // ToDo: Selective by config.
        for(int i = 0; i < 2; i++) {
index 11b9322..8b81ea7 100644 (file)
 //#define _IO_DEBUG_LOG
 
 // device informations for win32
-#define USE_CPU_TYPE           2
-#define USE_FLOPPY_DISK     4 // ??
-#define USE_CART                       2
-#define USE_SPECIAL_RESET      12 /* 'CD' 'F0' - 'F3' 'H0' - 'H4' 'ICM' 'DEBUG' */
-#define USE_FLOPPY_TYPE_BIT 0x0003 /* 5.0, 5.0, 3.5, 3.5 */
-
+#define USE_CPU_TYPE                   2
+#define USE_FLOPPY_DISK                        4 // ??
+#define USE_CART                               2
+#define USE_SPECIAL_RESET              12 /* 'CD' 'F0' - 'F3' 'H0' - 'H4' 'ICM' 'DEBUG' */
+#define USE_FLOPPY_TYPE_BIT            0x0003 /* 5.0, 5.0, 3.5, 3.5 */
+#define USE_MACHINE_FEATURES   8
 #define NOTIFY_KEY_DOWN
 #define USE_ALT_F10_KEY
 #define USE_AUTO_KEY           5
 #define USE_SOUND_FILES_FDD
 #define USE_JOYSTICK
 #define USE_JOY_BUTTON_CAPTIONS
-#define USE_JOYSTICK_TYPE      3
-#define JOYSTICK_TYPE_DEFAULT  0
 #define USE_MOUSE
-#define USE_MOUSE_TYPE      3
 #define USE_CUSTOM_SCREEN_ZOOM_FACTOR 1.25
 
 #if defined(USE_SOUND_FILES)
index fce6422..093d53e 100644 (file)
@@ -36,7 +36,7 @@ void JOYSTICK::release()
 
 void JOYSTICK::write_data_to_port(uint8_t data)
 {
-       //std::unique_lock<std::mutex> _l = lock_device();
+       std::unique_lock<std::mutex> _l = lock_device();
        
        reg_val = data;
        for(int num = 0; num < 2; num++) {
@@ -139,14 +139,61 @@ uint32_t JOYSTICK::read_signal(int id)
 
 void JOYSTICK::update_config(void)
 {
+       std::unique_lock<std::mutex> _l = lock_device();
+       // BEGIN JOYPORT.
+       // config.machine_features[0,1] : JOYPORT 1,2
+       // value =
+       // 0: None connected
+       // 1: Towns PAD 2buttons
+       // 2: Towns PAD 6buttons
+       // 3: Towns MOUSE
+       // 4: Analog Pad (reserved)
+       // 5: Libble Rabble stick (reserved)
+       bool change_jsport = false;
+       const int js_limit = 2;
+       for(int i = 0; i < 2; i++) {
+               if((port_using[i] + 1) != config.machine_features[i]) {
+                       change_jsport = true ;
+                       if((port_using[i] >= 0) && (port_using[i] < port_count[i])) {
+                               JSDEV_TEMPLATE* p = d_port[i][port_using[i]];
+                               if(p != nullptr) {
+                                       p->set_enable(false); // Disconnect
+                               }
+                       }
+                       if((config.machine_features[i] > 0) && (config.machine_features[i] <= js_limit)) {
+                               JSDEV_TEMPLATE* p = d_port[i][config.machine_features[i] - 1];
+                               if(p != nullptr) {
+                                       p->set_enable(true);
+                                       p->reset_device();
+                                       p->query(_stat); // Query Twice.
+                               }
+                       }
+               }
+       }
+//     if(change_jsport) {
+       write_data_to_port(reg_val);
+//     }
+       for(int i = 0; i < 2; i++) {
+               if((config.machine_features[i] > 0) && (config.machine_features[i] <= js_limit)) {
+                       JSDEV_TEMPLATE* p = d_port[i][config.machine_features[i] - 1];
+                       if(p != nullptr) {
+                               port_using[i] = ((int)config.machine_features[i]) - 1;
+                       } else {
+                               port_using[i] = -1;
+                       }
+               } else {
+                       port_using[i] = -1;
+               }
+       }
+       // END JOYPORT.
 }
 
 
-#define STATE_VERSION 16
+#define STATE_VERSION 17
 
 bool JOYSTICK::process_state(FILEIO *state_fio, bool loading)
 {
-       //std::unique_lock<std::mutex> _l = lock_device();
+       std::unique_lock<std::mutex> _l = lock_device();
        
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
@@ -158,6 +205,8 @@ bool JOYSTICK::process_state(FILEIO *state_fio, bool loading)
        state_fio->StateValue(reg_val);
        state_fio->StateArray(data_reg, sizeof(data_reg), 1);
        state_fio->StateArray(stat_com, sizeof(stat_com), 1);
+       
+       state_fio->StateArray(port_using, sizeof(port_using), 1);
 
        if(loading) {
                for(int i = 0; i < 2; i++) {
index e946a07..421082a 100644 (file)
@@ -67,13 +67,6 @@ private:
        {
                return  std::unique_lock<std::mutex>(_locker, std::adopt_lock);
        }
-       void unlock_device(std::unique_lock<std::mutex> _l)
-       {
-               std::mutex* p = _l.release();
-               if(p != nullptr) {
-                       p->unlock();
-               }
-       }
 public:
        JOYSTICK(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
index fcf1dd4..85ea7f8 100644 (file)
@@ -93,14 +93,6 @@ protected:
                }
        }
 
-       // @note: DEVICE MUST NOT RESET WITHIN reset(), must reset within reset_device().
-       virtual void reset_device()
-       {
-               
-               initialize_status();
-               output_port_signals(false);
-               output_port_com(val_com, false);
-       }
        virtual void initialize_status()
        {
                //std::unique_lock<std::mutex> _l = lock_device();
@@ -422,14 +414,13 @@ public:
                //std::unique_lock<std::mutex> _l = lock_device();
 
                parent_port_num = -1;
+               d_parent_device = NULL;
                pad_num = -1;
                pad_type = 0;
                signal_shift = 0;
                signal_mask = 0xffffffff;
                
-               d_parent_device = NULL;
                is_connected = false;
-               is_negative_logic = false;
                force_output_on_change  = false;
 
                //unlock_device(_l);
@@ -444,6 +435,13 @@ public:
                force_output_on_change = val;
 
        }
+       // @note: DEVICE MUST NOT RESET WITHIN reset(), must reset within reset_device().
+       virtual void reset_device()
+       {
+               initialize_status();
+               output_port_signals(false);
+               output_port_com(val_com, false);
+       }
        virtual void set_enable(bool is_enable)
        {
                //std::unique_lock<std::mutex> _l = lock_device();