OSDN Git Service

[VM][STATE] Apply New framework to some VMs.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 21 Oct 2018 12:31:14 +0000 (21:31 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 21 Oct 2018 12:31:14 +0000 (21:31 +0900)
28 files changed:
source/src/vm/phc20/memory.cpp
source/src/vm/phc20/memory.h
source/src/vm/phc20/phc20.cpp
source/src/vm/phc20/phc20.h
source/src/vm/phc25/keyboard.cpp
source/src/vm/phc25/keyboard.h
source/src/vm/phc25/memory.cpp
source/src/vm/phc25/memory.h
source/src/vm/phc25/phc25.cpp
source/src/vm/phc25/phc25.h
source/src/vm/phc25/system.cpp
source/src/vm/phc25/system.h
source/src/vm/pv1000/joystick.cpp
source/src/vm/pv1000/joystick.h
source/src/vm/pv1000/psg.cpp
source/src/vm/pv1000/psg.h
source/src/vm/pv1000/pv1000.cpp
source/src/vm/pv1000/pv1000.h
source/src/vm/pv1000/vdp.cpp
source/src/vm/pv1000/vdp.h
source/src/vm/pv2000/cmt.cpp
source/src/vm/pv2000/cmt.h
source/src/vm/pv2000/keyboard.cpp
source/src/vm/pv2000/keyboard.h
source/src/vm/pv2000/printer.cpp
source/src/vm/pv2000/printer.h
source/src/vm/pv2000/pv2000.cpp
source/src/vm/pv2000/pv2000.h

index fec8e53..558480a 100644 (file)
@@ -7,7 +7,7 @@
        [ memory ]
 */
 
-#include "memory.h"
+#include "./memory.h"
 #include "../datarec.h"
 
 static const uint8_t key_map[9][8] = {
@@ -38,7 +38,7 @@ static const uint8_t key_map[9][8] = {
        } \
 }
 
-void MEMORY::initialize()
+void PHC20_MEMORY::initialize()
 {
        memset(rom, 0xff, sizeof(rom));
        memset(rdmy, 0xff, sizeof(rdmy));
@@ -64,7 +64,7 @@ void MEMORY::initialize()
        register_frame_event(this);
 }
 
-void MEMORY::reset()
+void PHC20_MEMORY::reset()
 {
        memset(ram, 0, sizeof(ram));
        memset(vram, 0, sizeof(vram));
@@ -73,7 +73,7 @@ void MEMORY::reset()
        sysport = 0;
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PHC20_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
        if((0x3000 <= addr && addr < 0x4000) || 0x4400 <= addr) {
@@ -104,7 +104,7 @@ void MEMORY::write_data8(uint32_t addr, uint32_t data)
        wbank[addr >> 10][addr & 0x3ff] = data;
 }
 
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PHC20_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
        if((0x3000 <= addr && addr < 0x4000) || 0x4400 <= addr) {
@@ -134,7 +134,7 @@ uint32_t MEMORY::read_data8(uint32_t addr)
        return rbank[addr >> 10][addr & 0x3ff];
 }
 
-void MEMORY::event_frame()
+void PHC20_MEMORY::event_frame()
 {
        memset(status, 0, sizeof(status));
        
@@ -147,7 +147,7 @@ void MEMORY::event_frame()
        }
 }
 
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void PHC20_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(data & mask) {
                sysport |= mask;
@@ -158,57 +158,7 @@ void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
-       DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
-       DECL_STATE_ENTRY_UINT8(sysport);
-       
-       leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->Fwrite(ram, sizeof(ram), 1);
-//     state_fio->Fwrite(vram, sizeof(vram), 1);
-//     state_fio->Fwrite(status, sizeof(status), 1);
-//     state_fio->FputUint8(sysport);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     state_fio->Fread(ram, sizeof(ram), 1);
-//     state_fio->Fread(vram, sizeof(vram), 1);
-//     state_fio->Fread(status, sizeof(status), 1);
-//     sysport = state_fio->FgetUint8();
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PHC20_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index d93b411..e4d3b3f 100644 (file)
@@ -7,8 +7,8 @@
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PHC20_MEMORY_H_
+#define _PHC20_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -16,7 +16,7 @@
 
 #define SIG_MEMORY_SYSPORT     0
 
-class MEMORY : public DEVICE
+class PHC20_MEMORY : public DEVICE
 {
 private:
        DEVICE *d_drec;
@@ -35,11 +35,11 @@ private:
        uint8_t sysport;
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       PHC20_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~PHC20_MEMORY() {}
        
        // common functions
        void initialize();
@@ -48,9 +48,7 @@ public:
        uint32_t read_data8(uint32_t addr);
        void event_frame();
        void write_signal(int id, uint32_t data, uint32_t mask);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
        void set_context_drec(DEVICE* device)
index d5f0131..c1a53a6 100644 (file)
@@ -21,7 +21,7 @@
 #include "../debugger.h"
 #endif
 
-#include "memory.h"
+#include "./memory.h"
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -41,7 +41,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        drec->set_context_noise_fast(new NOISE(this, emu));
        vdp = new MC6847(this, emu);
        cpu = new Z80(this, emu);
-       memory = new MEMORY(this, emu);
+       memory = new PHC20_MEMORY(this, emu);
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(drec);
@@ -77,7 +77,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
-       decl_state();
 }
 
 VM::~VM()
@@ -260,71 +259,37 @@ void VM::update_config()
 
 #define STATE_VERSION  3
 
-#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::PHC_20_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);
-       
-       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) {
-       //      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;
-               }
-       }
-       return true;
-}
-
 bool VM::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               const char *name = typeid(*device).name() + 6; // skip "class "
