OSDN Git Service

[VM][FM7][FM8] Add "Connect 320KB FDD".You should check this ato first when using...
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 30 Apr 2016 11:15:11 +0000 (20:15 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 30 Apr 2016 11:15:11 +0000 (20:15 +0900)
source/src/qt/machines/fm7/MainWindow.cpp
source/src/qt/machines/fm7/menuclasses.h
source/src/vm/fm7/floppy.cpp
source/src/vm/fm7/fm7.cpp
source/src/vm/fm7/fm7.h
source/src/vm/fm7/fm7_common.h

index 2ecdf5c..28e71f1 100644 (file)
@@ -39,6 +39,51 @@ void Object_Menu_Control_7::do_set_kanji_rom(bool flag)
 }
 #endif
 
+#if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+void Object_Menu_Control_7::do_set_320kFloppy(bool flag)
+{
+       if(flag) {
+               config.dipswitch = config.dipswitch | FM7_DIPSW_CONNECT_320KFDC;
+       } else {
+               config.dipswitch = config.dipswitch & ~FM7_DIPSW_CONNECT_320KFDC;
+       }
+}
+#endif
+
+#if defined(_FM8) || defined(_FM7) || defined(_FMNEW7) || defined(_FM77_VARIANTS)
+void Object_Menu_Control_7::do_set_1MFloppy(bool flag)
+{
+       if(flag) {
+               config.dipswitch = config.dipswitch | FM7_DIPSW_CONNECT_1MFDC;
+       } else {
+               config.dipswitch = config.dipswitch & ~FM7_DIPSW_CONNECT_1MFDC;
+       }
+}
+#endif
+
+
+void Object_Menu_Control_7::do_set_autokey_5_8(void)
+{
+       int val = getValue1();
+       switch(val) {
+       case 0: // Not Auto Key:
+               config.dipswitch = config.dipswitch & ~(FM7_DIPSW_SELECT_5_OR_8KEY | FM7_DIPSW_AUTO_5_OR_8KEY);
+               break;
+       case 1: // Auto 5
+               config.dipswitch = config.dipswitch | (FM7_DIPSW_SELECT_5_OR_8KEY | FM7_DIPSW_AUTO_5_OR_8KEY);
+               break;
+       case 2: // Auto 8
+               config.dipswitch = (config.dipswitch | FM7_DIPSW_AUTO_5_OR_8KEY) & ~FM7_DIPSW_AUTO_5_OR_8KEY;
+               break;
+       default:// Not Auto Key:
+               config.dipswitch = config.dipswitch & ~(FM7_DIPSW_SELECT_5_OR_8KEY | FM7_DIPSW_AUTO_5_OR_8KEY);
+               break;
+       }
+}
+
+
+
+
 #if defined(_FM8)
 void Object_Menu_Control_7::do_set_protect_ram(bool flag)
 {
@@ -229,8 +274,17 @@ void META_MainWindow::retranslateUi(void)
 # if defined(_FM77AV_VARIANTS) || defined(_FM77_VARIANTS)
        actionExtRam->setText(QString::fromUtf8("Use Extra RAM (Need reboot)"));
 # endif
-#endif                                                   
-       
+#endif                           
+#if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+       action_320kFloppy->setText(QApplication::translate("MainWindow", "Connect 320KB FDD(Need Restart)", 0));
+#endif 
+#if defined(_FM8) || defined(_FM7) || defined(_FMNEW7) || defined(_FM77_VARIANTS)
+       action_1MFloppy->setText(QApplication::translate("MainWindow", "Connect 1MB FDD(Need Restart)", 0));
+#endif
+       menuAuto5_8Key->setTitle(QApplication::translate("MainWindow", "Auto Stop Ten Key (HACK)", 0));
+       action_Neither_5_or_8key->setText(QApplication::translate("MainWindow", "None used.", 0));
+       action_Auto_5key->setText(QApplication::translate("MainWindow", "Use 5", 0));
+       action_Auto_8key->setText(QApplication::translate("MainWindow", "Use 8", 0));
        // Set Labels
   
 } // retranslateUi
@@ -324,6 +378,70 @@ void META_MainWindow::setupUI_Emu(void)
        connect(actionExtRam, SIGNAL(toggled(bool)),
                        this, SLOT(do_set_extram(bool)));
 #endif
