OSDN Git Service

[VM][FM7][WIP] Fixing more accurate main-sub arbitation, WIP.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 11 Apr 2015 15:42:52 +0000 (00:42 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 11 Apr 2015 15:42:52 +0000 (00:42 +0900)
source/src/vm/fm7/display.cpp
source/src/vm/fm7/fm7_mainio.cpp
source/src/vm/fm7/fm7_mainio.h

index 8749555..e8b73f8 100644 (file)
@@ -476,6 +476,7 @@ void DISPLAY::halt_subcpu(void)
        bool flag = !(sub_run);
        if(flag) {
                sub_busy = true;
+               mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01);
                subcpu->write_signal(SIG_CPU_BUSREQ, 0x01, 0x01);
        }
 }
@@ -544,7 +545,7 @@ void DISPLAY::reset_crtflag(void)
 //SUB:D402:R
 uint8 DISPLAY::acknowledge_irq(void)
 {
-       //if(cancel_request) this->do_irq(false);
+  //if(cancel_request) this->do_irq(false);
        cancel_request = false;
        do_irq(false);
        return 0xff;
@@ -597,6 +598,7 @@ void DISPLAY::reset_vramaccess(void)
 uint8 DISPLAY::reset_subbusy(void)
 {
        sub_busy = false;
+       mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x00, 0x01);
        return 0xff;
 }
 
@@ -604,6 +606,7 @@ uint8 DISPLAY::reset_subbusy(void)
 void DISPLAY::set_subbusy(void)
 {
        sub_busy = true;
+       mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01);
 }
 
 
@@ -861,8 +864,8 @@ void DISPLAY::set_monitor_bank(uint8 var)
                halt_flag = true;
        }
 #else
-       //this->reset();
-       subcpu->reset();
+       this->reset();
+       //subcpu->reset();
 #endif
 }
 
@@ -1088,11 +1091,16 @@ void DISPLAY::write_signal(int id, uint32 data, uint32 mask)
                case SIG_FM7_SUB_HALT:
                        if(cancel_request && flag) {
                                sub_run = true;
+                               restart_subsystem();
                                //subcpu->write_signal(SIG_CPU_BUSREQ, 0, 1);
                                //printf("SUB: HALT : CANCEL\n");
+                               sub_busy = true;
                                return;
                        }
-                       halt_flag = flag;
+                       //halt_flag = flag;
+                       if(flag) {
+                               sub_busy = true;
+                       }
                        //printf("SUB: HALT : DID STAT=%d\n", flag);   
                        break;
                        case SIG_DISPLAY_HALT:
@@ -1115,6 +1123,7 @@ void DISPLAY::write_signal(int id, uint32 data, uint32 mask)
                                restart_subsystem();
 #endif
                        }
+                       halt_flag = flag;
                        break;
                case SIG_FM7_SUB_CANCEL:
                        if(flag) {
index 7742af4..97aa184 100644 (file)
@@ -43,7 +43,8 @@ void FM7_MAINIO::initialize(void)
        mmr_segment = 0x00;
        for(i = 0x00; i < 0x80; i++) mmr_table[i] = 0;
        //      for(i = 0x00; i < 0x10; i++) mmr_table[i] = 0x30 + i;
-#endif 
+#endif
+       sub_busy = false;
        switch(config.cpu_type){
                case 0:
                        clock_fast = true;
@@ -117,6 +118,7 @@ void FM7_MAINIO::reset(void)
    
        register_event(this, EVENT_TIMERIRQ_ON, 10000.0 / 4.9152, true, &event_timerirq); // TIMER IRQ
        mainmem->reset();
+       sub_busy = (display->read_signal(SIG_DISPLAY_BUSY) == 0) ? false : true;
        //maincpu->reset();
 }
 
@@ -357,7 +359,8 @@ void FM7_MAINIO::set_sub_attention(bool flag)
 uint8 FM7_MAINIO::get_fd04(void)
 {
        //uint8 val = display->read_signal(SIG_DISPLAY_BUSY) | ~0x83;
-       uint8 val = display->read_signal(SIG_DISPLAY_BUSY) | ~0x03;
+       uint8 val = ~0x83;
+       if(sub_busy) val |= 0x80;
        if(!firq_break_key)     val |= 0x02;
        if(!firq_sub_attention) {
                val |= 0x01;
@@ -377,7 +380,9 @@ void FM7_MAINIO::set_fd04(uint8 val)
   // FD05
  uint8 FM7_MAINIO::get_fd05(void)
 {
-       uint8 val = display->read_signal(SIG_DISPLAY_BUSY) | ~0x81;
+  //   uint8 val = (display->read_signal(SIG_DISPLAY_BUSY) == 0) ? 0x00 : 0x80;
+       uint8 val;
+       val = (sub_busy) ? 0x80 : 0x00;
        if(!extdet_neg) val |= 0x01;
        return val;
 }
@@ -568,6 +573,7 @@ void FM7_MAINIO::write_signal(int id, uint32 data, uint32 mask)
                        break;
                        // FD05
                case FM7_MAINIO_SUB_BUSY:
+                       sub_busy = val_b; 
                        break;
                case FM7_MAINIO_EXTDET:
                        extdet_neg = !val_b;
index aa59479..dfceeaa 100644 (file)
@@ -89,6 +89,7 @@ class FM7_MAINIO : public DEVICE {
 
        /* FD05 : R */
        bool extdet_neg; // bit0 : '1' = none , '0' = exists.
+       bool sub_busy;
        /* FD05 : W */
        bool sub_cancel; // bit6 : '1' Cancel req.
        bool z80_sel;    // bit0 : '1' = Z80. Maybe only FM-7/77.