+       for(DEVICE* device = first_device; device; device = device->next_device) {
+               // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+               // const char *name = typeid(*device).name();
+               //       But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+               const char *name = device->get_device_name();
                int len = strlen(name);
                
                if(!state_fio->StateCheckInt32(len)) {
+                       if(loading) {
+                               printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
                        return false;
                }
                if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
+                       if(loading) {
+                               printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
+                       return false;
+               }
                if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
+                       if(loading) {
+                               printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+                       }
+                       return false;
+               }
+       }
+       // Machine specified.
        return true;
 }
index 73232e0..db24352 100644 (file)
@@ -55,7 +55,7 @@ class DATAREC;
 class MC6847;
 class Z80;
 
-class MEMORY;
+class PHC20_MEMORY;
 
 class VM : public VM_TEMPLATE
 {
@@ -70,7 +70,7 @@ protected:
        MC6847* vdp;
        Z80* cpu;
        
-       MEMORY* memory;
+       PHC20_MEMORY* memory;
        
 public:
        // ----------------------------------------
@@ -122,9 +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);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // ----------------------------------------
        // for each device
index c9547ca..17574ab 100644 (file)
@@ -120,57 +120,6 @@ void KEYBOARD::event_frame()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-#ifdef _MAP1010
-       DECL_STATE_ENTRY_INT32(kana_pressed);
-#else
-       DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
-#endif
-       leave_decl_state();
-}
-
-void KEYBOARD::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-//     
-//#ifdef _MAP1010
-//     state_fio->FputInt32(kana_pressed);
-//#else
-//     state_fio->Fwrite(status, sizeof(status), 1);
-//#endif
-}
-
-bool KEYBOARD::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//#ifdef _MAP1010
-//     kana_pressed = state_fio->FgetInt32();
-//#else
-//     state_fio->Fread(status, sizeof(status), 1);
-//#endif
-       return true;
-}
-
 bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 281f176..c9c8a0c 100644 (file)
@@ -38,9 +38,7 @@ public:
        void reset();
        uint32_t read_io8(uint32_t addr);
        void event_frame();
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
 };
 
 #endif
index 966f9d6..7ae17e6 100644 (file)
@@ -8,7 +8,7 @@
        [ memory ]
 */
 
-#include "memory.h"
+#include "./memory.h"
 
 #define SET_BANK(s, e, w, r) { \
        int sb = (s) >> 11, eb = (e) >> 11; \
@@ -26,7 +26,7 @@
        } \
 }
 
-void MEMORY::initialize()
+void PHC25_MEMORY::initialize()
 {
        memset(rom, 0xff, sizeof(rom));
        memset(rdmy, 0xff, sizeof(rdmy));
@@ -53,13 +53,13 @@ void MEMORY::initialize()
 #endif
 }
 
-void MEMORY::reset()
+void PHC25_MEMORY::reset()
 {
        memset(ram, 0, sizeof(ram));
        memset(vram, 0, sizeof(vram));
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void PHC25_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
 #ifdef _MAP1010
@@ -71,7 +71,7 @@ void MEMORY::write_data8(uint32_t addr, uint32_t data)
        wbank[addr >> 11][addr & 0x7ff] = data;
 }
 
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t PHC25_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
 #ifdef _MAP1010