+# if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+       action_320kFloppy = new Action_Control_7(this); 
+       menuMachine->addAction(action_320kFloppy);
+       action_320kFloppy->setCheckable(true);
+       action_320kFloppy->setVisible(true);
+       if((config.dipswitch & FM7_DIPSW_CONNECT_320KFDC) != 0) action_320kFloppy->setChecked(true);
+       connect(action_320kFloppy, SIGNAL(toggled(bool)),
+                       action_320kFloppy->fm7_binds, SLOT(do_set_320kFloppy(bool)));
+# endif        
+# if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+       action_1MFloppy = new Action_Control_7(this);   
+       menuMachine->addAction(action_1MFloppy);
+       action_1MFloppy->setCheckable(true);
+       action_1MFloppy->setVisible(true);
+       if((config.dipswitch & FM7_DIPSW_CONNECT_1MFDC) != 0) action_1MFloppy->setChecked(true);
+       connect(action_1MFloppy, SIGNAL(toggled(bool)),
+                       action_1MFloppy->fm7_binds, SLOT(do_set_1MFloppy(bool)));
+#endif
+       uint32_t tmpv = config.dipswitch & (FM7_DIPSW_SELECT_5_OR_8KEY | FM7_DIPSW_AUTO_5_OR_8KEY);
+       
+       menuAuto5_8Key = new QMenu(menuMachine);
+       menuAuto5_8Key->setObjectName(QString::fromUtf8("menuControl_Auto5_8Key"));
+       menuMachine->addAction(menuAuto5_8Key->menuAction());
+       
+       actionGroup_Auto_5_8key = new QActionGroup(this);
+       actionGroup_Auto_5_8key->setExclusive(true);
+       
+       action_Neither_5_or_8key = new Action_Control_7(this);
+       action_Neither_5_or_8key->setCheckable(true);
+       action_Neither_5_or_8key->setVisible(true);
+       action_Neither_5_or_8key->fm7_binds->setValue1(0);
+       actionGroup_Auto_5_8key->addAction(action_Neither_5_or_8key);
+       menuAuto5_8Key->addAction(action_Neither_5_or_8key);
+       if((tmpv &  FM7_DIPSW_AUTO_5_OR_8KEY) == 0) action_Neither_5_or_8key->setChecked(true);
+       connect(action_Neither_5_or_8key, SIGNAL(triggered()),
+                       action_Neither_5_or_8key->fm7_binds, SLOT(do_set_autokey_5_8()));
+       
+       action_Auto_5key = new Action_Control_7(this);
+       action_Auto_5key->setCheckable(true);
+       action_Auto_5key->setVisible(true);
+       action_Auto_5key->fm7_binds->setValue1(1);
+       actionGroup_Auto_5_8key->addAction(action_Auto_5key);
+       menuAuto5_8Key->addAction(action_Auto_5key);
+       if((tmpv &  FM7_DIPSW_AUTO_5_OR_8KEY) != 0) {
+               if((tmpv &  FM7_DIPSW_SELECT_5_OR_8KEY) != 0){
+                       action_Auto_5key->setChecked(true);
+               }
+       }
+       connect(action_Auto_5key, SIGNAL(triggered()),
+                       action_Auto_5key->fm7_binds, SLOT(do_set_autokey_5_8()));
+
+       action_Auto_8key = new Action_Control_7(this);
+       action_Auto_8key->setCheckable(true);
+       action_Auto_8key->setVisible(true);
+       action_Auto_8key->fm7_binds->setValue1(2);
+       actionGroup_Auto_5_8key->addAction(action_Auto_8key);
+       menuAuto5_8Key->addAction(action_Auto_8key);
+       if((tmpv &  FM7_DIPSW_AUTO_5_OR_8KEY) != 0) {
+               if((tmpv &  FM7_DIPSW_SELECT_5_OR_8KEY) == 0){
+                       action_Auto_8key->setChecked(true);
+               }
+       }
+       connect(action_Auto_8key, SIGNAL(triggered()),
+                       action_Auto_8key->fm7_binds, SLOT(do_set_autokey_5_8()));
 }
 
 
index f1766f2..bfe349d 100644 (file)
@@ -24,12 +24,17 @@ signals:
 # endif
 # if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
    void do_set_kanji_rom(bool flag);
