OSDN Git Service

[BUILD] Set SOVERSION and GIT hash automatically.
[csp-qt/common_source_project-fm7.git] / source / src / vm / j3100 / j3100.cpp
index cc59517..bd0978b 100644 (file)
 //#include "../i8250.h"
 #include "../i8253.h"
 #include "../i8259.h"
-#include "../i86.h"
+//#if defined(HAS_I286)
+#include "../i286.h"
+//#else
+//#include "../i86.h"
+//#endif
 #include "../io.h"
+#include "../noise.h"
 #include "../pcm1bit.h"
 #include "../upd765a.h"
 #ifdef TYPE_SL
 #include "../hd146818p.h"
 #endif
 
+#ifdef USE_DEBUGGER
+#include "../debugger.h"
+#endif
+
 #include "display.h"
 #include "dmareg.h"
 #include "floppy.h"
 // initialize
 // ----------------------------------------------------------------------------
 
-VM::VM(EMU* parent_emu) : emu(parent_emu)
+VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
 {
        // create devices
        first_device = last_device = NULL;
        dummy = new DEVICE(this, emu);  // must be 1st device
        event = new EVENT(this, emu);   // must be 2nd device
+       dummy->set_device_name(_T("1st Dummy"));
        
        crtc = new HD46505(this, emu);
        dma = new I8237(this, emu);
 #ifndef TYPE_SL
        dma2 = new I8237(this, emu);
 #endif
+#ifndef TYPE_SL
+       dma->set_device_name(_T("i8237 DMAC #1"));
+       dma2->set_device_name(_T("i8237 DMAC #2"));
+#endif
 //     sio = new I8250(this, emu);
        pit = new I8253(this, emu);     // i8254
        pic = new I8259(this, emu);
-       cpu = new I86(this, emu);
+//#if defined(HAS_I286)
+       cpu = new I286(this, emu);
+//#else
+//     cpu = new I86(this, emu);
+//#endif
        io = new IO(this, emu);
        pcm = new PCM1BIT(this, emu);
        fdc = new UPD765A(this, emu);
+       fdc->set_context_noise_seek(new NOISE(this, emu));
+       fdc->set_context_noise_head_down(new NOISE(this, emu));
+       fdc->set_context_noise_head_up(new NOISE(this, emu));
 #ifdef TYPE_SL
        rtc = new RP5C01(this, emu);
 #else
@@ -78,15 +99,20 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        memory = new MEMORY(this, emu);
        sasi = new SASI(this, emu);
        system = new SYSTEM(this, emu);
-       
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(pcm);
-       
+       event->set_context_sound(fdc->get_context_noise_seek());
+       event->set_context_sound(fdc->get_context_noise_head_down());
+       event->set_context_sound(fdc->get_context_noise_head_up());
+
        // cpu bus
        cpu->set_context_mem(memory);
        cpu->set_context_io(io);
        cpu->set_context_intr(pic);
+#ifdef USE_DEBUGGER
+       cpu->set_context_debugger(new DEBUGGER(this, emu));
+#endif
        
        // dmac
        io->set_iomap_range_rw(0x00, 0x0f, dma);
@@ -99,7 +125,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
                io->set_iomap_alias_rw(i, dma2, i >> 1);
        }
        dma2->set_context_memory(memory);
-       dma2->set_word_mode(true);
+       dma2->set_mode_word(true);
        dmareg->set_context_dma2(dma2);
 #endif
        
@@ -196,11 +222,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
                0x2e8, 0x42e8, 0x82e8, 0xc2e8,
 #endif
        };
-#ifdef _MSC_VER   
-       for(int i = 0; i < _countof(ems_addr); i++) {
-#else
-       for(int i = 0; i < (sizeof(ems_addr) / sizeof(int)); i++) {
-#endif
+       for(int i = 0; i < array_length(ems_addr); i++) {
                io->set_iomap_single_rw(ems_addr[i], memory);
 #ifdef TYPE_SL
                io->set_iomap_single_w(ems_addr[i] + 1, memory);
@@ -227,15 +249,16 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
                io->set_flipflop_single_rw(i, iovalues[i & 0x1f]);
        }
 #endif
-
-
-
-
-       
        // initialize all devices
+#if defined(__GIT_REPO_VERSION)
+       strncpy(_git_revision, __GIT_REPO_VERSION, sizeof(_git_revision) - 1);
+#endif
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+#ifdef TYPE_SL
+       //pcm->set_realtime_render(true);
+#endif
 }
 
 VM::~VM()
@@ -259,12 +282,6 @@ DEVICE* VM::get_device(int id)
        return NULL;
 }
 
