OSDN Git Service

[VM][DEVICE] Get OSD:: at constructor, not initialize().
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 13 Jun 2017 17:41:55 +0000 (02:41 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 13 Jun 2017 17:41:55 +0000 (02:41 +0900)
source/src/vm/libcpu_newdev/device.cpp
source/src/vm/libcpu_newdev/device.h
source/src/vm/mc6844.cpp
source/src/vm/mc6844.h
source/src/vm/upd71071.cpp
source/src/vm/upd71071.h

index ff66a42..16a5504 100644 (file)
@@ -20,7 +20,9 @@ DEVICE::DEVICE(VM* parent_vm, EMU* parent_emu) : vm(parent_vm), emu(parent_emu)
 {
        vm = parent_vm;
        emu = parent_emu;
-       osd = NULL;
+       //osd = NULL;
+       osd = emu->get_osd();
+       //this->out_debug_log("OSD is %08x", osd); 
        strncpy(this_device_name, "Base Device", 128);
        prev_device = vm->last_device;
        next_device = NULL;
index 105ca71..4fd95c1 100644 (file)
@@ -65,7 +65,7 @@ public:
        //~DEVICE(void);
        virtual ~DEVICE() {}
        
-       virtual void initialize() { osd = emu->get_osd(); }
+       virtual void initialize() { /* osd = emu->get_osd(); */}
        virtual void release() {}
        
        virtual void update_config() {}
index 70ec8ba..f91a961 100644 (file)
@@ -134,13 +134,13 @@ void MC6844::transfer(int ch)
        if(priority_ctrl_reg & (1 << ch)) {
                if(dma[ch].byte_count_reg.w.l != 0) {
                        if(dma[ch].channel_ctrl_reg & 0x01) {
-                               uint8_t data = 0xff;
-                               if(d_memory != NULL) data = d_memory->read_dma_data8(dma[ch].address_reg.w.l);
-                               if(dma[ch].device != NULL) dma[ch].device->write_dma_io8(0, data);
+                               uint8_t data;
+                               data = d_memory->read_dma_data8(dma[ch].address_reg.w.l);
+                               dma[ch].device->write_dma_io8(0, data);
                        } else {
-                               uint8_t data = 0xff;
-                               if(dma[ch].device != NULL) dma[ch].device->read_dma_io8(0);
-                               if(d_memory != NULL) d_memory->write_dma_data8(dma[ch].address_reg.w.l, data);
+                               uint8_t data;
+                               data = dma[ch].device->read_dma_io8(0);
+                               d_memory->write_dma_data8(dma[ch].address_reg.w.l, data);
                        }
                        if(dma[ch].channel_ctrl_reg & 0x08) {
                                dma[ch].address_reg.d--;
index 8401974..1246281 100644 (file)
@@ -43,14 +43,21 @@ private:
 public:
        MC6844(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
+               // TIP: if((DEVICE::prev_device == NULL) || (DEVICE::this_device_id == 0)) DEVICE must be DUMMY.
+               // And, at this device, should not be FIRST DEVICE. 20170613 Ohta.
+               DEVICE *__dev = this;
+               while((__dev->prev_device != NULL) && (__dev->this_device_id > 0)) {
+                       __dev = __dev->prev_device;
+               }
+               
 //             for(int i = 0; i < 4; i++) {
 //                     dma[i].device = vm->dummy;
 //             }
 //             d_memory = vm->dummy;
                for(int i = 0; i < 4; i++) {
-                       dma[i].device = NULL;
+                       dma[i].device = __dev;
                }
-               d_memory = NULL;
+               d_memory = __dev;
                initialize_output_signals(&outputs_irq);
                set_device_name(_T("MC6844 DMAC"));
        }
index e709d4f..3ca18cd 100644 (file)
@@ -229,20 +229,14 @@ void UPD71071::do_dma()
                                        if((dma[c].mode & 0x0c) == 4) {
                                                // io -> memory
                                                uint32_t val;
-                                               if(dma[c].dev != NULL) {
-                                                       val = dma[c].dev->read_dma_io8(0);
-                                               } else {
-                                                       val = 0xff;
-                                               }
+                                               val = dma[c].dev->read_dma_io8(0);
                                                d_mem->write_dma_data8(dma[c].areg, val);
                                                // update temporary register
                                                tmp = (tmp >> 8) | (val << 8);
                                        } else if((dma[c].mode & 0x0c) == 8) {
                                                // memory -> io
                                                uint32_t val = d_mem->read_dma_data8(dma[c].areg);
-                                               if(dma[c].dev != NULL) {
-                                                       dma[c].dev->write_dma_io8(0, val);
-                                               }
+                                               dma[c].dev->write_dma_io8(0, val);
                                                // update temporary register
                                                tmp = (tmp >> 8) | (val << 8);
                                        }
index 481ee8b..fc4f392 100644 (file)
@@ -43,10 +43,17 @@ private:
 public:
        UPD71071(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
+               // TIP: if((DEVICE::prev_device == NULL) || (DEVICE::this_device_id == 0)) DEVICE must be DUMMY.
+               // And, at this device, should not be FIRST DEVICE. 20170613 Ohta.
+               DEVICE *__dev = this;
+               while((__dev->prev_device != NULL) && (__dev->this_device_id > 0)) {
+                       __dev = __dev->prev_device;
+               }
                for(int i = 0; i < 4; i++) {
                        //dma[i].dev = vm->dummy;
-                       dma[i].dev = NULL;
+                       dma[i].dev = __dev;
                }
+               d_mem = __dev;
 //#ifdef SINGLE_MODE_DMA
                d_dma = NULL;
 //#endif