+   void do_set_320kFloppy(bool flag);
+# endif
+# if defined(_FM8) || defined(_FM7) || defined(_FMNEW7) || defined(_FM77_VARIANTS)
+   void do_set_1MFloppy(bool flag);
 # endif   
 # if defined(_FM8)
    void do_set_protect_ram(bool flag);
 # else   
    void do_set_cyclesteal(bool flag);
 # endif
+   void do_set_autokey_5_8(void);
 };
 
 class Action_Control_7 : public Action_Control
@@ -64,7 +69,19 @@ protected:
 # endif  
 # if defined(_FM77AV_VARIANTS)   
   class Action_Control_7 *actionSyncToHsync;
+# endif
+  QActionGroup *actionGroup_Auto_5_8key;
+  QMenu *menuAuto5_8Key;
+  class Action_Control_7 *action_Neither_5_or_8key;
+  class Action_Control_7 *action_Auto_5key;
+  class Action_Control_7 *action_Auto_8key;
+# if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+  class Action_Control_7 *action_320kFloppy;
+# endif  
+# if defined(_FM8) || defined(_FM7) || defined(_FMNEW7) || defined(_FM77_VARIANTS)
+  class Action_Control_7 *action_1MFloppy;
 # endif  
+  
   void setupUI_Emu(void);
   void retranslateUi(void);
   void retranslateVolumeLabels(Ui_SoundDialog *p);
index 0d144e6..47e52d8 100644 (file)
 
 void FM7_MAINIO::reset_fdc(void)
 {
-       fdc_cmdreg = 0;
-       fdc_statreg = fdc->read_io8(0);
-       fdc_trackreg = fdc->read_io8(1);
-       fdc_sectreg = fdc->read_io8(2);
-       fdc_datareg = fdc->read_io8(3);
-       fdc_headreg = 0xfe | fdc->read_signal(SIG_MB8877_SIDEREG);
-       fdc_drvsel = 0x7c | fdc->read_signal(SIG_MB8877_DRIVEREG);
+
+       if(connect_fdc) {
+               fdc_cmdreg = 0;
+               fdc_statreg = fdc->read_io8(0);
+               fdc_trackreg = fdc->read_io8(1);
+               fdc_sectreg = fdc->read_io8(2);
+               fdc_datareg = fdc->read_io8(3);
+               fdc_headreg = 0xfe | fdc->read_signal(SIG_MB8877_SIDEREG);
+               fdc_drvsel = 0x7c | fdc->read_signal(SIG_MB8877_DRIVEREG);
+       }
        //fdc_motor = (fdc->read_signal(SIG_MB8877_MOTOR) != 0);
        fdc_motor = false;
        fdc_cmd_type1 = false;
        
 #if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX) || \
        defined(_FM77AV20) || defined(_FM77AV20EX)
-       fdc_reg_fd1e = 0x80;
-       for(int i = 0; i < 4; i++) {
-               fdc_drive_table[i] = (uint8_t)i;
-               fdc->set_drive_type(i, DRIVE_TYPE_2D);
+       if(connect_fdc) {
+               fdc_reg_fd1e = 0x80;
+               for(int i = 0; i < 4; i++) {
+                       fdc_drive_table[i] = (uint8_t)i;
+                       fdc->set_drive_type(i, DRIVE_TYPE_2D);
+               }
        }
 #else
-       for(int i = 0; i < 4; i++) {
-               fdc->set_drive_type(i, DRIVE_TYPE_2D);
+       if(connect_fdc) {
+               for(int i = 0; i < 4; i++) {
+                       fdc->set_drive_type(i, DRIVE_TYPE_2D);
+               }
        }
 #endif 
        if(event_fdc_motor >= 0) cancel_event(this, event_fdc_motor);
        event_fdc_motor = -1;
        irqstat_fdc = false;
        irqmask_mfd = true;
-       set_fdc_motor(fdc_motor);
+       if(connect_fdc) {
+               set_fdc_motor(fdc_motor);
+       }
 }
 
 /* FDD */
@@ -252,6 +261,7 @@ void FM7_MAINIO::set_fdc_fd1e(uint8_t val)
 #if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX) || \
        defined(_FM77AV20) || defined(_FM77AV20EX)
        uint8_t drive;
+       if(!connect_fdc) return;
        
        fdc_reg_fd1e = val;
        
index f5d09e7..c1ddfc7 100644 (file)
@@ -95,7 +95,33 @@ VM::VM(EMU* parent_emu): emu(parent_emu)
 #endif 
        drec = new DATAREC(this, emu);
        pcm1bit = new PCM1BIT(this, emu);
-       fdc = new MB8877(this, emu);
+
+       connect_320kfdc = connect_1Mfdc = false;
+       fdc = NULL;
+#if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+       if(((config.dipswitch & FM7_DIPSW_CONNECT_320KFDC) != 0) ||
+          ((config.dipswitch & FM7_DIPSW_CONNECT_1MFDC) != 0)) {
+#endif         
+               fdc = new MB8877(this, emu);
+#if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+               if((config.dipswitch & FM7_DIPSW_CONNECT_320KFDC) != 0) {
+                       connect_320kfdc = true;
+               }
+               if((config.dipswitch & FM7_DIPSW_CONNECT_1MFDC) != 0) {
+                       connect_1Mfdc = true;
+               }
+#elif defined(_FM77_VARIANTS)
+               connect_320kfdc = true;
+               if((config.dipswitch & FM7_DIPSW_CONNECT_1MFDC) != 0) {
+                       connect_1Mfdc = true;
+               }
+#else  // AV or later.
+               connect_320kfdc = true;
+               // 1MFDD??
+#endif         
+#if defined(_FM8) || defined(_FM7) || defined(_FMNEW7)
+       }
+#endif 
        joystick  = new JOYSTICK(this, emu);
        printer = new PRNFILE(this, emu);
 #if defined(_FM77AV_VARIANTS)
