OSDN Git Service

[VM][STATE] Apply statesub.h to VM::foo_state() with remained VMs.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 2 Jun 2018 02:30:22 +0000 (11:30 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 2 Jun 2018 02:30:22 +0000 (11:30 +0900)
41 files changed:
source/src/vm/pc8201/pc8201.cpp
source/src/vm/pc8201/pc8201.h
source/src/vm/pc9801/pc9801.cpp
source/src/vm/pc9801/pc9801.h
source/src/vm/pc98ha/pc98ha.cpp
source/src/vm/pc98ha/pc98ha.h
source/src/vm/phc20/phc20.cpp
source/src/vm/phc20/phc20.h
source/src/vm/phc25/phc25.cpp
source/src/vm/phc25/phc25.h
source/src/vm/pv1000/pv1000.cpp
source/src/vm/pv1000/pv1000.h
source/src/vm/pv2000/pv2000.cpp
source/src/vm/pv2000/pv2000.h
source/src/vm/pyuta/pyuta.cpp
source/src/vm/pyuta/pyuta.h
source/src/vm/qc10/qc10.cpp
source/src/vm/qc10/qc10.h
source/src/vm/rx78/rx78.cpp
source/src/vm/rx78/rx78.h
source/src/vm/sc3000/sc3000.cpp
source/src/vm/sc3000/sc3000.h
source/src/vm/scv/scv.cpp
source/src/vm/scv/scv.h
source/src/vm/smb80te/smb80te.cpp
source/src/vm/smb80te/smb80te.h
source/src/vm/smc777/smc777.cpp
source/src/vm/smc777/smc777.h
source/src/vm/tk80bs/tk80bs.cpp
source/src/vm/tk80bs/tk80bs.h
source/src/vm/x07/x07.cpp
source/src/vm/x07/x07.h
source/src/vm/x1/x1.cpp
source/src/vm/yalky/yalky.cpp
source/src/vm/yalky/yalky.h
source/src/vm/yis/yis.cpp
source/src/vm/yis/yis.h
source/src/vm/ys6464a/ys6464a.cpp
source/src/vm/ys6464a/ys6464a.h
source/src/vm/z80tvgame/z80tvgame.cpp
source/src/vm/z80tvgame/z80tvgame.h

index f9f2408..6f607c4 100644 (file)
@@ -103,6 +103,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+       decl_state();
        rtc->write_signal(SIG_UPD1990A_STB, 0, 0);
 }
 
@@ -343,10 +344,30 @@ void VM::update_config()
 
 #define STATE_VERSION  3
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+#if defined(_PC8201)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_8201_HEAD")));
+#elif defined(_PC8201A)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_8201A_HEAD")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_8201_SERIES_HEAD")));
+#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);
        }
@@ -354,7 +375,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) {
index a80f8e8..00fe7fd 100644 (file)
@@ -49,6 +49,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -69,6 +71,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils *state_entry;
        
        // devices
        EVENT* event;
@@ -141,6 +144,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index b760ec0..9f2b0ad 100644 (file)
@@ -1624,7 +1624,34 @@ void VM::update_config()
 
 void VM::decl_state(void)
 {
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98_SERIES_HEAD")));
+#if defined(_PC9801)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801_HEAD")));
+#elif defined(_PC9801E)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801E_HEAD")));
+#elif defined(_PC9801U)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801U_HEAD")));
+#elif defined(_PC9801VF)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801VF_HEAD")));
+#elif defined(_PC9801VM)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801VF_HEAD")));
+#elif defined(_PC98DO)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98DO_HEAD")));
+#elif defined(_PC9801DOPLUS)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98DO_PLUS_HEAD")));
+#elif defined(_PC9801VX)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801VX_HEAD")));
+#elif defined(_PC98XL)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98XL_HEAD")));
+#elif defined(_PC98XA)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98XA_HEAD")));
+#elif defined(_PC9801RA)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801RA_HEAD")));
+#elif defined(_PC98RL)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC98RL_HEAD")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC9801_SERIES_HEAD")));
+#endif
+       
        DECL_STATE_ENTRY_BOOL(pit_clock_8mhz);
 #if defined(_PC98DO) || defined(_PC98DOPLUS)
        DECL_STATE_ENTRY_INT32(boot_mode);
@@ -1632,7 +1659,6 @@ void VM::decl_state(void)
        DECL_STATE_ENTRY_INT32(sound_type);
 #if defined(USE_HARD_DISK) && defined(OPEN_HARD_DISK_IN_RESET)
        DECL_STATE_ENTRY_MULTI(void, hd_file_path, sizeof(hd_file_path));
-
 #endif
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->decl_state();
index 926ea8e..0a09f92 100644 (file)
@@ -328,6 +328,7 @@ static const _TCHAR *sound_device_caption[] = {
 #endif
 
 class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
index 702c6bd..160355a 100644 (file)
@@ -217,6 +217,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()
@@ -399,10 +400,30 @@ void VM::update_config()
 
 #define STATE_VERSION  6
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+#if defined(_PC98HA)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_98HA_HEAD")));
+#elif defined(_PC98LT)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_98LT_HEAD")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PC_98LT_SERIES_HEAD")));
+#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);
        }
@@ -410,7 +431,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) {
index 74e6291..6aa21e3 100644 (file)
@@ -66,6 +66,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -101,6 +103,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils *state_entry;
        
        // devices
        EVENT* event;
@@ -183,6 +186,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index ffcba18..cf1df2e 100644 (file)
@@ -74,6 +74,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()
@@ -256,10 +257,24 @@ void VM::update_config()
 
 #define STATE_VERSION  3
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_20_HEAD")));
+       
+       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);
        }
