OSDN Git Service

[VM][FM7] Add cyclesteal features.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 12 Mar 2015 14:17:38 +0000 (23:17 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 12 Mar 2015 14:17:38 +0000 (23:17 +0900)
[VM][FM7] Fix correct clock changing.

source/src/qt/fm7/MainWindow.cpp
source/src/qt/fm7/menuclasses.h
source/src/vm/fm7/display.cpp
source/src/vm/fm7/fm7.cpp
source/src/vm/fm7/fm7.h
source/src/vm/fm7/fm7_common.h
source/src/vm/fm7/fm7_display.h

index 64bf4cb..77c79f8 100644 (file)
@@ -29,7 +29,22 @@ void Object_Menu_Control_7::do_set_sound_device(void)
    emit sig_sound_device(this->getValue1());
 }
 
+void Object_Menu_Control_7::do_set_cyclesteal(bool flag)
+{
+   if(flag) {
+       config.dipswitch = config.dipswitch | 0x0001;
+   } else {
+       config.dipswitch = config.dipswitch & ~0x0001;
+   }
+   if(emu) {
+      emu->LockVM();
+      emu->update_config();
+      emu->UnlockVM();
+   }
+
+}
 
+   
 Action_Control_7::Action_Control_7(QObject *parent) : Action_Control(parent)
 {
    fm7_binds = new Object_Menu_Control_7(parent);
@@ -89,6 +104,7 @@ void META_MainWindow::retranslateUi(void)
   actionBootMode[1]->setText(QString::fromUtf8("DOS"));        
   actionBootMode[2]->setText(QString::fromUtf8("MMR"));
 
+   actionCycleSteal->setText(QString::fromUtf8("Cycle Steal"));
    menuSoundDevice->setTitle(QApplication::translate("MainWindow", "Sound Boards", 0, QApplication::UnicodeUTF8));
 #if defined(_FM77AV_VARIANTS)
    actionSoundDevice[0]->setVisible(false);
@@ -157,6 +173,14 @@ void META_MainWindow::setupUI_Emu(void)
                 this, SLOT(do_set_sound_device(int)));
       }
    }
+   
+       actionCycleSteal = new Action_Control_7(this);
+       menuMachine->addAction(actionCycleSteal);
+       actionCycleSteal->setCheckable(true);
+       actionCycleSteal->setVisible(true);
+       if((config.dipswitch & 0x01) == 0x01) actionCycleSteal->setChecked(true);
+       connect(actionCycleSteal, SIGNAL(toggled(bool)),
+                actionCycleSteal->fm7_binds, SLOT(do_set_cyclesteal(bool)));
 
 }
 
index 8f72d3a..c363522 100644 (file)
@@ -17,6 +17,7 @@ signals:
    int sig_sound_device(int);
  public slots:
    void do_set_sound_device(void);
+   void do_set_cyclesteal(bool flag);
 };
 
 class Action_Control_7 : public Action_Control
@@ -37,6 +38,7 @@ class META_MainWindow : public Ui_MainWindow {
   QActionGroup   *actionGroup_SoundDevice;
   QMenu *menuSoundDevice;
   class Action_Control_7 *actionSoundDevice[8]; //
+  class Action_Control_7 *actionCycleSteal;
   void setupUI_Emu(void);
   void retranslateUi(void);
  public:
index a480e04..5a3a7bd 100644 (file)
@@ -47,6 +47,11 @@ void DISPLAY::reset(void)
 //     subcpu->reset();
 }
 
+void DISPLAY::update_config(void)
+{
+       set_cyclesteal(config.dipswitch & 0x01); // CYCLE STEAL = bit0.
+}
+
 void DISPLAY::draw_screen(void)
 {
        int y;
@@ -263,7 +268,7 @@ uint8 DISPLAY::attention_irq(void)
 // SUB:D405:W
 void DISPLAY::set_cyclesteal(uint8 val)
 {
-#if !defined(_FM7) && !defined(_FMNEW7) && !defined(_FM8)
+#if !defined(_FM8)
        val &= 0x01;
        if(val != 0) {
                is_cyclesteal = true;
index 1c0487d..26e5cba 100644 (file)
@@ -164,11 +164,18 @@ void VM::connect_bus(void)
        event->set_lines_per_frame(400);
        event->set_context_cpu(dummycpu, 8000000);
 #if defined(_FM8)
-       event->set_context_cpu(maincpu, 1095000);
-       event->set_context_cpu(subcpu,   999000);
+       event->set_context_cpu(maincpu, MAINCLOCK_SLOW);
+       event->set_context_cpu(subcpu,  SUBCLOCK_SLOW);
 #else
-       event->set_context_cpu(maincpu, 1794000);
-       event->set_context_cpu(subcpu,  2000000);
+       if(config.cpu_type == 0) {
+               // 2MHz
+               event->set_context_cpu(maincpu, MAINCLOCK_NORMAL);
+               event->set_context_cpu(subcpu,  SUBCLOCK_NORMAL);
+       } else {
+               // 1.2MHz
+               event->set_context_cpu(maincpu, MAINCLOCK_SLOW);
+               event->set_context_cpu(subcpu,  SUBCLOCK_SLOW);
+       }
 #endif
 #ifdef WITH_Z80
        event->set_context_cpu(z80cpu,  4000000);
@@ -278,6 +285,18 @@ void VM::connect_bus(void)
 
 void VM::update_config()
 {
+#if !defined(_FM8)
+       switch(config.cpu_type){
+               case 0:
+                       event->set_cpu_clock(maincpu, MAINCLOCK_NORMAL);
+                       event->set_cpu_clock(subcpu,  SUBCLOCK_NORMAL);
+                       break;
+               case 1:
+                       event->set_cpu_clock(maincpu, MAINCLOCK_SLOW);
+                       event->set_cpu_clock(subcpu,  SUBCLOCK_SLOW);
+                       break;
+       }
+#endif
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->update_config();
        }
index 41c61a0..d005c88 100644 (file)
@@ -91,8 +91,6 @@
 #define MAX_DRIVE              4
 #define HAS_MC6809              
 #define MB8877_MAX_CHIPS       1
-#define MEMORY_ADDR_MAX                0x10000
-#define MEMORY_BANK_SIZE       0x1000
 //#define IO_ADDR_MAX          0x10000
 
 // device informations for win32
index 3eb2416..ef07471 100644 (file)
@@ -44,6 +44,15 @@ enum {
 #define FM7_BOOTMODE_ROM4  3
 #define FM7_BOOTMODE_RAM   4
 
+#define MAINCLOCK_NORMAL    1794000
+#define MAINCLOCK_MMR       1565000
+#define MAINCYCLES_FAST_MMR 2016000
+#define MAINCLOCK_SLOW      1095000
+
+#define SUBCLOCK_NORMAL     2000000
+#define SUBCLOCK_SLOW        999000
+
+
 #define FM7_SUBMEM_OFFSET_DPALETTE    0x100000
 #define FM7_SUBMEM_OFFSET_APALETTE_B  0x200000
 #define FM7_SUBMEM_OFFSET_APALETTE_R  0x300000
index 005a59f..b22c8c0 100644 (file)
@@ -161,6 +161,7 @@ class DISPLAY: public MEMORY
        void write_data8(uint32 addr, uint32 data);
        void initialize(void);
        void reset(void);
+       void update_config(void);
        
        void draw_screen(void);
        void event_frame(void);