@@ -290,11 +316,16 @@ void VM::connect_bus(void)
 #endif 
        // Palette, VSYNC, HSYNC, Multi-page, display mode. 
        mainio->set_context_display(display);
-       
-       //FDC
-       fdc->set_context_irq(mainio, FM7_MAINIO_FDC_IRQ, 0x1);
-       fdc->set_context_drq(mainio, FM7_MAINIO_FDC_DRQ, 0x1);
-       mainio->set_context_fdc(fdc);
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
+       if(connect_320kfdc || connect_1Mfdc) {
+#endif         
+               //FDC
+               fdc->set_context_irq(mainio, FM7_MAINIO_FDC_IRQ, 0x1);
+               fdc->set_context_drq(mainio, FM7_MAINIO_FDC_DRQ, 0x1);
+               mainio->set_context_fdc(fdc);
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
+       }
+#endif 
        // SOUND
        mainio->set_context_beep(pcm1bit);
 #if defined(_FM8)      
@@ -344,24 +375,36 @@ void VM::connect_bus(void)
        }
 
        // Disks
-       for(int i = 0; i < 2; i++) {
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
+       if(connect_320kfdc) {
+#endif         
+               for(int i = 0; i < 2; i++) {
 #if defined(_FM77AV20) || defined(_FM77AV20EX) || \
        defined(_FM77AV40SX) || defined(_FM77AV40EX) || defined(_FM77AV40SX)
-               fdc->set_drive_type(i, DRIVE_TYPE_2DD);
+                       fdc->set_drive_type(i, DRIVE_TYPE_2DD);
 #else
-               fdc->set_drive_type(i, DRIVE_TYPE_2D);
+                       fdc->set_drive_type(i, DRIVE_TYPE_2D);
 #endif
-               fdc->set_drive_rpm(i, 360);
-               fdc->set_drive_mfm(i, true);
+                       fdc->set_drive_rpm(i, 360);
+                       fdc->set_drive_mfm(i, true);
+               }
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
        }
+#endif 
+       
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
+       if(connect_1Mfdc) {
+#endif         
 #if defined(_FM77) || defined(_FM77L4)
-       for(int i = 2; i < 4; i++) {
-               fdc->set_drive_type(i, DRIVE_TYPE_2HD);
-               fdc->set_drive_rpm(i, 360);
-               fdc->set_drive_mfm(i, true);
-       }
+               for(int i = 2; i < 4; i++) {
+                       fdc->set_drive_type(i, DRIVE_TYPE_2HD);
+                       fdc->set_drive_rpm(i, 360);
+                       fdc->set_drive_mfm(i, true);
+               }
 #endif
-       
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
+       }
+#endif 
 }  
 
 void VM::update_config()