@@ -267,7 +282,16 @@ 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) {
index b22fd50..73249fa 100644 (file)
@@ -44,6 +44,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -58,6 +60,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -118,6 +121,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index dcf3307..fe5a605 100644 (file)
@@ -107,6 +107,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()
@@ -294,20 +295,48 @@ void VM::update_config()
 
 #define STATE_VERSION  4
 
-void VM::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void VM::decl_state(void)
 {
-       state_fio->FputUint32(STATE_VERSION);
+#if defined(_PHC25)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_25_HEAD")));
+#elif defined(_MAP1010)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MAP_1010_HEAD")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_25_SERIES_HEAD")));
+#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);
+       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);
        }
 }
 
 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) {
                if(!device->load_state(state_fio)) {
                        return false;
index 3acc276..3e1539d 100644 (file)
@@ -54,6 +54,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -75,6 +77,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -142,6 +145,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index d8cfa67..dc524a4 100644 (file)
@@ -75,6 +75,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+       decl_state();
        inserted = false;
 }
 
@@ -216,20 +217,44 @@ void VM::update_config()
 
 #define STATE_VERSION  2
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PV_1000_HEAD")));
+
+       DECL_STATE_ENTRY_1DARRAY(mem, sizeof(mem));
+       DECL_STATE_ENTRY_BOOL(inserted);
+       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);
        }
-       state_fio->Fwrite(mem, sizeof(mem), 1);
-       state_fio->FputBool(inserted);
+       //state_fio->Fwrite(mem, sizeof(mem), 1);
+       //state_fio->FputBool(inserted);
 }
 
 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) {
@@ -237,8 +262,8 @@ bool VM::load_state(FILEIO* state_fio)
                        return false;
                }
        }
-       state_fio->Fread(mem, sizeof(mem), 1);
-       inserted = state_fio->FgetBool();
+       //state_fio->Fread(mem, sizeof(mem), 1);
+       //inserted = state_fio->FgetBool();
        return true;
 }
 
index 45e9250..2a8ce5a 100644 (file)
@@ -56,6 +56,8 @@ static const _TCHAR *joy_button_captions[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -72,6 +74,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -127,6 +130,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index cc24db1..b4c8b13 100644 (file)
@@ -91,6 +91,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+       decl_state();
        inserted = false;
 }
 
@@ -266,21 +267,46 @@ void VM::update_config()
 
 #define STATE_VERSION  2
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PV_2000_HEAD")));
+
+       DECL_STATE_ENTRY_1DARRAY(ram, sizeof(ram));
+       DECL_STATE_ENTRY_1DARRAY(ext, sizeof(ext));
+       DECL_STATE_ENTRY_BOOL(inserted);
+       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);
        }
