OSDN Git Service

[VM][FM7] WIP: Implementing correct subsystem, yet.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 15 Mar 2015 21:00:52 +0000 (06:00 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 15 Mar 2015 21:00:52 +0000 (06:00 +0900)
source/src/vm/fm7/display.cpp
source/src/vm/fm7/fm7_common.h
source/src/vm/fm7/fm7_display.h
source/src/vm/mc6809.cpp

index 6c7dba3..5d80d62 100644 (file)
@@ -38,9 +38,11 @@ void DISPLAY::reset(void)
        if(hdisp_event_id >= 0) cancel_event(this, hdisp_event_id);
        if(vsync_event_id >= 0) cancel_event(this, vsync_event_id);
        if(vstart_event_id >= 0) cancel_event(this, vstart_event_id);
+       if(halt_event_id >= 0) cancel_event(this, halt_event_id);
        hblank_event_id = -1;
        hdisp_event_id = -1;
        vsync_event_id = -1;
+       halt_event_id = -1;
        for(i = 0; i < 8; i++) set_dpalette(i, i);
        
        offset_77av = false;
@@ -56,6 +58,7 @@ void DISPLAY::reset(void)
        vblank = false;
        vsync = false;
        hblank = true;
+       halt_flag = false;
        displine = 0;
        
        set_cyclesteal(config.dipswitch & 0x01); // CYCLE STEAL = bit0.
@@ -348,6 +351,7 @@ void DISPLAY::go_subcpu(void)
 void DISPLAY::enter_display(void)
 {
        bool tmpf;
+       //sub_run = false;
        if(is_cyclesteal) {
                vram_wait = false;
                return;
@@ -358,24 +362,28 @@ void DISPLAY::enter_display(void)
 void DISPLAY::leave_display(void)
 {
        vram_wait = false;
-       go_subcpu();
+       //sub_run = false;
+       //go_subcpu();
 }
 
 void DISPLAY::halt_subsystem(void)
 {
+       halt_flag = false;
        sub_run = false;
-       if(!sub_run) {
-               halt_subcpu();
-               mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01); // BUSY
-       }
+       if(halt_event_id >= 0) cancel_event(this, halt_event_id);
+       register_event_by_clock(this, EVENT_FM7SUB_HALT, 10, true, &halt_event_id);
+       //mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x00, 0x01);
 }
 
 void DISPLAY::restart_subsystem(void)
 {
        sub_run = true;
+       halt_flag = false;
        if(sub_run) {
+               if(halt_event_id >= 0) cancel_event(this, halt_event_id);
+               halt_event_id = -1;
                go_subcpu();
-//             mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01); // BUSY
+               mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01); // BUSY
        }
 //     go_subcpu();
 //     mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01); // BUSY
@@ -399,7 +407,7 @@ void DISPLAY::reset_crtflag(void)
 uint8 DISPLAY::acknowledge_irq(void)
 {
        this->do_irq(false);
-       mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01);
+       //mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x00, 0x01);
        return 0xff;
 }
 
@@ -449,7 +457,8 @@ void DISPLAY::reset_vramaccess(void)
 //SUB:D40A:R
 uint8 DISPLAY::reset_subbusy(void)
 {
-       mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x00, 0x01);
+       mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x00, 0x01);
+       //sub_run = false;
        return 0xff;
 }
 
@@ -836,6 +845,15 @@ void DISPLAY::event_callback(int event_id, int err)
                        }
                        register_event(this, EVENT_FM7SUB_VSTART, usec, false, &vstart_event_id); // NEXT CYCLE_
                        break;
+               case EVENT_FM7SUB_HALT:
+                       if(!sub_run) {
+                               halt_subcpu();
+                               mainio->write_signal(FM7_MAINIO_SUB_BUSY, 0x01, 0x01); // BUSY
+                               cancel_event(this, halt_event_id);
+                               halt_event_id = -1;
+                               halt_flag = true;                  
+                       }
+               break;
        }
 }
 
@@ -853,7 +871,7 @@ uint32 DISPLAY::read_signal(int id)
        switch(id) {
                case SIG_FM7_SUB_HALT:
                case SIG_DISPLAY_HALT:
-                       return (!sub_run) ? 0x00000000 : 0xffffffff;
+                       return (halt_flag) ? 0 : 0xffffffff;
                        break;
                default:
                        return 0;
index b8c5014..45207d9 100644 (file)
@@ -72,6 +72,7 @@ enum {
        EVENT_FM7SUB_HBLANK,
        EVENT_FM7SUB_VSTART,
        EVENT_FM7SUB_VSYNC,
+       EVENT_FM7SUB_HALT,
        ID_KEYBOARD_RXRDY_OK = 64,
        ID_KEYBOARD_RXRDY_BUSY,
        ID_KEYBOARD_ACK,
index 6897f1a..6dce19c 100644 (file)
@@ -98,7 +98,9 @@ class DISPLAY: public MEMORY
        int hdisp_event_id;
        int vsync_event_id;
        int vstart_event_id;
+       int halt_event_id;
        int display_mode;
+       bool halt_flag;
 
        scrntype dpalette_pixel[8];
        uint8 dpalette_data[8];
index 601ef3e..5b9005b 100644 (file)
@@ -385,6 +385,11 @@ void MC6809::cpu_irq(void)
 
 int MC6809::run(int clock)
 {
+//     if ((int_state & MC6809_HALT_BIT) != 0) {       // 0x80
+//             icount = 0;
+//             extra_icount = 0;
+//             return icount;
+//     } 
        if((int_state & MC6809_INSN_HALT) != 0) {       // 0x80
                uint8 dmy = RM(PCD);
                icount -= 2;
@@ -418,8 +423,9 @@ void MC6809::run_one_opecode()
        if ((int_state & MC6809_HALT_BIT) != 0) {       // 0x80
                icount = 0;
                extra_icount = 0;
-               return icount;
-       } else  if(int_state & MC6809_NMI_BIT) {
+               return;
+       } else
+        if(int_state & MC6809_NMI_BIT) {
                int_state &= ~MC6809_NMI_BIT;
                int_state &= ~MC6809_SYNC_IN; /* clear SYNC flag */
                int_state |=  MC6809_SYNC_OUT; /* clear SYNC flag */
@@ -908,14 +914,14 @@ inline void MC6809::fetch_effective_address_IDX(uint8 upper, uint8 lower)
                        break;
        }
        // $9x,$bx,$dx,$fx = INDIRECT
-       if (indirect != 0) {
+       if (indirect) {
                EAD = RM16(EAD);
        }
 }
 
 void MC6809::illegal()
 {
-       //logerror("MC6809: illegal opcode at %04x\n", PC);
+       printf("MC6809: illegal opcode at %04x\n", PC);
 }
 
 /* $00 NEG direct ?**** */
@@ -4017,7 +4023,7 @@ void MC6809::pref10()
        case 0xef: sts_ix(); icount -= 6; break;
        case 0xfe: lds_ex(); icount -= 7; break;
        case 0xff: sts_ex(); icount -= 7; break;
-       default: illegal(); break;
+       default: illegal(); break; // OKAY?
        }
 }