OSDN Git Service

[VM] Apply VM_TEMPLATE to all VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / z80tvgame / z80tvgame.cpp
index 02aeec3..f07bb8c 100644 (file)
@@ -33,7 +33,7 @@
 // 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;
@@ -57,7 +57,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        event->set_context_sound(pcm);
 
        // Sound:: Force realtime rendering. This is temporally fix. 20161024 K.O
-       pcm->set_realtime_render(true);
+       //pcm->set_realtime_render(true);
 
 #ifdef _USE_I8255
        pio->set_context_port_c(pcm, SIG_PCM1BIT_SIGNAL, 1, 0);
@@ -78,6 +78,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+       decl_state();
 }
 
 VM::~VM()
@@ -214,12 +215,31 @@ void VM::update_config()
        }
 }
 
-#define STATE_VERSION  1
+#define STATE_VERSION  2
+
+#include "../../statesub.h"
+#include "../../qt/gui/csp_logger.h"
+extern CSP_Logger DLL_PREFIX_I *csp_logger;
+
+void VM::decl_state(void)
+{
+#if defined(_USE_I8255)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::Z80_TV_GAME_I8255_HEAD")), csp_logger);
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::Z80_TV_GAME_Z80PIO_HEAD")), csp_logger);
+#endif
+       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);
        }
@@ -227,7 +247,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) {