@@ -87,51 +87,7 @@ uint32_t MEMORY::read_data8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
-       
-       leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->Fwrite(ram, sizeof(ram), 1);
-//     state_fio->Fwrite(vram, sizeof(vram), 1);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     state_fio->Fread(ram, sizeof(ram), 1);
-//     state_fio->Fread(vram, sizeof(vram), 1);
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool PHC25_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 23ba8a7..1a51166 100644 (file)
@@ -8,14 +8,14 @@
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _PHC25_MEMORY_H_
+#define _PHC25_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
 #include "../device.h"
 
-class MEMORY : public DEVICE
+class PHC25_MEMORY : public DEVICE
 {
 private:
        DEVICE *d_kbd;
@@ -34,20 +34,18 @@ private:
        uint8_t* rbank[32];
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       PHC25_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~PHC25_MEMORY() {}
        
        // common functions
        void initialize();
        void reset();
        void write_data8(uint32_t addr, uint32_t data);
        uint32_t read_data8(uint32_t addr);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
        void set_context_keyboard(DEVICE* device)
index 9d33ded..0987d12 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "joystick.h"
 #include "keyboard.h"
-#include "memory.h"
-#include "system.h"
+#include "./memory.h"
+#include "./system.h"
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -57,8 +57,8 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        
        joystick = new JOYSTICK(this, emu);
        keyboard = new KEYBOARD(this, emu);
-       memory = new MEMORY(this, emu);
-       system = new SYSTEM(this, emu);
+       memory = new PHC25_MEMORY(this, emu);
+       system = new PHC25_SYSTEM(this, emu);
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(psg);
@@ -110,7 +110,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
-       decl_state();
 }
 
 VM::~VM()
@@ -298,76 +297,37 @@ void VM::update_config()
 
 #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)
-{
-#if defined(_PHC25)
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_25_HEAD")), csp_logger);
-#elif defined(_MAP1010)
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MAP_1010_HEAD")), csp_logger);
-#else
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PHC_25_SERIES_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);
-       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) {
-       //      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;
-               }
-       }
-       return true;
-}
-
 bool VM::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               const char *name = typeid(*device).name() + 6; // skip "class "
+       for(DEVICE* device = first_device; device; device = device->next_device) {
+               // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+               // const char *name = typeid(*device).name();
+               //       But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+               const char *name = device->get_device_name();
                int len = strlen(name);
                
                if(!state_fio->StateCheckInt32(len)) {
+                       if(loading) {
+                               printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
                        return false;
                }
                if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
+                       if(loading) {
+                               printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
+                       return false;
+               }
                if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
+                       if(loading) {
+                               printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+                       }
+                       return false;
+               }
+       }
+       // Machine specified.
        return true;
 }
index 3e19cc4..72f8698 100644 (file)
@@ -71,8 +71,8 @@ class Z80;
 
 class JOYSTICK;
 class KEYBOARD;