-       state_fio->Fwrite(ram, sizeof(ram), 1);
-       state_fio->Fwrite(ext, sizeof(ext), 1);
-       state_fio->FputBool(inserted);
+       //state_fio->Fwrite(ram, sizeof(ram), 1);
+       //state_fio->Fwrite(ext, sizeof(ext), 1);
+       //state_fio->FputBool(inserted);
 }
 
 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) {
@@ -288,9 +314,9 @@ bool VM::load_state(FILEIO* state_fio)
                        return false;
                }
        }
-       state_fio->Fread(ram, sizeof(ram), 1);
-       state_fio->Fread(ext, sizeof(ext), 1);
-       inserted = state_fio->FgetBool();
+       //state_fio->Fread(ram, sizeof(ram), 1);
+       //state_fio->Fread(ext, sizeof(ext), 1);
+       //inserted = state_fio->FgetBool();
        return true;
 }
 
index 10309f3..f12b15e 100644 (file)
@@ -50,6 +50,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+       
 class EMU;
 class DEVICE;
 class EVENT;
@@ -68,6 +70,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -136,6 +139,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index ac75a48..f4ecabc 100644 (file)
@@ -71,6 +71,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()
@@ -283,10 +284,24 @@ void VM::update_config()
 
 #define STATE_VERSION  4
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PYUTA_HEAD")));
+
+       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);
        }
@@ -294,7 +309,16 @@ 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) {
index db6df9a..1351da8 100644 (file)
@@ -45,6 +45,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -60,6 +62,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -124,6 +127,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index 1ba2668..59db05c 100644 (file)
@@ -171,6 +171,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+       decl_state();
        //pcm->set_realtime_render(true);
        for(int i = 0; i < 4; i++) {
                fdc->set_drive_type(i, DRIVE_TYPE_2D);
@@ -341,10 +342,27 @@ void VM::update_config()
 
 #define STATE_VERSION  3
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+#ifdef _COLOR_MONITOR
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::QC_10_WITH_COLOR_MONITOR_HEAD")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::QC_10_HEAD")));
+#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);
        }
@@ -352,7 +370,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) {
index ee4b05b..9624a11 100644 (file)
@@ -64,6 +64,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -90,6 +92,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -161,6 +164,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index dd04cac..1b54bcc 100644 (file)
@@ -88,6 +88,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()
@@ -300,10 +301,23 @@ void VM::update_config()
 
 #define STATE_VERSION  3
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::RX_78_HEAD")));
+       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);
        }
@@ -311,7 +325,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) {
index 204fd87..48fced5 100644 (file)
@@ -45,6 +45,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -64,6 +66,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -132,6 +135,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index 546d95d..923c03c 100644 (file)
@@ -358,10 +358,23 @@ void VM::update_config()
 
 #define STATE_VERSION  3
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::SC_3000_HEAD")));
+       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);
        }
@@ -369,7 +382,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) {
index afb027f..d225317 100644 (file)
@@ -48,6 +48,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -68,6 +70,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -144,6 +147,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index 47a4b88..b13523a 100644 (file)
@@ -64,6 +64,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()
@@ -200,10 +201,23 @@ void VM::update_config()
 
 #define STATE_VERSION  2
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::SCV_HEAD")));
+       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);
        }
@@ -211,7 +225,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) {
index 34931b8..6553e7a 100644 (file)
@@ -42,6 +42,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -57,6 +59,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -107,6 +110,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index b443e73..c28c605 100644 (file)
@@ -94,6 +94,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()
@@ -310,10 +311,23 @@ void VM::update_config()
 
 #define STATE_VERSION  3
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::SM_B_80TE_HEAD")));
+       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);
        }