@@ -462,8 +505,17 @@ void VM::draw_screen()
 
 uint32_t VM::get_access_lamp_status()
 {
-       uint32_t status = fdc->read_signal(0xff);
-       return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0;
+       // WILLFIX : Multiple FDC for 1M FD.
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
+       if(connect_320kfdc || connect_1Mfdc) {
+#endif         
+               uint32_t status = fdc->read_signal(0xff);
+               return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0;
+#if defined(_FM8) || (_FM7) || (_FMNEW7)
+       } else {
+               return 0x00000000;
+       }
+#endif         
 }
 
 void VM::initialize_sound(int rate, int samples)
@@ -559,27 +611,41 @@ void VM::key_up(int code)
 
 void VM::open_floppy_disk(int drv, const _TCHAR* file_path, int bank)
 {
-       fdc->open_disk(drv, file_path, bank);
+       if(fdc != NULL) {
+               fdc->open_disk(drv, file_path, bank);
+       }
 }
 
 void VM::close_floppy_disk(int drv)
 {
-       fdc->close_disk(drv);
+       if(fdc != NULL) {
+               fdc->close_disk(drv);
+       }
 }
 
 bool VM::is_floppy_disk_inserted(int drv)
 {
-       return fdc->is_disk_inserted(drv);
+       if(fdc != NULL) {
+               return fdc->is_disk_inserted(drv);
+       } else {
+               return false;
+       }
 }
 
 void VM::is_floppy_disk_protected(int drv, bool value)
 {
-       fdc->is_disk_protected(drv, value);
+       if(fdc != NULL) {
+               fdc->is_disk_protected(drv, value);
+       }
 }
 
 bool VM::is_floppy_disk_protected(int drv)
 {
-       return fdc->is_disk_protected(drv);
+       if(fdc != NULL) {
+               return fdc->is_disk_protected(drv);
+       } else {
+               return false;
+       }
 }
 
 void VM::play_tape(const _TCHAR* file_path)
@@ -705,10 +771,12 @@ void VM::is_bubble_casette_protected(int drv, bool flag)
 #endif
 
 
-#define STATE_VERSION  3
+#define STATE_VERSION  4
 void VM::save_state(FILEIO* state_fio)
 {
        state_fio->FputUint32_BE(STATE_VERSION);
+       state_fio->FputBool(connect_320kfdc);
+       state_fio->FputBool(connect_1Mfdc);
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->save_state(state_fio);
        }
@@ -721,6 +789,8 @@ bool VM::load_state(FILEIO* state_fio)
        if(version != STATE_VERSION) {
                return false;
        }
+       connect_320kfdc = state_fio->FgetBool();
+       connect_1Mfdc = state_fio->FgetBool();
        for(DEVICE* device = first_device; device; device = device->next_device) {
                if(!device->load_state(state_fio)) {
                        printf("Load Error: DEVID=%d\n", device->this_device_id);
index 769e294..3ce0cc7 100644 (file)
@@ -435,6 +435,8 @@ protected:
 #ifdef CAPABLE_KANJI_CLASS2
        KANJIROM *kanjiclass2;
 #endif
+       bool connect_320kfdc;
+       bool connect_1Mfdc;
 public:
        // ----------------------------------------
        // initialize
index ed6757b..7ceb880 100644 (file)
@@ -55,6 +55,11 @@ enum {
 #define FM7_DIPSW_DICTROM_AV         0x00000008
 #define FM7_DIPSW_FM8_PROTECT_FD0F   0x00000010
 #define FM7_DIPSW_CONNECT_KANJIROM   0x00000020
+#define FM7_DIPSW_CONNECT_320KFDC    0x00000040
+#define FM7_DIPSW_CONNECT_1MFDC      0x00000080
+// '1' is Auto 5 Key, '0' is Auto 8 Key
+#define FM7_DIPSW_SELECT_5_OR_8KEY   0x00000100 
+#define FM7_DIPSW_AUTO_5_OR_8KEY     0x00000200
 #define FM7_DIPSW_FRAMESKIP          0x30000000
 #define FM7_DIPSW_SYNC_TO_HSYNC      0x80000000