-class MEMORY;
-class SYSTEM;
+class PHC25_MEMORY;
+class PHC25_SYSTEM;
 
 class VM : public VM_TEMPLATE
 {
@@ -93,8 +93,8 @@ protected:
        
        JOYSTICK* joystick;
        KEYBOARD* keyboard;
-       MEMORY* memory;
-       SYSTEM* system;
+       PHC25_MEMORY* memory;
+       PHC25_SYSTEM* system;
        
 public:
        // ----------------------------------------
@@ -146,9 +146,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // ----------------------------------------
        // for each device
index 79d2569..2a6e473 100644 (file)
@@ -8,21 +8,21 @@
        [ system port ]
 */
 
-#include "system.h"
+#include "./system.h"
 #include "../datarec.h"
 #include "../mc6847.h"
 
-void SYSTEM::initialize()
+void PHC25_SYSTEM::initialize()
 {
        sysport = 0;
 }
 
-void SYSTEM::reset()
+void PHC25_SYSTEM::reset()
 {
        d_vdp->write_signal(SIG_MC6847_INTEXT, 1, 1);
 }
 
-void SYSTEM::write_io8(uint32_t addr, uint32_t data)
+void PHC25_SYSTEM::write_io8(uint32_t addr, uint32_t data)
 {
        d_drec->write_signal(SIG_DATAREC_MIC, data, 0x01);
        d_drec->write_signal(SIG_DATAREC_REMOTE, ~data, 0x02);
@@ -33,12 +33,12 @@ void SYSTEM::write_io8(uint32_t addr, uint32_t data)
        d_vdp->write_signal(SIG_MC6847_AG, data, 0x80);
 }
 
-uint32_t SYSTEM::read_io8(uint32_t addr)
+uint32_t PHC25_SYSTEM::read_io8(uint32_t addr)
 {
        return sysport;
 }
 
-void SYSTEM::write_signal(int id, uint32_t data, uint32_t mask)
+void PHC25_SYSTEM::write_signal(int id, uint32_t data, uint32_t mask)
 {
        sysport = (sysport & ~mask) | (data & mask);
 }
@@ -47,7 +47,7 @@ void SYSTEM::write_signal(int id, uint32_t data, uint32_t mask)
 
 #include "../../statesub.h"
 
-void SYSTEM::decl_state()
+void PHC25_SYSTEM::decl_state()
 {
        enter_decl_state(STATE_VERSION);
 
@@ -56,7 +56,7 @@ void SYSTEM::decl_state()
        leave_decl_state();
 }
 
-void SYSTEM::save_state(FILEIO* state_fio)
+void PHC25_SYSTEM::save_state(FILEIO* state_fio)
 {
        if(state_entry != NULL) {
                state_entry->save_state(state_fio);
@@ -67,7 +67,7 @@ void SYSTEM::save_state(FILEIO* state_fio)
 //     state_fio->FputUint8(sysport);
 }
 
-bool SYSTEM::load_state(FILEIO* state_fio)
+bool PHC25_SYSTEM::load_state(FILEIO* state_fio)
 {
        bool mb = false;
        if(state_entry != NULL) {
@@ -86,7 +86,7 @@ bool SYSTEM::load_state(FILEIO* state_fio)
        return true;
 }
 
-bool SYSTEM::process_state(FILEIO* state_fio, bool loading)
+bool PHC25_SYSTEM::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 19196cd..bf2cdc5 100644 (file)
@@ -8,8 +8,8 @@
        [ system port ]
 */
 
-#ifndef _SYSTEM_H_
-#define _SYSTEM_H_
+#ifndef _PHC25_SYSTEM_H_
+#define _PHC25_SYSTEM_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -17,7 +17,7 @@
 
 #define SIG_SYSTEM_PORT        0
 
-class SYSTEM : public DEVICE
+class PHC25_SYSTEM : public DEVICE
 {
 private:
        DEVICE *d_drec, *d_vdp;
@@ -25,11 +25,11 @@ private:
        uint8_t sysport;
        
 public:
-       SYSTEM(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       PHC25_SYSTEM(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("System I/O"));
        }
-       ~SYSTEM() {}
+       ~PHC25_SYSTEM() {}
        
        // common functions
        void initialize();
@@ -37,9 +37,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
        void write_signal(int id, uint32_t data, uint32_t mask);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
        void set_context_drec(DEVICE* device)
index fac275a..20d94f0 100644 (file)
@@ -7,7 +7,7 @@
        [ joystick ]
 */
 
-#include "joystick.h"
+#include "./joystick.h"
 
 void JOYSTICK::initialize()
 {
@@ -86,50 +86,6 @@ void JOYSTICK::event_frame()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void JOYSTICK::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_UINT8(column);
-       DECL_STATE_ENTRY_UINT8(status);
-       
-       leave_decl_state();
-}
-
-void JOYSTICK::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->FputUint8(column);
-//     state_fio->FputUint8(status);
-}
-
-bool JOYSTICK::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     column = state_fio->FgetUint8();
-//     status = state_fio->FgetUint8();
-       return true;
-}
-
 bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index de20c3b..b3e2716 100644 (file)
@@ -35,9 +35,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
        void event_frame();
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
 };
 
 #endif
index 120880c..9df6995 100644 (file)
@@ -8,7 +8,7 @@
 */
 
 #include <math.h>
-#include "psg.h"
+#include "./psg.h"
 
 #define PSG_CLOCK
 #define PSG_VOLUME     8192
@@ -62,51 +62,6 @@ void PSG::set_volume(int ch, int decibel_l, int decibel_r)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void PSG::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_INT32_STRIDE((ch[0].period), 3, sizeof(ch[0]));
-       
-       leave_decl_state();
-}
-
-void PSG::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     for(int i = 0; i < 3; i++) {
-//             state_fio->FputInt32(ch[i].period);
-//     }
-}
-
-bool PSG::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     for(int i = 0; i < 3; i++) {
-//             ch[i].period = state_fio->FgetInt32();
-//     }
-       return true;
-}
-
 bool PSG::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index b4a58a0..4be84dc 100644 (file)