@@ -321,7 +335,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) {
index cc54396..f171c8c 100644 (file)
@@ -93,6 +93,8 @@ const struct {
        {446 + 32 * 0, 110, LED_WIDTH, LED_HEIGHT},
 };
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -109,6 +111,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -179,6 +182,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index c139e34..8011267 100644 (file)
@@ -115,6 +115,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+       decl_state();
        for(int i = 0; i < MAX_DRIVE; i++) {
                fdc->set_drive_type(i, DRIVE_TYPE_2DD); // 1DD
                fdc->set_drive_rpm(i, 600);
@@ -390,10 +391,29 @@ void VM::update_config()
 
 #define STATE_VERSION  4
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+#if defined(_SMC70)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::SMC_70_HEAD")));
+#elif defined(_SMC777)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::SMC_777_HEAD")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::SMC_70_SERIES_HEAD")));
+#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);
        }
@@ -401,7 +421,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) {
index 4d46e71..6a9ef98 100644 (file)
@@ -145,6 +145,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -167,6 +169,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -249,6 +252,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index 9c2b950..be9021a 100644 (file)
@@ -205,6 +205,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()
@@ -543,24 +544,59 @@ void VM::update_config()
 
 #define STATE_VERSION  6
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+#if defined(_TK80)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_80_HEAD")));
+#elif defined(_TK85)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_85_HEAD")));
+#elif defined(_TK80BS)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_80BS_HEAD")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_80_SERIES_HEAD")));
+#endif
+       DECL_STATE_ENTRY_1DARRAY(ram, sizeof(ram));
+#if defined(_TK80BS)
+       DECL_STATE_ENTRY_1DARRAY(vram, sizeof(vram));
+       DECL_STATE_ENTRY_INT32(boot_mode);
+       //DECL_STATE_ENTRY_INT32(draw_ranges);
+#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);
        }
-       state_fio->Fwrite(ram, sizeof(ram), 1);
-#if defined(_TK80BS)
-       state_fio->Fwrite(vram, sizeof(vram), 1);
-       state_fio->FputInt32(boot_mode);
-//     state_fio->FputInt32(draw_ranges);
-#endif
+//     state_fio->Fwrite(ram, sizeof(ram), 1);
+//#if defined(_TK80BS)
+//     state_fio->Fwrite(vram, sizeof(vram), 1);
+//     state_fio->FputInt32(boot_mode);
+////   state_fio->FputInt32(draw_ranges);
+//#endif
 }
 
 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) {
@@ -568,11 +604,11 @@ bool VM::load_state(FILEIO* state_fio)
                        return false;
                }
        }
-       state_fio->Fread(ram, sizeof(ram), 1);
+//     state_fio->Fread(ram, sizeof(ram), 1);
 #if defined(_TK80BS)
-       state_fio->Fread(vram, sizeof(vram), 1);
-       boot_mode = state_fio->FgetInt32();
-//     draw_ranges = state_fio->FgetInt32();
+//     state_fio->Fread(vram, sizeof(vram), 1);
+//     boot_mode = state_fio->FgetInt32();
+////   draw_ranges = state_fio->FgetInt32();
        
        // post process
        emu->reload_bitmap();
index 2875065..5824163 100644 (file)
@@ -181,6 +181,8 @@ const struct {
 #endif
 };
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -206,6 +208,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -302,6 +305,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index 99ed936..eea1980 100644 (file)
@@ -75,6 +75,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()
@@ -232,20 +233,44 @@ void VM::update_config()
 
 #define STATE_VERSION  2
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::X07_HEAD")));
+       DECL_STATE_ENTRY_1DARRAY(ram, sizeof(ram));
+       DECL_STATE_ENTRY_1DARRAY(vram, sizeof(vram));
+       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);
        }
-       state_fio->Fwrite(ram, sizeof(ram), 1);
-       state_fio->Fwrite(vram, sizeof(vram), 1);
+       //state_fio->Fwrite(ram, sizeof(ram), 1);
+       //state_fio->Fwrite(vram, sizeof(vram), 1);
 }
 
 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) {
@@ -253,8 +278,8 @@ bool VM::load_state(FILEIO* state_fio)
                        return false;
                }
        }
-       state_fio->Fread(ram, sizeof(ram), 1);
-       state_fio->Fread(vram, sizeof(vram), 1);
+       //state_fio->Fread(ram, sizeof(ram), 1);
+       //state_fio->Fread(vram, sizeof(vram), 1);
        return true;
 }
 
