OSDN Git Service

[VM][FM7][DISPLAY] Not use CLR_HACK for MC6809 and delay using CLR to set busy flag...
authorK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 30 Jul 2018 19:30:45 +0000 (04:30 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 30 Jul 2018 19:30:45 +0000 (04:30 +0900)
source/src/vm/fm7/display.cpp
source/src/vm/fm7/fm7.cpp
source/src/vm/fm7/fm7_common.h
source/src/vm/fm7/fm7_display.h

index 6a84e82..90952fe 100644 (file)
@@ -199,7 +199,7 @@ void DISPLAY::reset_some_devices()
 # endif        
 #endif
        vram_wrote = true;
-       clr_count = 0;
+       delay_busy = false;
        frame_skip_count_draw = 3;
        frame_skip_count_transfer = 3;
        need_transfer_line = true;
@@ -1670,9 +1670,13 @@ void DISPLAY::event_callback(int event_id, int err)
                        event_callback_vsync();
                        break;
 //#endif                       
-               case EVENT_FM7SUB_CLR_BUSY:
+               case EVENT_FM7SUB_DELAY_BUSY:
+                       delay_busy = false;
                        set_subbusy();
                        break;
+               case EVENT_FM7SUB_CLEAR_DELAY:
+                       delay_busy = false;
+                       break;
                case EVENT_FM7SUB_CLR_CRTFLAG:
                        reset_crtflag();
                        break;
@@ -2138,13 +2142,6 @@ void DISPLAY::write_signal(int id, uint32_t data, uint32_t mask)
                        do_firq(flag & !(firq_mask));
                        key_firq_req = flag;
                        break;
-               case SIG_FM7_SUB_USE_CLR:
-                       if(flag) {
-                               clr_count = data & 0x03;
-                       } else {
-                               clr_count = 0;
-                       }
-                       break;
                default:
                        break;
        }
@@ -2211,6 +2208,17 @@ uint32_t DISPLAY::read_mmio(uint32_t addr)
                        retval = set_vramaccess();
                        break;
                case 0x0a:
+                       { // If use CLR insn to set busy flag, clear flag at first, then delay and set flag. 
+                               double usec;
+                               // Delay at least 3+ clocks (CLR <$0A )
+                               delay_busy = true;
+                               if(clock_fast) {
+                                       usec = (4000.0 * 1000.0) / 2000000.0;
+                               } else {
+                                       usec = (4000.0 * 1000.0) / 999000.0;
+                               }
+                               register_event(this, EVENT_FM7SUB_CLEAR_DELAY, usec, false, NULL); // NEXT CYCLE_
+                       }
                        reset_subbusy();
                        break;
 #if defined(_FM77L4)
@@ -2785,21 +2793,20 @@ void DISPLAY::write_mmio(uint32_t addr, uint8_t data)
                        break;
                // BUSY
                case 0x0a:
-                       if(clr_count <= 0) {
-                               set_subbusy();
-                       } else { // Read once when using clr_foo() to set busy flag.
+                       if(delay_busy) { // If WRITE after READ immediately.Perhaps use CLR insn.
                                double usec;
+                               // Delay at least 5+ clocks (CLR $D40A or CLR (INDEX = $D40A))
                                if(clock_fast) {
-                                       usec = (1000.0 * 1000.0) / 2000000.0;
+                                       usec = (6000.0 * 1000.0) / 2000000.0;
                                } else {
-                                       usec = (1000.0 * 1000.0) / 999000.0;
+                                       usec = (6000.0 * 1000.0) / 999000.0;
                                }
-                               if(!(is_cyclesteal) && (vram_accessflag))  usec = usec * 3.0;
-                               usec = (double)clr_count * usec;
-                               register_event(this, EVENT_FM7SUB_CLR_BUSY, usec, false, NULL); // NEXT CYCLE_
+                               register_event(this, EVENT_FM7SUB_DELAY_BUSY, usec, false, NULL); // NEXT CYCLE_
                                reset_subbusy();
-                               clr_count = 0;
-                       }
+                               delay_busy = false;
+                       } else {
+                               set_subbusy();
+                       } 
                        break;
                // LED
 #if defined(_FM77L4)
@@ -3500,14 +3507,14 @@ void DISPLAY::release()
 {
 }
 
-#define STATE_VERSION 11
+#define STATE_VERSION 12
 void DISPLAY::decl_state(void)
 {
        enter_decl_state(STATE_VERSION);
        DECL_STATE_ENTRY_INT(this_device_id);
        {
                int i;
-               DECL_STATE_ENTRY_INT32(clr_count);
+               DECL_STATE_ENTRY_BOOL(delay_busy);
                DECL_STATE_ENTRY_BOOL(halt_flag);
                DECL_STATE_ENTRY_INT32(active_page);
                DECL_STATE_ENTRY_BOOL(sub_busy);
index f923294..6f0ff04 100644 (file)
@@ -621,7 +621,7 @@ void VM::connect_bus(void)
        opn[2]->set_context_irq(mainio, FM7_MAINIO_THG_IRQ, 0xffffffff);
        mainio->set_context_opn(opn[2], 2);
 #endif   
-       subcpu->set_context_bus_clr(display, SIG_FM7_SUB_USE_CLR, 0x0000000f);
+       //subcpu->set_context_bus_clr(display, SIG_FM7_SUB_USE_CLR, 0x0000000f);
    
        event->register_frame_event(joystick);
 #if defined(HAS_DMA)
index e42b6ef..22c6fcc 100644 (file)
@@ -121,7 +121,7 @@ enum {
        EVENT_FM7SUB_VSTART,
        EVENT_FM7SUB_VSYNC,
        EVENT_FM7SUB_HALT,
-       EVENT_FM7SUB_CLR_BUSY,
+       EVENT_FM7SUB_DELAY_BUSY,
        EVENT_FM7SUB_CLR_CRTFLAG,
        EVENT_FM7SUB_PROC,
        EVENT_FM7SUB_CURSOR_BLINK,
@@ -129,6 +129,7 @@ enum {
        EVENT_PRINTER_RESET_COMPLETED,
        EVENT_FM7MAINMEM_WAIT_START,
        EVENT_FM7MAINMEM_WAIT_STOP,
+       EVENT_FM7SUB_CLEAR_DELAY,
 };
 
 
@@ -306,7 +307,7 @@ enum {
        SIG_FM7_SUB_BANK,
        SIG_FM7_SUB_KEY_FIRQ,
        SIG_FM7_SUB_KEY_MASK,
-       SIG_FM7_SUB_USE_CLR
+       //SIG_FM7_SUB_USE_CLR
 };
 
 // KEYBOARD
index fe468cc..137963b 100644 (file)
@@ -52,7 +52,7 @@ protected:
        void (DISPLAY::*write_cpu_func_table[512])(uint32_t, uint8_t);
        void (DISPLAY::*write_dma_func_table[512])(uint32_t, uint8_t);
        
-       int clr_count;
+       bool delay_busy;
        bool screen_update_flag;
        bool crt_flag_bak;