@@ -38,9 +38,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        void mix(int32_t* buffer, int cnt);
        void set_volume(int ch, int decibel_l, int decibel_r);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique function
        void initialize_sound(int rate);
index 9c06951..d54a5bb 100644 (file)
@@ -78,7 +78,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
-       decl_state();
        inserted = false;
 }
 
@@ -220,77 +219,39 @@ void VM::update_config()
 
 #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)
-{
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PV_1000_HEAD")), csp_logger);
-
-       DECL_STATE_ENTRY_1D_ARRAY(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);
-       
-       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);
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
-       //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;
-               }
-       }
-       //state_fio->Fread(mem, sizeof(mem), 1);
-       //inserted = state_fio->FgetBool();
-       return true;
-}
 
 bool VM::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               const char *name = typeid(*device).name() + 6; // skip "class "
+       for(DEVICE* device = first_device; device; device = device->next_device) {
+               // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+               // const char *name = typeid(*device).name();
+               //       But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+               const char *name = device->get_device_name();
                int len = strlen(name);
                
                if(!state_fio->StateCheckInt32(len)) {
+                       if(loading) {
+                               printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
                        return false;
                }
                if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
+                       if(loading) {
+                               printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
+                       return false;
+               }
                if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
+                       if(loading) {
+                               printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+                       }
+                       return false;
+               }
+       }
+       // Machine specified.
        state_fio->StateBuffer(mem, sizeof(mem), 1);
        state_fio->StateBool(inserted);
        return true;
index 118f937..c6c72c9 100644 (file)
@@ -131,9 +131,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // ----------------------------------------
        // for each device
index 64f0fcc..7f49165 100644 (file)
@@ -130,63 +130,6 @@ void VDP::draw_pcg(int x8, int y8, uint16_t top)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void VDP::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_INT32(tmp_vram_size);    // (int)(vram - base);
-       DECL_STATE_ENTRY_INT32(tmp_pcg_size);     // (int)(pcg - base);
-       DECL_STATE_ENTRY_INT32(tmp_pattern_size); // (int)(pattern - base);
-       DECL_STATE_ENTRY_BOOL(force_pattern);
-       
-       leave_decl_state();
-}
-
-void VDP::save_state(FILEIO* state_fio)
-{
-       tmp_vram_size = (int)(vram - base);
-       tmp_pcg_size = (int)(pcg - base);
-       tmp_pattern_size = (int)(pattern - base);
-
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->FputInt32((int)(vram - base));
-//     state_fio->FputInt32((int)(pcg - base));
-//     state_fio->FputInt32((int)(pattern - base));
-//     state_fio->FputBool(force_pattern);
-}
-
-bool VDP::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     vram = base + state_fio->FgetInt32();
-//     pcg = base + state_fio->FgetInt32();
-//     pattern = base + state_fio->FgetInt32();
-//     force_pattern = state_fio->FgetBool();
-       vram = base + tmp_vram_size;
-       pcg = base + tmp_pcg_size;
-       pattern = base + tmp_pattern_size;
-       return true;
-}
-
 bool VDP::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 642e7be..16427cc 100644 (file)
@@ -46,9 +46,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        void event_callback(int event_id, int err);
        void event_vline(int v, int clock);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
        void set_context_cpu(DEVICE* device)
index 054c60e..5840d2d 100644 (file)
@@ -131,62 +131,6 @@ void CMT::close_tape()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void CMT::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_INT32(bufcnt);
-       DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
-       DECL_STATE_ENTRY_BOOL(play);
-       DECL_STATE_ENTRY_BOOL(rec);
-       DECL_STATE_ENTRY_UINT8(start);
-       DECL_STATE_ENTRY_UINT8(bit);
-
-       leave_decl_state();
-}
-
-void CMT::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->FputInt32(bufcnt);
-//     state_fio->Fwrite(buffer, sizeof(buffer), 1);
-//     state_fio->FputBool(play);
-//     state_fio->FputBool(rec);
-//     state_fio->FputUint8(start);
-//     state_fio->FputUint8(bit);
-}
-
-bool CMT::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     bufcnt = state_fio->FgetInt32();
-//     state_fio->Fread(buffer, sizeof(buffer), 1);
-//     play = state_fio->FgetBool();
-//     rec = state_fio->FgetBool();
-//     start = state_fio->FgetUint8();
-//     bit = state_fio->FgetUint8();
-       return true;
-}
-
 bool CMT::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index ded5ab3..7f0d7ed 100644 (file)