index bc484f2..17d3211 100644 (file)
@@ -52,6 +52,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -68,6 +70,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -132,6 +135,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index cdd1518..46a3581 100644 (file)
@@ -985,7 +985,18 @@ void VM::update_dipswitch()
 
 void VM::decl_state(void)
 {
-       state_entry = new csp_state_utils(STATE_VERSION, 0, CONFIG_NAME);
+#if defined(_X1)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, _T("CSP::X1_HEAD"));
+#elif defined(_X1TURBO)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, _T("CSP::X1_TURBO_HEAD"));
+#elif defined(_X1TURBOZ)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, _T("CSP::X1_TURBO_Z_HEAD"));
+#elif defined(_X1TWIN)
+       state_entry = new csp_state_utils(STATE_VERSION, 0, _T("CSP::X1_TWIN_HEAD"));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, _T("CSP::X1_SERIES_HEAD"));
+#endif
+       
        DECL_STATE_ENTRY_BOOL(pseudo_sub_cpu);
        DECL_STATE_ENTRY_INT32(sound_type);
        for(DEVICE* device = first_device; device; device = device->next_device) {
index 07357f6..dcfb662 100644 (file)
@@ -89,6 +89,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()
@@ -283,20 +284,44 @@ void VM::update_config()
 
 #define STATE_VERSION  4
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::YALKY_HEAD")));
+       DECL_STATE_ENTRY_1DARRAY(ram, sizeof(ram));
+       DECL_STATE_ENTRY_1DARRAY(vram, sizeof(vram));
+       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);
        }
-       state_fio->Fwrite(ram, sizeof(ram), 1);
-       state_fio->Fwrite(vram, sizeof(vram), 1);
+       //state_fio->Fwrite(ram, sizeof(ram), 1);
+       //state_fio->Fwrite(vram, sizeof(vram), 1);
 }
 
 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) {
@@ -304,8 +329,8 @@ bool VM::load_state(FILEIO* state_fio)
                        return false;
                }
        }
-       state_fio->Fread(ram, sizeof(ram), 1);
-       state_fio->Fread(vram, sizeof(vram), 1);
+       //state_fio->Fread(ram, sizeof(ram), 1);
+       //state_fio->Fread(vram, sizeof(vram), 1);
        return true;
 }
 
index 2a396a9..d62c3ca 100644 (file)
@@ -50,6 +50,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -65,6 +67,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -131,6 +134,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index 50d692e..25e369d 100644 (file)
@@ -119,6 +119,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
+       decl_state();
        for(int i = 0; i < MAX_DRIVE; i++) {
                fdc->set_drive_type(i, DRIVE_TYPE_2DD); // 1DD
                fdc->set_track_size(i, 6238);
@@ -295,10 +296,23 @@ void VM::update_config()
 
 #define STATE_VERSION  2
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::YIS_HEAD")));
+       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);
        }
@@ -306,7 +320,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) {
index dac8228..eecad93 100644 (file)
@@ -70,6 +70,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -96,6 +98,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -169,6 +172,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index d0e518e..f4750b5 100644 (file)
@@ -86,6 +86,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()
@@ -204,19 +205,42 @@ void VM::update_config()
 
 #define STATE_VERSION  2
 
+#include "../../statesub.h"
+
+void VM::decl_state(void)
+{
+
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::YS_6464A_HEAD")));
+       DECL_STATE_ENTRY_1DARRAY(ram, sizeof(ram));
+       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);
        }
-       state_fio->Fwrite(ram, sizeof(ram), 1);
+       //state_fio->Fwrite(ram, sizeof(ram), 1);
 }
 
 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) {
@@ -224,7 +248,7 @@ bool VM::load_state(FILEIO* state_fio)
                        return false;
                }
        }
-       state_fio->Fread(ram, sizeof(ram), 1);
+       //state_fio->Fread(ram, sizeof(ram), 1);
        return true;
 }
 
index ba49c9e..fda9fcf 100644 (file)
@@ -73,6 +73,8 @@ const struct {
        {582, 23, 28, 40},
 };
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -90,6 +92,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -142,6 +145,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
        
index c2626b3..5351a33 100644 (file)
@@ -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()
@@ -216,10 +217,27 @@ void VM::update_config()
 
 #define STATE_VERSION  2
 
+#include "../../statesub.h"
+
+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")));
+#else
+       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::Z80_TV_GAME_Z80PIO_HEAD")));
+#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 +245,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) {
index 340237e..864bee5 100644 (file)
@@ -46,6 +46,8 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
+class csp_state_utils;
+
 class EMU;
 class DEVICE;
 class EVENT;
@@ -65,6 +67,7 @@ class VM
 {
 protected:
        EMU* emu;
+       csp_state_utils* state_entry;
        
        // devices
        EVENT* event;
@@ -119,6 +122,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
+       void decl_state();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);