OSDN Git Service

[BUILD] Set SOVERSION and GIT hash automatically.
[csp-qt/common_source_project-fm7.git] / source / src / vm / multi8 / multi8.cpp
index ea0b548..98ff6c7 100644 (file)
 // 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
-#if defined(_USE_QT)
        dummy->set_device_name(_T("1st Dummy"));
-       event->set_device_name(_T("EVENT"));
-#endif 
        
        beep = new BEEP(this, emu);
        crtc = new HD46505(this, emu);
@@ -66,11 +63,6 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
 //     psg = new YM2203(this, emu);
        psg = new AY_3_891X(this, emu);
        cpu = new Z80(this, emu);
-#if defined(_USE_QT)
-       psg->set_device_name(_T("AY-3-8910 PSG"));
-       io->set_device_name(_T("I/O"));
-       cpu->set_device_name(_T("CPU(Z80)"));
-#endif 
        
        cmt = new CMT(this, emu);
        display = new DISPLAY(this, emu);
@@ -78,23 +70,15 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        kanji = new KANJI(this, emu);
        key = new KEYBOARD(this, emu);
        memory = new MEMORY(this, emu);
-#if defined(_USE_QT)
-       cmt->set_device_name(_T("CMT I/F"));
-       display->set_device_name(_T("DISPLAY I/F"));
-       floppy->set_device_name(_T("FDD I/F"));
-       kanji->set_device_name(_T("KANJI ROM"));
-       key->set_device_name(_T("KEYBOARD I/F"));
-       memory->set_device_name(_T("MEMORY"));
-#endif
+       
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(beep);
        event->set_context_sound(psg);
-#if defined(USE_SOUND_FILES)
-       if(fdc->load_sound_data(UPD765A_SND_TYPE_SEEK, _T("FDDSEEK.WAV"))) {
-               event->set_context_sound(fdc);
-       }
-#endif 
+       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());
+
        crtc->set_context_vsync(pio, SIG_I8255_PORT_A, 0x20);
        sio->set_context_out(cmt, SIG_CMT_OUT);
        pit->set_context_ch1(pit, SIG_I8253_CLOCK_2, 1);
@@ -142,9 +126,14 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        io->set_iomap_single_w(0x78, memory);
        
        // 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();
        }
+       decl_state();
+       
        for(int i = 0; i < 4; i++) {
                fdc->set_drive_type(i, DRIVE_TYPE_2D);
        }
@@ -216,12 +205,6 @@ void VM::draw_screen()
        display->draw_screen();
 }
 
-uint32_t VM::get_access_lamp_status()
-{
-       uint32_t status = fdc->read_signal(0);
-       return (status & (1 | 4)) ? 1 : (status & (2 | 8)) ? 2 : 0;
-}
-
 // ----------------------------------------------------------------------------
 // soud manager
 // ----------------------------------------------------------------------------
@@ -258,15 +241,24 @@ void VM::set_sound_device_volume(int ch, int decibel_l, int 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);
        }
-#if defined(USE_SOUND_FILES)
-       else if(ch == 2) {
-               fdc->set_volume(UPD765A_SND_TYPE_SEEK, decibel_l, decibel_r);
-       }
-#endif
 }
 #endif
 
 // ----------------------------------------------------------------------------
+// notify key
+// ----------------------------------------------------------------------------
+
+bool VM::get_caps_locked()
+{
+       return key->get_caps_locked();
+}
+
+bool VM::get_kana_locked()
+{
+       return key->get_kana_locked();
+}
+
+// ----------------------------------------------------------------------------
 // user interface
 // ----------------------------------------------------------------------------
 
@@ -295,22 +287,27 @@ bool VM::is_floppy_disk_protected(int drv)
        return fdc->is_disk_protected(drv);
 }
 
-void VM::play_tape(const _TCHAR* file_path)
+uint32_t VM::is_floppy_disk_accessed()
+{
+       return fdc->read_signal(0);
+}
+
+void VM::play_tape(int drv, const _TCHAR* file_path)
 {
        cmt->play_tape(file_path);
 }
 
-void VM::rec_tape(const _TCHAR* file_path)
+void VM::rec_tape(int drv, const _TCHAR* file_path)
 {
        cmt->rec_tape(file_path);
 }
 
-void VM::close_tape()
+void VM::close_tape(int drv)
 {
        cmt->close_tape();
 }
 
-bool VM::is_tape_inserted()
+bool VM::is_tape_inserted(int drv)
 {
        return cmt->is_tape_inserted();
 }
@@ -327,12 +324,27 @@ void VM::update_config()
        }
 }
 
-#define STATE_VERSION  3
+#define STATE_VERSION  4
+
+#include "../../statesub.h"
+#include "../../qt/gui/csp_logger.h"
+extern CSP_Logger DLL_PREFIX_I *csp_logger;
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MULTI8_HEAD")), csp_logger);
+       for(DEVICE* device = first_device; device; device = device->next_device) {
+               device->decl_state();
+       }
+}
 
 void VM::save_state(FILEIO* state_fio)
 {
-       state_fio->FputUint32(STATE_VERSION);
+       //state_fio->FputUint32(STATE_VERSION);
        
+       if(state_entry != NULL) {
+               state_entry->save_state(state_fio);
+       }
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->save_state(state_fio);
        }
@@ -340,7 +352,15 @@ void VM::save_state(FILEIO* state_fio)
 
 bool VM::load_state(FILEIO* state_fio)
 {
-       if(state_fio->FgetUint32() != STATE_VERSION) {
+       //if(state_fio->FgetUint32() != STATE_VERSION) {
+       //      return false;
+       //}
+       bool mb = false;
+       if(state_entry != NULL) {
+               mb = state_entry->load_state(state_fio);
+       }
+       if(!mb) {
+               emu->out_debug_log("INFO: HEADER DATA ERROR");
                return false;
        }
        for(DEVICE* device = first_device; device; device = device->next_device) {