@@ -40,9 +40,7 @@ public:
        void reset();
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
        void play_tape(const _TCHAR* file_path);
index bed36e7..9e7e713 100644 (file)
@@ -110,55 +110,6 @@ void KEYBOARD::key_up(int code)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_1D_ARRAY(key_stat, sizeof(key_stat));
-       DECL_STATE_ENTRY_INT32(key_no);
-       DECL_STATE_ENTRY_BOOL(intr_enb);
-
-       leave_decl_state();
-}
-
-void KEYBOARD::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     if(state_entry != NULL) {
-//             state_entry->save_state(state_fio);
-//     }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
-//     state_fio->FputInt32(key_no);
-//     state_fio->FputBool(intr_enb);
-}
-
-bool KEYBOARD::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     state_fio->Fread(key_stat, sizeof(key_stat), 1);
-//     key_no = state_fio->FgetInt32();
-//     intr_enb = state_fio->FgetBool();
-       return true;
-}
 
 bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
 {
index 0c6c08e..522c0fd 100644 (file)
@@ -36,9 +36,7 @@ public:
        void reset();
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
        void set_context_cpu(DEVICE* device)
index a463c75..c7d3dcd 100644 (file)
@@ -40,56 +40,6 @@ uint32_t PRINTER::read_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void PRINTER::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_UINT8(out);
-       DECL_STATE_ENTRY_UINT8(ctrl0);
-       DECL_STATE_ENTRY_UINT8(ctrl1);
-       DECL_STATE_ENTRY_BOOL(busy);
-
-       leave_decl_state();
-}
-
-void PRINTER::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->FputUint8(out);
-//     state_fio->FputUint8(ctrl0);
-//     state_fio->FputUint8(ctrl1);
-//     state_fio->FputBool(busy);
-}
-
-bool PRINTER::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
-       }
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     out = state_fio->FgetUint8();
-//     ctrl0 = state_fio->FgetUint8();
-//     ctrl1 = state_fio->FgetUint8();
-//     busy = state_fio->FgetBool();
-       return true;
-}
-
 bool PRINTER::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 3a60de4..7ad0914 100644 (file)
@@ -31,9 +31,7 @@ public:
        void initialize();
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
 };
 
 #endif
index 886e5d8..4d25760 100644 (file)
@@ -94,7 +94,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
-       decl_state();
        inserted = false;
 }
 
@@ -270,80 +269,38 @@ void VM::update_config()
 
 #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)
-{
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::PV_2000_HEAD")), csp_logger);
-
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_1D_ARRAY(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);
-       
-       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);
-}
-
-bool VM::load_state(FILEIO* state_fio)
-{
-       //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;
-               }
-       }
-       //state_fio->Fread(ram, sizeof(ram), 1);
-       //state_fio->Fread(ext, sizeof(ext), 1);
-       //inserted = state_fio->FgetBool();
-       return true;
-}
-
 bool VM::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               const char *name = typeid(*device).name() + 6; // skip "class "
+       for(DEVICE* device = first_device; device; device = device->next_device) {
+               // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+               // const char *name = typeid(*device).name();
+               //       But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+               const char *name = device->get_device_name();
                int len = strlen(name);
                
                if(!state_fio->StateCheckInt32(len)) {
+                       if(loading) {
+                               printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
                        return false;
                }
                if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
+                       if(loading) {
+                               printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+                       }
+                       return false;
+               }
                if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
+                       if(loading) {
+                               printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+                       }
+                       return false;
+               }
+       }
+       // Machine specified.
        state_fio->StateBuffer(ram, sizeof(ram), 1);
        state_fio->StateBuffer(ext, sizeof(ext), 1);
        state_fio->StateBool(inserted);
index 939f285..219b183 100644 (file)
@@ -140,9 +140,7 @@ public:
        bool is_frame_skippable();
        
        void update_config();
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // ----------------------------------------
        // for each device