-   
-void VM::register_frame_event(DEVICE* dev)
-{
-       this->event->register_frame_event(dev);
-}
-
 // ----------------------------------------------------------------------------
 // drive virtual machine
 // ----------------------------------------------------------------------------
@@ -283,18 +300,26 @@ void VM::run()
 }
 
 // ----------------------------------------------------------------------------
-// draw screen
+// debugger
 // ----------------------------------------------------------------------------
 
-void VM::draw_screen()
+#ifdef USE_DEBUGGER
+DEVICE *VM::get_cpu(int index)
 {
-       display->draw_screen();
+       if(index == 0) {
+               return cpu;
+       }
+       return NULL;
 }
+#endif
+
+// ----------------------------------------------------------------------------
+// draw screen
+// ----------------------------------------------------------------------------
 
-int VM::access_lamp()
+void VM::draw_screen()
 {
-       uint32 status = fdc->read_signal(0);
-       return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0;
+       display->draw_screen();
 }
 
 // ----------------------------------------------------------------------------
@@ -307,18 +332,31 @@ void VM::initialize_sound(int rate, int samples)
        event->initialize_sound(rate, samples);
        
        // init sound gen
-       pcm->init(rate, 8000);
+       pcm->initialize_sound(rate, 8000);
 }
 
-uint16* VM::create_sound(int* extra_frames)
+uint16_t* VM::create_sound(int* extra_frames)
 {
        return event->create_sound(extra_frames);
 }
 
-int VM::sound_buffer_ptr()
+int VM::get_sound_buffer_ptr()
+{
+       return event->get_sound_buffer_ptr();
+}
+
+#ifdef USE_SOUND_VOLUME
+void VM::set_sound_device_volume(int ch, int decibel_l, int decibel_r)
 {
-       return event->sound_buffer_ptr();
+       if(ch == 0) {
+               pcm->set_volume(0, decibel_l, decibel_r);
+       } else if(ch == 1) {
+               fdc->get_context_noise_seek()->set_volume(0, decibel_l, decibel_r);
+               fdc->get_context_noise_head_down()->set_volume(0, decibel_l, decibel_r);
+               fdc->get_context_noise_head_up()->set_volume(0, decibel_l, decibel_r);
+       }
 }
+#endif
 
 // ----------------------------------------------------------------------------
 // notify key
@@ -338,34 +376,39 @@ void VM::key_up(int code)
 // user interface
 // ----------------------------------------------------------------------------
 
-void VM::open_disk(int drv, _TCHAR* file_path, int bank)
+void VM::open_floppy_disk(int drv, const _TCHAR* file_path, int bank)
 {
        fdc->open_disk(drv, file_path, bank);
 }
 
-void VM::close_disk(int drv)
+void VM::close_floppy_disk(int drv)
 {
        fdc->close_disk(drv);
 }
 
-bool VM::disk_inserted(int drv)
+bool VM::is_floppy_disk_inserted(int drv)
+{
+       return fdc->is_disk_inserted(drv);
+}
+
+void VM::is_floppy_disk_protected(int drv, bool value)
 {
-       return fdc->disk_inserted(drv);
+       fdc->is_disk_protected(drv, value);
 }
 
-void VM::set_disk_protected(int drv, bool value)
+bool VM::is_floppy_disk_protected(int drv)
 {
-       fdc->set_disk_protected(drv, value);
+       return fdc->is_disk_protected(drv);
 }
 
-bool VM::get_disk_protected(int drv)
+uint32_t VM::is_floppy_disk_accessed()
 {
-       return fdc->get_disk_protected(drv);
+       return fdc->read_signal(0);
 }
 
-bool VM::now_skip()
+bool VM::is_frame_skippable()
 {
-       return event->now_skip();
+       return event->is_frame_skippable();
 }
 
 void VM::update_config()