OSDN Git Service

[VM][DISK][UI][Qt] "Ignore CRC Errors" per drive.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 25 Jun 2015 12:06:59 +0000 (21:06 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 25 Jun 2015 12:06:59 +0000 (21:06 +0900)
source/src/config.cpp
source/src/config.h
source/src/qt/fm7/MainWindow.cpp
source/src/qt/fm7/menuclasses.h
source/src/qt/gui/commonclasses.h
source/src/qt/gui/mainwidget.h
source/src/qt/gui/menu_disk.cpp
source/src/vm/disk.cpp
source/src/vm/mb8877.cpp
source/src/vm/msx/memory.cpp

index 7bd831c..98f8735 100644 (file)
@@ -190,6 +190,7 @@ bool GetPrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool bDefault,
 #endif
 void init_config()
 {
+       int i;
        // initial settings
        memset(&config, 0, sizeof(config_t));
        
@@ -220,8 +221,12 @@ void init_config()
 #if defined(USE_DEVICE_TYPE) && defined(DEVICE_TYPE_DEFAULT)
        config.device_type = DEVICE_TYPE_DEFAULT;
 #endif
-#if defined(USE_FD1) && defined(IGNORE_CRC_DEFAULT)
-       config.ignore_crc = IGNORE_CRC_DEFAULT;
+#if defined(USE_FD1)
+# if defined(IGNORE_CRC_DEFAULT)
+       for(i = 0; i < 8; i++) config.ignore_crc[i] = IGNORE_CRC_DEFAULT;
+# else
+       for(i = 0; i < 8; i++) config.ignore_crc = false;
+# endif        
 #endif
 #if defined(USE_SOUND_DEVICE_TYPE) && defined(SOUND_DEVICE_TYPE_DEFAULT)
        config.sound_device_type = SOUND_DEVICE_TYPE_DEFAULT;
@@ -246,7 +251,7 @@ void init_config()
 
 void load_config()
 {
-   int drv, i;
+       int drv, i;
        // initial settings
        init_config();
        
@@ -294,7 +299,14 @@ void load_config()
        config.drive_type = GetPrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
 #endif
 #ifdef USE_FD1
-       config.ignore_crc = GetPrivateProfileBool(_T("Control"), _T("IgnoreCRC"), config.ignore_crc, config_path);
+       {
+               _TCHAR _tag[128];
+               for(drv = 0; drv < 8; drv++) {
+                       memset(_tag, 0x00, sizeof(_tag));
+                       _stprintf_s(_tag, 64, _T("IgnoreCRC_%d"), drv + 1);
+                       config.ignore_crc[drv] = GetPrivateProfileBool(_T("Control"), _tag, config.ignore_crc[drv], config_path);
+               }
+       }
 #endif
 #ifdef USE_TAPE
        config.tape_sound = GetPrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
@@ -410,8 +422,7 @@ void load_config()
 
 void save_config()
 {
-   int drv, i;
-
+       int drv, i;
        // get config path
 #if defined(_USE_AGAR) || defined(_USE_QT)
        char app_path2[_MAX_PATH], *ptr;
@@ -455,7 +466,15 @@ void save_config()
        WritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
 #endif
 #ifdef USE_FD1
-       WritePrivateProfileBool(_T("Control"), _T("IgnoreCRC"), config.ignore_crc, config_path);
+       {
+               _TCHAR _tag[128];
+               for(drv = 0; drv < 8; drv++) {
+                       memset(_tag, 0x00, sizeof(_tag));
+                       _stprintf_s(_tag, 64, _T("IgnoreCRC_%d"), drv + 1);
+                       WritePrivateProfileBool(_T("Control"), _tag, config.ignore_crc[drv], config_path);
+               }
+       }
+       
 #endif
 #ifdef USE_TAPE
        WritePrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
@@ -571,6 +590,7 @@ void save_config()
 void save_config_state(void *f)
 {
        FILEIO *state_fio = (FILEIO *)f;
+       int drv;
        
        state_fio->FputUint32(STATE_VERSION);
        
@@ -590,7 +610,7 @@ void save_config_state(void *f)
        state_fio->FputInt32(config.drive_type);
 #endif
 #ifdef USE_FD1
-       state_fio->FputBool(config.ignore_crc);
+       for(drv = 0; drv < 8; drv++) state_fio->FputBool(config.ignore_crc[drv]);
 #endif
 #ifdef USE_MONITOR_TYPE
        state_fio->FputInt32(config.monitor_type);
@@ -603,6 +623,7 @@ void save_config_state(void *f)
 bool load_config_state(void *f)
 {
        FILEIO *state_fio = (FILEIO *)f;
+       int drv;
        
        if(state_fio->FgetUint32() != STATE_VERSION) {
                return false;
@@ -623,7 +644,7 @@ bool load_config_state(void *f)
        config.drive_type = state_fio->FgetInt32();
 #endif
 #ifdef USE_FD1
-       config.ignore_crc = state_fio->FgetBool();
+       for(drv = 0; drv < 8; drv++) config.ignore_crc[drv] = state_fio->FgetBool();
 #endif
 #ifdef USE_MONITOR_TYPE
        config.monitor_type = state_fio->FgetInt32();
index efbdce5..2de33d5 100644 (file)
@@ -97,7 +97,7 @@ typedef struct {
        int drive_type;
 #endif
 #ifdef USE_FD1
-       BOOL ignore_crc;
+       bool ignore_crc[8];
 #endif
 #ifdef USE_TAPE
        bool tape_sound;
index 8b92c9f..5bf7239 100644 (file)
@@ -91,15 +91,6 @@ void META_MainWindow::do_set_extram(bool flag)
 
    
 
-void META_MainWindow::do_set_ignore_crc_error(bool flag)
-{
-       if(emu) {
-               config.ignore_crc = flag;
-               emu->LockVM();
-               emu->update_config();
-               emu->UnlockVM();
-       }
-}
 
 
 void META_MainWindow::retranslateUi(void)
@@ -145,7 +136,6 @@ void META_MainWindow::retranslateUi(void)
 #endif
    
        actionCycleSteal->setText(QString::fromUtf8("Cycle Steal"));
-       actionIgnoreCRC->setText(QString::fromUtf8("Ignore CRC errors"));
        menuSoundDevice->setTitle(QApplication::translate("MainWindow", "Sound Boards", 0));
 #if defined(_FM77AV_VARIANTS)
        actionSoundDevice[0]->setVisible(false);
@@ -239,18 +229,6 @@ void META_MainWindow::setupUI_Emu(void)
                this, SLOT(do_set_extram(bool)));
 #endif
 
-        actionIgnoreCRC = new Action_Control_7(this);
-       menuMachine->addAction(actionIgnoreCRC);
-       actionIgnoreCRC->setCheckable(true);
-       actionIgnoreCRC->setVisible(true);
-       if(config.ignore_crc == false) {
-               actionIgnoreCRC->setChecked(false);
-       } else {
-               actionIgnoreCRC->setChecked(true);
-       }
-       connect(actionIgnoreCRC, SIGNAL(toggled(bool)),
-                this, SLOT(do_set_ignore_crc_error(bool)));
-
 }
 
 
index 410899a..5d7d640 100644 (file)
@@ -42,7 +42,6 @@ class META_MainWindow : public Ui_MainWindow {
 # if defined(_FM77AV_VARIANTS) || defined(_FM77_VARIANTS)
   class Action_Control_7 *actionExtRam;
 # endif
-  class Action_Control_7 *actionIgnoreCRC;
   void setupUI_Emu(void);
   void retranslateUi(void);
  public:
@@ -50,7 +49,6 @@ class META_MainWindow : public Ui_MainWindow {
   ~META_MainWindow();
  public slots:
     void do_set_sound_device(int);
-    void do_set_ignore_crc_error(bool);
     void do_set_extram(bool flag);
 };
 
index a590b31..13e0191 100644 (file)
@@ -123,6 +123,7 @@ public slots:
        void on_recent_disk(void);
        void write_protect_fd(void);
        void no_write_protect_fd(void);
+       void do_set_ignore_crc_error(bool flag);
      
        void set_screen_aspect(void);
        void set_screen_size(void);
index 67e3af0..f2ce9aa 100644 (file)
@@ -167,6 +167,7 @@ class Ui_MainWindow : public QMainWindow
        class Action_Control *action_D88_ListImage_FD[8][64];
        class Action_Control *actionInsert_FD[8];
        class Action_Control *actionEject_FD[8];
+       class Action_Control *actionIgnoreCRC[8];
        
        class Action_Control *actionProtection_ON_FD[8];
        class Action_Control *actionProtection_OFF_FD[8];
index e2a890f..aaaa4c6 100644 (file)
@@ -34,6 +34,17 @@ void Object_Menu_Control::no_write_protect_fd(void) {
        write_protect = false;
        emit sig_write_protect_fd(drive, write_protect);
 }
+
+void Object_Menu_Control::do_set_ignore_crc_error(bool flag)
+{
+       if(emu) {
+               config.ignore_crc[drive] = flag;
+               emu->LockVM();
+               emu->update_config();
+               emu->UnlockVM();
+       }
+}
+
 // Common Routine
 #ifdef USE_FD1
 void Ui_MainWindow::open_disk_dialog(int drv)
@@ -91,6 +102,8 @@ void Ui_MainWindow::CreateFloppyPulldownMenu(int drv)
        menuFD[drv]->addAction(actionInsert_FD[drv]);
        menuFD[drv]->addAction(actionEject_FD[drv]);
        menuFD[drv]->addSeparator();
+       menuFD[drv]->addAction(actionIgnoreCRC[drv]);
+       menuFD[drv]->addSeparator();
        menuFD_Recent[drv] = new QMenu(menuFD[drv]);
        menuFD_Recent[drv]->setObjectName(QString::fromUtf8("Recent_FD", -1) + QString::number(drv));
        menuFD[drv]->addAction(menuFD_Recent[drv]->menuAction());
@@ -139,6 +152,24 @@ void Ui_MainWindow::ConfigFloppyMenuSub(int drv)
        actionEject_FD[drv]->binds->setDrive(drv);
        actionEject_FD[drv]->binds->setNumber(0);
   
+       actionEject_FD[drv] = new Action_Control(this);
+       actionEject_FD[drv]->setObjectName(QString::fromUtf8("actionEject_FD") + drive_name);
+       actionEject_FD[drv]->binds->setDrive(drv);
+       actionEject_FD[drv]->binds->setNumber(0);
+       
+        actionIgnoreCRC[drv] = new Action_Control(this);
+       actionIgnoreCRC[drv]->setCheckable(true);
+       actionIgnoreCRC[drv]->setVisible(true);
+       actionIgnoreCRC[drv]->binds->setDrive(drv);
+       actionIgnoreCRC[drv]->binds->setNumber(drv);
+       if(config.ignore_crc[drv] == false) {
+               actionIgnoreCRC[drv]->setChecked(false);
+       } else {
+               actionIgnoreCRC[drv]->setChecked(true);
+       }
+       connect(actionIgnoreCRC[drv], SIGNAL(toggled(bool)),
+               actionIgnoreCRC[drv]->binds, SLOT(do_set_ignore_crc_error(bool)));
+
        actionGroup_Opened_FD[drv] = new QActionGroup(this);
        actionRecent_Opened_FD[drv] = new Action_Control(this);
        actionRecent_Opened_FD[drv]->setObjectName(QString::fromUtf8("actionRecent_Opened_FD") + drive_name);
@@ -232,6 +263,7 @@ void Ui_MainWindow::retranslateFloppyMenu(int drv, int basedrv)
        menuFD[drv]->setTitle(QApplication::translate("MainWindow", drive_name.toUtf8().constData() , 0));
        actionInsert_FD[drv]->setText(QApplication::translate("MainWindow", "Insert", 0));
        actionEject_FD[drv]->setText(QApplication::translate("MainWindow", "Eject", 0));
+       actionIgnoreCRC[drv]->setText(QApplication::translate("MainWindow", "Ignore CRC Errors", 0));
 
        menuFD_Recent[drv]->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0));
        menuFD_D88[drv]->setTitle(QApplication::translate("MainWindow", "Select D88 Image", 0));
index d79dde5..1d2f58e 100644 (file)
@@ -661,7 +661,7 @@ void DISK::set_sector_info(uint8 *t)
        density = t[6];
        deleted = (t[7] != 0);
    
-       if(config.ignore_crc != false) {
+       if(config.ignore_crc[drive_num] != false) {
                crc_error = false;
        } else {
                crc_error = (((t[8] & 0xf0) != 0x00) && ((t[8] & 0xf0) != 0x10));
index 9b5c63c..b632082 100644 (file)
@@ -982,7 +982,7 @@ uint8 MB8877::search_sector(int trk, int side, int sct, bool compare)
                fdc[drvreg].next_trans_position = disk[drvreg]->data_position[i];
                fdc[drvreg].next_sync_position = disk[drvreg]->sync_position[i];
                fdc[drvreg].index = 0;
-               return (disk[drvreg]->deleted ? FDC_ST_RECTYPE : 0) | ((disk[drvreg]->crc_error && !config.ignore_crc) ? FDC_ST_CRCERR : 0);
+               return (disk[drvreg]->deleted ? FDC_ST_RECTYPE : 0) | ((disk[drvreg]->crc_error && !config.ignore_crc[drvreg]) ? FDC_ST_CRCERR : 0);
        }
        
        // sector not found
@@ -1024,7 +1024,7 @@ uint8 MB8877::search_addr()
                fdc[drvreg].next_sync_position = disk[drvreg]->sync_position[first_sector];
                fdc[drvreg].index = 0;
                secreg = disk[drvreg]->id[0];
-               return (disk[drvreg]->crc_error && !config.ignore_crc) ? FDC_ST_CRCERR : 0;
+               return (disk[drvreg]->crc_error && !config.ignore_crc[drvreg]) ? FDC_ST_CRCERR : 0;
        }
        
        // sector not found
index 73d5664..7b28729 100644 (file)
@@ -734,7 +734,7 @@ bool MEMORY::bios_ret_z80(uint16 PC, pair* af, pair* bc, pair* de, pair* hl, pai
                                                AF = 0x0801; // record not found
                                                return true;
                                        }
-                                       if(disk[drv]->crc_error && !config.ignore_crc) {
+                                       if(disk[drv]->crc_error && !config.ignore_crc[drv]) {
                                                AF = 0x0401; // data crc error
                                                return true;
                                        }
@@ -755,7 +755,7 @@ bool MEMORY::bios_ret_z80(uint16 PC, pair* af, pair* bc, pair* de, pair* hl, pai
                                                AF = 0x0801; // record not found
                                                return true;
                                        }
-                                       if(disk[drv]->crc_error && !config.ignore_crc) {
+                                       if(disk[drv]->crc_error && !config.ignore_crc[drv]) {
                                                AF = 0x0401; // data crc error
                                                return true;
                                        }
@@ -796,7 +796,7 @@ bool MEMORY::bios_ret_z80(uint16 PC, pair* af, pair* bc, pair* de, pair* hl, pai
                                AF = 0x0c01; // other error
                                return true;
                        }
-                       if(disk[drv]->crc_error && !config.ignore_crc) {
+                       if(disk[drv]->crc_error && !config.ignore_crc[drv]) {
                                AF = 0x0401; // data crc error
                                return true;
                        }