OSDN Git Service

[VM][I286] Save cpustate without StateBuffer().
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 18 Oct 2018 09:29:50 +0000 (18:29 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 18 Oct 2018 09:29:50 +0000 (18:29 +0900)
[VM] Apply new state framework to some VMs.

91 files changed:
source/src/vm/fp1100/fp1100.cpp
source/src/vm/fp1100/fp1100.h
source/src/vm/fp1100/main.cpp
source/src/vm/fp1100/main.h
source/src/vm/fp1100/rampack.cpp
source/src/vm/fp1100/rampack.h
source/src/vm/fp1100/sub.cpp
source/src/vm/fp1100/sub.h
source/src/vm/fp200/fp200.cpp
source/src/vm/fp200/fp200.h
source/src/vm/fp200/io.cpp
source/src/vm/fp200/io.h
source/src/vm/hc20/hc20.cpp
source/src/vm/hc20/hc20.h
source/src/vm/hc20/memory.cpp
source/src/vm/hc20/memory.h
source/src/vm/hc40/hc40.cpp
source/src/vm/hc40/hc40.h
source/src/vm/hc40/io.cpp
source/src/vm/hc40/io.h
source/src/vm/hc40/memory.cpp
source/src/vm/hc40/memory.h
source/src/vm/hc80/hc80.cpp
source/src/vm/hc80/hc80.h
source/src/vm/hc80/io.cpp
source/src/vm/hc80/io.h
source/src/vm/hc80/memory.cpp
source/src/vm/hc80/memory.h
source/src/vm/i286.cpp
source/src/vm/i286.h
source/src/vm/j3100/j3100.cpp
source/src/vm/jr100/jr100.cpp
source/src/vm/jr100/jr100.h
source/src/vm/jr100/memory.cpp
source/src/vm/jr100/memory.h
source/src/vm/jr800/io.cpp
source/src/vm/jr800/io.h
source/src/vm/jr800/jr800.cpp
source/src/vm/jr800/jr800.h
source/src/vm/jx/display.cpp
source/src/vm/jx/floppy.cpp
source/src/vm/jx/i286.cpp
source/src/vm/jx/i286.h
source/src/vm/jx/jx.cpp
source/src/vm/jx/jx.h
source/src/vm/jx/keyboard.cpp
source/src/vm/m5/cmt.cpp
source/src/vm/m5/cmt.h
source/src/vm/m5/m5.cpp
source/src/vm/m5/m5.h
source/src/vm/msx/memory_ex.h
source/src/vm/multi8/cmt.cpp
source/src/vm/multi8/cmt.h
source/src/vm/multi8/display.cpp
source/src/vm/multi8/display.h
source/src/vm/multi8/floppy.cpp
source/src/vm/multi8/floppy.h
source/src/vm/multi8/kanji.cpp
source/src/vm/multi8/kanji.h
source/src/vm/multi8/keyboard.cpp
source/src/vm/multi8/keyboard.h
source/src/vm/multi8/memory.cpp
source/src/vm/multi8/memory.h
source/src/vm/multi8/multi8.cpp
source/src/vm/multi8/multi8.h
source/src/vm/mz700/cmos.cpp
source/src/vm/mz700/cmos.h
source/src/vm/mz700/emm.cpp
source/src/vm/mz700/emm.h
source/src/vm/mz700/floppy.cpp
source/src/vm/mz700/floppy.h
source/src/vm/mz700/kanji.cpp
source/src/vm/mz700/kanji.h
source/src/vm/mz700/keyboard.cpp
source/src/vm/mz700/keyboard.h
source/src/vm/mz700/memory.cpp
source/src/vm/mz700/memory.h
source/src/vm/mz700/mz700.cpp
source/src/vm/mz700/mz700.h
source/src/vm/mz700/quickdisk.cpp
source/src/vm/mz700/quickdisk.h
source/src/vm/mz700/ramfile.cpp
source/src/vm/mz700/ramfile.h
source/src/vm/mz80k/keyboard.cpp
source/src/vm/mz80k/keyboard.h
source/src/vm/mz80k/memory.cpp
source/src/vm/mz80k/memory.h
source/src/vm/mz80k/mz80k.cpp
source/src/vm/mz80k/mz80k.h
source/src/vm/mz80k/printer.cpp
source/src/vm/mz80k/printer.h

index 3418429..d194c49 100644 (file)
@@ -136,7 +136,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
-       decl_state();
        for(int i = 0; i < 4; i++) {
                fdc->set_drive_type(i, DRIVE_TYPE_2D);
        }
@@ -382,69 +381,36 @@ 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)
-{
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::FP_1100_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;
+               }
+       }
        return true;
 }
index 17678ab..cf0d9e4 100644 (file)
@@ -165,9 +165,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 ba1ee08..a78c400 100644 (file)
@@ -248,73 +248,6 @@ void MAIN::notify_intr_ei()
 
 #define STATE_VERSION  3
 
-#include "../../statesub.h"
-
-void MAIN::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_UINT8(comm_data);
-       DECL_STATE_ENTRY_BOOL(rom_sel);
-       DECL_STATE_ENTRY_UINT8(slot_sel);
-       DECL_STATE_ENTRY_1D_ARRAY(slot_exp, sizeof(slot_exp));
-       DECL_STATE_ENTRY_UINT8(intr_mask);
-       DECL_STATE_ENTRY_UINT8(intr_request);
-       DECL_STATE_ENTRY_UINT8(intr_in_service);
-
-       leave_decl_state();
-}
-       
-void MAIN::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->FputUint8(comm_data);
-//     state_fio->FputBool(rom_sel);
-//     state_fio->FputUint8(slot_sel);
-//     state_fio->Fwrite(slot_exp, sizeof(slot_exp), 1);
-//     state_fio->FputUint8(intr_mask);
-//     state_fio->FputUint8(intr_request);
-//     state_fio->FputUint8(intr_in_service);
-}
-
-bool MAIN::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);
-//     comm_data = state_fio->FgetUint8();
-//     rom_sel = state_fio->FgetBool();
-//     slot_sel = state_fio->FgetUint8();
-//     state_fio->Fread(slot_exp, sizeof(slot_exp), 1);
-//     intr_mask = state_fio->FgetUint8();
-//     intr_request = state_fio->FgetUint8();
-//     intr_in_service = state_fio->FgetUint8();
-       
-       // post process
-       update_memory_map();
-       return true;
-}
-
 bool MAIN::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 3d38757..04c34fe 100644 (file)
@@ -78,9 +78,7 @@ public:
        uint32_t get_intr_ack();
        void notify_intr_reti();
        void notify_intr_ei();
-       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 fc0d2d6..c69fdee 100644 (file)
@@ -56,52 +56,6 @@ uint32_t RAMPACK::read_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void RAMPACK::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_BOOL(modified);
-       
-       leave_decl_state();
-}
-
-void RAMPACK::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->FputBool(modified);
-}
-
-bool RAMPACK::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);
-//     modified = state_fio->FgetBool();
-       return true;
-}
-
 bool RAMPACK::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 5c84461..bd4f434 100644 (file)
@@ -32,9 +32,7 @@ public:
        void release();
        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 variable
        int index;
index 7947865..7171ab4 100644 (file)
@@ -524,169 +524,62 @@ void SUB::draw_screen()
        }
 }
 
-#define STATE_VERSION  2
-
-#include "../../statesub.h"
-
-#define DECL_STATE_ENTRY_74LS74(foo) {                 \
-               DECL_STATE_ENTRY_BOOL((foo.in_d));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_ck));             \
-               DECL_STATE_ENTRY_BOOL((foo.in_s));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_r));              \
-               DECL_STATE_ENTRY_BOOL((foo.out_q));             \
-               DECL_STATE_ENTRY_BOOL((foo.out_nq));    \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_ck));    \
-       }
 
-#define DECL_STATE_ENTRY_74LS151(foo) { \
-       DECL_STATE_ENTRY_BOOL((foo.in_d0)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d1)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d2)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d3)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d4)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d5)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d6)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d7)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_a)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_b)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_c)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_s));      \
-       DECL_STATE_ENTRY_BOOL((foo.out_y)); \
-       DECL_STATE_ENTRY_BOOL((foo.out_ny));            \
+#define PROCESS_STATE_74LS74(foo)                      \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_d);                 \
+               state_fio->StateBool(foo.in_ck);                \
+               state_fio->StateBool(foo.in_s);                 \
+               state_fio->StateBool(foo.in_r);                 \
+               state_fio->StateBool(foo.out_q);                \
+               state_fio->StateBool(foo.out_nq);               \
+               state_fio->StateBool(foo.tmp_ck);               \
        }
 
-#define DECL_STATE_ENTRY_74LS93(foo) {                 \
-               DECL_STATE_ENTRY_BOOL((foo.in_a));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_b));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_rc1));    \
-               DECL_STATE_ENTRY_BOOL((foo.in_rc2));    \
-               DECL_STATE_ENTRY_BOOL((foo.out_qa));    \
-               DECL_STATE_ENTRY_BOOL((foo.out_qb));    \
-               DECL_STATE_ENTRY_BOOL((foo.out_qc));    \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_a));             \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_b));             \
-               DECL_STATE_ENTRY_UINT8((foo.counter_a));        \
-               DECL_STATE_ENTRY_UINT8((foo.counter_b));        \
+#define PROCESS_STATE_74LS151(foo)             \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_d0);                \
+               state_fio->StateBool(foo.in_d1);                \
+               state_fio->StateBool(foo.in_d2);                \
+               state_fio->StateBool(foo.in_d3);                \
+               state_fio->StateBool(foo.in_d4);                \
+               state_fio->StateBool(foo.in_d5);                \
+               state_fio->StateBool(foo.in_d6);                \
+               state_fio->StateBool(foo.in_d7);                \
+               state_fio->StateBool(foo.in_a);                 \
+               state_fio->StateBool(foo.in_b);                 \
+               state_fio->StateBool(foo.in_c);                 \
+               state_fio->StateBool(foo.in_s);                 \
+               state_fio->StateBool(foo.out_y);                \
+               state_fio->StateBool(foo.out_ny);               \
        }
 
-#define DECL_STATE_ENTRY_TC4024BP(foo) {                       \
-               DECL_STATE_ENTRY_BOOL((foo.in_ck));                     \
-               DECL_STATE_ENTRY_BOOL((foo.in_clr));            \
-               DECL_STATE_ENTRY_BOOL((foo.out_q5));            \
-               DECL_STATE_ENTRY_BOOL((foo.out_q6));            \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_ck));            \
-               DECL_STATE_ENTRY_UINT8((foo.counter));          \
-       }
-
-void SUB::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_1D_ARRAY(vram_b, sizeof(vram_b));
-       DECL_STATE_ENTRY_1D_ARRAY(vram_r, sizeof(vram_r));
-       DECL_STATE_ENTRY_1D_ARRAY(vram_g, sizeof(vram_g));
-       DECL_STATE_ENTRY_UINT8(pa);
-       DECL_STATE_ENTRY_UINT8(pb);
-       DECL_STATE_ENTRY_UINT8(pc);
-       DECL_STATE_ENTRY_UINT8(comm_data);
-       DECL_STATE_ENTRY_BOOL(so);
-       DECL_STATE_ENTRY_UINT8(clock);
-       DECL_STATE_ENTRY_74LS74(b16_1);
-       DECL_STATE_ENTRY_74LS74(b16_2);
-       DECL_STATE_ENTRY_74LS74(g21_1);
-       DECL_STATE_ENTRY_74LS74(g21_2);
-
-       DECL_STATE_ENTRY_74LS151(c15);
-       DECL_STATE_ENTRY_74LS93(c16);
-
-       DECL_STATE_ENTRY_TC4024BP(f21);
-
-       DECL_STATE_ENTRY_UINT8(key_sel);
-       DECL_STATE_ENTRY_UINT8(key_data);
-       DECL_STATE_ENTRY_UINT8(color_reg);
-       DECL_STATE_ENTRY_BOOL(hsync);
-       DECL_STATE_ENTRY_BOOL(wait);
-       DECL_STATE_ENTRY_UINT8(cblink);
-
-       leave_decl_state();
-}
-
-void SUB::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
+#define PROCESS_STATE_74LS93(foo)                      \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_a);                 \
+               state_fio->StateBool(foo.in_b);                 \
+               state_fio->StateBool(foo.in_rc1);               \
+               state_fio->StateBool(foo.in_rc2);               \
+               state_fio->StateBool(foo.out_qa);               \
+               state_fio->StateBool(foo.out_qb);               \
+               state_fio->StateBool(foo.out_qc);               \
+               state_fio->StateBool(foo.tmp_a);                \
+               state_fio->StateBool(foo.tmp_b);                \
+               state_fio->StateUint8(foo.counter_a);   \
+               state_fio->StateUint8(foo.counter_b);   \
        }
 
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->Fwrite(ram, sizeof(ram), 1);
-//     state_fio->Fwrite(vram_b, sizeof(vram_b), 1);
-//     state_fio->Fwrite(vram_r, sizeof(vram_r), 1);
-//     state_fio->Fwrite(vram_g, sizeof(vram_g), 1);
-//     state_fio->FputUint8(pa);
-//     state_fio->FputUint8(pb);
-//     state_fio->FputUint8(pc);
-//     state_fio->FputUint8(comm_data);
-//     state_fio->FputBool(so);
-//     state_fio->FputUint8(clock);
-//     state_fio->Fwrite(&b16_1, sizeof(b16_1), 1);
-//     state_fio->Fwrite(&b16_2, sizeof(b16_2), 1);
-//     state_fio->Fwrite(&g21_1, sizeof(g21_1), 1);
-//     state_fio->Fwrite(&g21_2, sizeof(g21_2), 1);
-//     state_fio->Fwrite(&c15, sizeof(c15), 1);
-//     state_fio->Fwrite(&c16, sizeof(c16), 1);
-//     state_fio->Fwrite(&f21, sizeof(f21), 1);
-//     state_fio->FputUint8(key_sel);
-//     state_fio->FputUint8(key_data);
-//     state_fio->FputUint8(color_reg);
-//     state_fio->FputBool(hsync);
-//     state_fio->FputBool(wait);
-//     state_fio->FputUint8(cblink);
-}
-
-bool SUB::load_state(FILEIO* state_fio)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
+#define PROCESS_STATE_4024(foo)                        \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_ck);                \
+               state_fio->StateBool(foo.in_clr);               \
+               state_fio->StateBool(foo.out_q5);               \
+               state_fio->StateBool(foo.out_q6);               \
+               state_fio->StateBool(foo.tmp_ck);               \
+               state_fio->StateUint8(foo.counter);             \
        }
 
-//     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_b, sizeof(vram_b), 1);
-//     state_fio->Fread(vram_r, sizeof(vram_r), 1);
-//     state_fio->Fread(vram_g, sizeof(vram_g), 1);
-//     pa = state_fio->FgetUint8();
-//     pb = state_fio->FgetUint8();
-//     pc = state_fio->FgetUint8();
-//     comm_data = state_fio->FgetUint8();
-//     so = state_fio->FgetBool();
-//     clock = state_fio->FgetUint8();
-//     state_fio->Fread(&b16_1, sizeof(b16_1), 1);
-//     state_fio->Fread(&b16_2, sizeof(b16_2), 1);
-//     state_fio->Fread(&g21_1, sizeof(g21_1), 1);
-//     state_fio->Fread(&g21_2, sizeof(g21_2), 1);
-//     state_fio->Fread(&c15, sizeof(c15), 1);
-//     state_fio->Fread(&c16, sizeof(c16), 1);
-//     state_fio->Fread(&f21, sizeof(f21), 1);
-//     key_sel = state_fio->FgetUint8();
-//     key_data = state_fio->FgetUint8();
-//     color_reg = state_fio->FgetUint8();
-//     hsync = state_fio->FgetBool();
-//     wait = state_fio->FgetBool();
-//     cblink = state_fio->FgetUint8();
-       return true;
-}
+#define STATE_VERSION  2
 
 bool SUB::process_state(FILEIO* state_fio, bool loading)
 {
@@ -706,13 +599,24 @@ bool SUB::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateUint8(comm_data);
        state_fio->StateBool(so);
        state_fio->StateUint8(clock);
-       state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
-       state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
-       state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
-       state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
-       state_fio->StateBuffer(&c15, sizeof(c15), 1);
-       state_fio->StateBuffer(&c16, sizeof(c16), 1);
-       state_fio->StateBuffer(&f21, sizeof(f21), 1);
+       //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
+       //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
+       //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
+       //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
+       PROCESS_STATE_74LS74(b16_1);
+       PROCESS_STATE_74LS74(b16_2);
+       PROCESS_STATE_74LS74(g21_1);
+       PROCESS_STATE_74LS74(g21_2);
+       
+       //state_fio->StateBuffer(&c15, sizeof(c15), 1);
+       PROCESS_STATE_74LS151(c15);
+       
+       //state_fio->StateBuffer(&c16, sizeof(c16), 1);
+       PROCESS_STATE_74LS93(c16);
+       
+       //state_fio->StateBuffer(&f21, sizeof(f21), 1);
+       PROCESS_STATE_4024(f21);
+       
        state_fio->StateUint8(key_sel);
        state_fio->StateUint8(key_data);
        state_fio->StateUint8(color_reg);
index 06d9234..7bc85fa 100644 (file)
@@ -184,9 +184,7 @@ public:
        void write_signal(int id, uint32_t data, uint32_t mask);
        void event_frame();
        void event_callback(int event_id, int err);
-       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 0474c70..1dd8c94 100644 (file)
@@ -22,7 +22,7 @@
 #include "../debugger.h"
 #endif
 
-#include "io.h"
+#include "./io.h"
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -44,7 +44,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        memory = new MEMORY(this, emu);
        rtc = new RP5C01(this, emu);
        
-       io = new IO(this, emu);
+       io = new FP200_IO(this, emu);
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(drec);
@@ -91,7 +91,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()
@@ -326,72 +325,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::FP_200_HEAD")), csp_logger);
-       DECL_STATE_ENTRY_MULTI(void, 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);
-       
-       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);
-}
-
-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);
-       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;
+               }
+       }
        state_fio->StateBuffer(ram, sizeof(ram), 1);
        return true;
 }
index b06a0f4..5fed729 100644 (file)
@@ -60,7 +60,7 @@ class I8080;
 class MEMORY;
 class RP5C01;
 
-class IO;
+class FP200_IO;
 
 class VM : public VM_TEMPLATE
 {
@@ -76,7 +76,7 @@ protected:
        MEMORY* memory;
        RP5C01* rtc;
        
-       IO* io;
+       FP200_IO* io;
        
        // memory
        uint8_t rom[0x8000];
@@ -136,9 +136,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 62371de..67a08ff 100644 (file)
@@ -167,7 +167,7 @@ static const uint8_t key_table[10][8] = {
        {0x0d, 0xdd, 0x14, 0xe2, 0x36, 0x59, 0x48, 0x4e}
 };
 
-void IO::initialize()
+void FP200_IO::initialize()
 {
        FILEIO* fio = new FILEIO();
        if(fio->Fopen(create_local_path(_T("FONT.ROM")), FILEIO_READ_BINARY)) {
@@ -209,13 +209,13 @@ void IO::initialize()
        key_stat = emu->get_key_buffer();
 }
 
-void IO::release()
+void FP200_IO::release()
 {
        close_tape();
        delete cmt_fio;
 }
 
-void IO::reset()
+void FP200_IO::reset()
 {
        mode_basic = (config.boot_mode == 0);
        
@@ -235,7 +235,7 @@ void IO::reset()
 
 #define REVERSE(v) (((v) & 0x80) >> 7) | (((v) & 0x40) >> 5) | (((v) & 0x20) >> 3) | (((v) & 0x10) >> 1) | (((v) & 0x08) << 1) | (((v) & 0x04) << 3) | (((v) & 0x02) << 5) | (((v) & 0x01) << 7)
 
-void IO::write_io8(uint32_t addr, uint32_t data)
+void FP200_IO::write_io8(uint32_t addr, uint32_t data)
 {
 #ifdef _IO_DEBUG_LOG
        this->out_debug_log(_T("%06x\tSOD=%d\tOUT8\t%04x, %02x\n"), get_cpu_pc(0), sod ? 1 : 0, addr & 0xff, data & 0xff);
@@ -310,7 +310,7 @@ void IO::write_io8(uint32_t addr, uint32_t data)
        }
 }
 
-uint32_t IO::read_io8(uint32_t addr)
+uint32_t FP200_IO::read_io8(uint32_t addr)
 {
        uint32_t value = 0xff;
        
@@ -364,19 +364,19 @@ uint32_t IO::read_io8(uint32_t addr)
        return value;
 }
 
-void IO::write_io8w(uint32_t addr, uint32_t data, int* wait)
+void FP200_IO::write_io8w(uint32_t addr, uint32_t data, int* wait)
 {
        *wait = 2;
        write_io8(addr, data);
 }
 
-uint32_t IO::read_io8w(uint32_t addr, int* wait)
+uint32_t FP200_IO::read_io8w(uint32_t addr, int* wait)
 {
        *wait = 2;
        return read_io8(addr);
 }
 
-void IO::write_signal(int id, uint32_t data, uint32_t mask)
+void FP200_IO::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(id == SIG_IO_SOD) {
                sod = ((data & mask) != 0);
@@ -390,7 +390,7 @@ void IO::write_signal(int id, uint32_t data, uint32_t mask)
 #define BIT_1200HZ     0x20
 #define BIT_300HZ      0x80
 
-void IO::event_callback(int event_id, int err)
+void FP200_IO::event_callback(int event_id, int err)
 {
        if(event_id == EVENT_CMT_READY) {
                if(CMT_RECORDING) {
@@ -415,7 +415,7 @@ void IO::event_callback(int event_id, int err)
        }
 }
 
-void IO::key_down(int code)
+void FP200_IO::key_down(int code)
 {
        if(code >= 0x10 && code <= 0x13) {
                update_sid();
@@ -424,12 +424,12 @@ void IO::key_down(int code)
        }
 }
 
-void IO::key_up()
+void FP200_IO::key_up()
 {
        update_sid();
 }
 
-void IO::update_sid()
+void FP200_IO::update_sid()
 {
        switch(key_column) {
        case 5:
@@ -453,7 +453,7 @@ void IO::update_sid()
        }
 }
 
-void IO::cmt_write_buffer(uint8_t value, int samples)
+void FP200_IO::cmt_write_buffer(uint8_t value, int samples)
 {
        if(cmt_is_wav) {
                for(int i = 0; i < samples; i++) {
@@ -477,7 +477,7 @@ void IO::cmt_write_buffer(uint8_t value, int samples)
        }
 }
 
-void IO::rec_tape(const _TCHAR* file_path)
+void FP200_IO::rec_tape(const _TCHAR* file_path)
 {
        close_tape();
        
@@ -492,7 +492,7 @@ void IO::rec_tape(const _TCHAR* file_path)
        }
 }
 
-void IO::close_tape()
+void FP200_IO::close_tape()
 {
        // close file
        if(cmt_fio->IsOpened()) {
@@ -558,7 +558,7 @@ void IO::close_tape()
        cmt_bufcnt = 0;
 }
 
-void IO::update_cmt()
+void FP200_IO::update_cmt()
 {
        bool prev_load_clock = c15.out_y;
        
@@ -588,7 +588,7 @@ void IO::update_cmt()
        }
 }
 
-void IO::draw_screen()
+void FP200_IO::draw_screen()
 {
        // render screen
        for(int y = 0; y < 8; y++) {
@@ -624,210 +624,63 @@ void IO::draw_screen()
        }
 }
 
-#define STATE_VERSION  3
-
-#include "../../statesub.h"
-
-#define DECL_STATE_ENTRY_74LS74(foo) {                 \
-               DECL_STATE_ENTRY_BOOL((foo.in_d));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_ck));             \
-               DECL_STATE_ENTRY_BOOL((foo.in_s));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_r));              \
-               DECL_STATE_ENTRY_BOOL((foo.out_q));             \
-               DECL_STATE_ENTRY_BOOL((foo.out_nq));    \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_ck));    \
+#define PROCESS_STATE_74LS74(foo)                              \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_d);                 \
+               state_fio->StateBool(foo.in_ck);                \
+               state_fio->StateBool(foo.in_s);                 \
+               state_fio->StateBool(foo.in_r);                 \
+               state_fio->StateBool(foo.out_q);                \
+               state_fio->StateBool(foo.out_nq);               \
+               state_fio->StateBool(foo.tmp_ck);               \
        }
 
-#define DECL_STATE_ENTRY_74LS151(foo) { \
-       DECL_STATE_ENTRY_BOOL((foo.in_d0)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d1)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d2)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d3)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d4)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d5)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d6)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_d7)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_a)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_b)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_c)); \
-       DECL_STATE_ENTRY_BOOL((foo.in_s));      \
-       DECL_STATE_ENTRY_BOOL((foo.out_y)); \
-       DECL_STATE_ENTRY_BOOL((foo.out_ny));            \
+#define PROCESS_STATE_74LS151(foo)                             \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_d0);                \
+               state_fio->StateBool(foo.in_d1);                \
+               state_fio->StateBool(foo.in_d2);                \
+               state_fio->StateBool(foo.in_d3);                \
+               state_fio->StateBool(foo.in_d4);                \
+               state_fio->StateBool(foo.in_d5);                \
+               state_fio->StateBool(foo.in_d6);                \
+               state_fio->StateBool(foo.in_d7);                \
+               state_fio->StateBool(foo.in_a);                 \
+               state_fio->StateBool(foo.in_b);                 \
+               state_fio->StateBool(foo.in_c);                 \
+               state_fio->StateBool(foo.in_s);                 \
+               state_fio->StateBool(foo.out_y);                \
+               state_fio->StateBool(foo.out_ny);               \
        }
 
-#define DECL_STATE_ENTRY_74LS93(foo) {                 \
-               DECL_STATE_ENTRY_BOOL((foo.in_a));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_b));              \
-               DECL_STATE_ENTRY_BOOL((foo.in_rc1));    \
-               DECL_STATE_ENTRY_BOOL((foo.in_rc2));    \
-               DECL_STATE_ENTRY_BOOL((foo.out_qa));    \
-               DECL_STATE_ENTRY_BOOL((foo.out_qb));    \
-               DECL_STATE_ENTRY_BOOL((foo.out_qc));    \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_a));             \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_b));             \
-               DECL_STATE_ENTRY_UINT8((foo.counter_a));        \
-               DECL_STATE_ENTRY_UINT8((foo.counter_b));        \
-       }
-
-#define DECL_STATE_ENTRY_TC4024BP(foo) {                       \
-               DECL_STATE_ENTRY_BOOL((foo.in_ck));                     \
-               DECL_STATE_ENTRY_BOOL((foo.in_clr));            \
-               DECL_STATE_ENTRY_BOOL((foo.out_q5));            \
-               DECL_STATE_ENTRY_BOOL((foo.out_q6));            \
-               DECL_STATE_ENTRY_BOOL((foo.tmp_ck));            \
-               DECL_STATE_ENTRY_UINT8((foo.counter));          \
-       }
-
-void IO::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       for(int i = 0; i < 2; i++) {
-               DECL_STATE_ENTRY_1D_ARRAY_MEMBER(lcd[i].ram, sizeof(lcd[0].ram), i);
-               DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].offset), i);
-               DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].cursor), i);
-       }               
-       DECL_STATE_ENTRY_INT32(lcd_status);
-       DECL_STATE_ENTRY_INT32(lcd_addr);
-       DECL_STATE_ENTRY_BOOL(lcd_text);
-       DECL_STATE_ENTRY_BOOL(cmt_selected);
-       DECL_STATE_ENTRY_UINT8(cmt_mode);
-       DECL_STATE_ENTRY_BOOL(cmt_play_ready);
-       DECL_STATE_ENTRY_BOOL(cmt_play_signal);
-       DECL_STATE_ENTRY_BOOL(cmt_rec_ready);
-       DECL_STATE_ENTRY_BOOL(cmt_rec);
-       DECL_STATE_ENTRY_BOOL(cmt_is_wav);
-       DECL_STATE_ENTRY_STRING(cmt_rec_file_path, sizeof(cmt_rec_file_path));
-       DECL_STATE_ENTRY_CMT_RECORDING(cmt_fio, cmt_rec, cmt_rec_file_path);
-       
-       DECL_STATE_ENTRY_INT32(cmt_bufcnt);
-       // ToDo: Write cmt_buffer only used (indicated by cmt_bufcnt).
-       DECL_STATE_ENTRY_1D_ARRAY(cmt_buffer, sizeof(cmt_buffer));
-       
-       DECL_STATE_ENTRY_UINT8(cmt_clock);
-       DECL_STATE_ENTRY_74LS74(b16_1);
-       DECL_STATE_ENTRY_74LS74(b16_2);
-       DECL_STATE_ENTRY_74LS74(g21_1);
-       DECL_STATE_ENTRY_74LS74(g21_2);
-       
-       DECL_STATE_ENTRY_74LS151(c15);
-       
-       DECL_STATE_ENTRY_74LS93(c16);
-
-       DECL_STATE_ENTRY_TC4024BP(f21);
-       DECL_STATE_ENTRY_UINT8(key_column);
-
-       leave_decl_state();
-}
-       
-void IO::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
+#define PROCESS_STATE_74LS93(foo)                              \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_a);                 \
+               state_fio->StateBool(foo.in_b);                 \
+               state_fio->StateBool(foo.in_rc1);               \
+               state_fio->StateBool(foo.in_rc2);               \
+               state_fio->StateBool(foo.out_qa);               \
+               state_fio->StateBool(foo.out_qb);               \
+               state_fio->StateBool(foo.out_qc);               \
+               state_fio->StateBool(foo.tmp_a);                \
+               state_fio->StateBool(foo.tmp_b);                \
+               state_fio->StateUint8(foo.counter_a);   \
+               state_fio->StateUint8(foo.counter_b);   \
        }
 
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->Fwrite(lcd, sizeof(lcd), 1);
-//     state_fio->FputInt32(lcd_status);
-//     state_fio->FputInt32(lcd_addr);
-//     state_fio->FputBool(lcd_text);
-//     state_fio->FputBool(cmt_selected);
-//     state_fio->FputUint8(cmt_mode);
-//     state_fio->FputBool(cmt_play_ready);
-//     state_fio->FputBool(cmt_play_signal);
-//     state_fio->FputBool(cmt_rec_ready);
-//     state_fio->FputBool(cmt_rec);
-//     state_fio->FputBool(cmt_is_wav);
-//     state_fio->Fwrite(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
-//     if(cmt_rec && cmt_fio->IsOpened()) {
-//             int length_tmp = (int)cmt_fio->Ftell();
-//             cmt_fio->Fseek(0, FILEIO_SEEK_SET);
-///            state_fio->FputInt32(length_tmp);
-//             while(length_tmp != 0) {
-///                    uint8_t buffer_tmp[1024];
-///                    int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-//                     cmt_fio->Fread(buffer_tmp, length_rw, 1);
-//                     state_fio->Fwrite(buffer_tmp, length_rw, 1);
-//                     length_tmp -= length_rw;
-//             }
-//     } else {
-//             state_fio->FputInt32(0);
-//     }
-//     state_fio->FputInt32(cmt_bufcnt);
-//     state_fio->Fwrite(cmt_buffer, cmt_bufcnt, 1);
-//     state_fio->FputUint8(cmt_clock);
-//     state_fio->Fwrite(&b16_1, sizeof(b16_1), 1);
-//     state_fio->Fwrite(&b16_2, sizeof(b16_2), 1);
-//     state_fio->Fwrite(&g21_1, sizeof(g21_1), 1);
-//     state_fio->Fwrite(&g21_2, sizeof(g21_2), 1);
-//     state_fio->Fwrite(&c15, sizeof(c15), 1);
-//     state_fio->Fwrite(&c16, sizeof(c16), 1);
-//     state_fio->Fwrite(&f21, sizeof(f21), 1);
-//     state_fio->FputUint8(key_column);
-}
-
-bool IO::load_state(FILEIO* state_fio)
-{
-       close_tape();
-       
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               return false;
+#define PROCESS_STATE_4024(foo)                        \
+       {                                                                                       \
+               state_fio->StateBool(foo.in_ck);                \
+               state_fio->StateBool(foo.in_clr);               \
+               state_fio->StateBool(foo.out_q5);               \
+               state_fio->StateBool(foo.out_q6);               \
+               state_fio->StateBool(foo.tmp_ck);               \
+               state_fio->StateUint8(foo.counter);             \
        }
 
-//     if(state_fio->FgetUint32() != STATE_VERSION) {
-//             return false;
-//     }
-//     if(state_fio->FgetInt32() != this_device_id) {
-//             return false;
-//     }
-//     state_fio->Fread(lcd, sizeof(lcd), 1);
-//     lcd_status = state_fio->FgetInt32();
-//     lcd_addr = state_fio->FgetInt32();
-//     lcd_text = state_fio->FgetBool();
-//     cmt_selected = state_fio->FgetBool();
-//     cmt_mode = state_fio->FgetUint8();
-//     cmt_play_ready = state_fio->FgetBool();
-//     cmt_play_signal = state_fio->FgetBool();
-//     cmt_rec_ready = state_fio->FgetBool();
-//     cmt_rec = state_fio->FgetBool();
-//     cmt_is_wav = state_fio->FgetBool();
-//     state_fio->Fread(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
-//     int length_tmp = state_fio->FgetInt32();
-//     if(cmt_rec) {
-//             cmt_fio->Fopen(cmt_rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
-//             while(length_tmp != 0) {
-//                     uint8_t buffer_tmp[1024];
-//                     int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-//                     state_fio->Fread(buffer_tmp, length_rw, 1);
-//                     if(cmt_fio->IsOpened()) {
-//                             cmt_fio->Fwrite(buffer_tmp, length_rw, 1);
-//                     }
-//                     length_tmp -= length_rw;
-//             }
-//     }
-//     cmt_bufcnt = state_fio->FgetInt32();
-//     if(cmt_bufcnt) {
-//             state_fio->Fread(cmt_buffer, cmt_bufcnt, 1);
-//     }
-//     cmt_clock = state_fio->FgetUint8();
-//     state_fio->Fread(&b16_1, sizeof(b16_1), 1);
-//     state_fio->Fread(&b16_2, sizeof(b16_2), 1);
-//     state_fio->Fread(&g21_1, sizeof(g21_1), 1);
-//     state_fio->Fread(&g21_2, sizeof(g21_2), 1);
-//     state_fio->Fread(&c15, sizeof(c15), 1);
-///    state_fio->Fread(&c16, sizeof(c16), 1);
-//     state_fio->Fread(&f21, sizeof(f21), 1);
-//     key_column = state_fio->FgetUint8();
-       return true;
-}
+#define STATE_VERSION  4
 
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool FP200_IO::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
@@ -839,7 +692,12 @@ bool IO::process_state(FILEIO* state_fio, bool loading)
        if(loading) {
                close_tape();
        }
-       state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+       //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+       for(int i = 0; i < 2; i++) {
+               state_fio->StateBuffer(&(lcd[i].ram), 0x400, 1);
+               state_fio->StateInt32(lcd[i].offset);
+               state_fio->StateInt32(lcd[i].cursor);
+       }               
        state_fio->StateInt32(lcd_status);
        state_fio->StateInt32(lcd_addr);
        state_fio->StateBool(lcd_text);
@@ -884,13 +742,23 @@ bool IO::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateInt32(cmt_bufcnt);
        state_fio->StateBuffer(cmt_buffer, cmt_bufcnt, 1);
        state_fio->StateUint8(cmt_clock);
-       state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
-       state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
-       state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
-       state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
-       state_fio->StateBuffer(&c15, sizeof(c15), 1);
-       state_fio->StateBuffer(&c16, sizeof(c16), 1);
-       state_fio->StateBuffer(&f21, sizeof(f21), 1);
+       
+       //state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
+       //state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
+       //state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
+       //state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
+       PROCESS_STATE_74LS74(b16_1);
+       PROCESS_STATE_74LS74(b16_2);
+       PROCESS_STATE_74LS74(g21_1);
+       PROCESS_STATE_74LS74(g21_2);
+       
+       //state_fio->StateBuffer(&c15, sizeof(c15), 1);
+       PROCESS_STATE_74LS151(c15);
+       
+       //state_fio->StateBuffer(&c16, sizeof(c16), 1);
+       PROCESS_STATE_74LS93(c16);
+       //state_fio->StateBuffer(&f21, sizeof(f21), 1);
+       PROCESS_STATE_4024(f21);
        state_fio->StateUint8(key_column);
        return true;
 }
index 2206f59..29b83f7 100644 (file)
@@ -7,8 +7,8 @@
        [ io ]
 */
 
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _FP200_IO_H_
+#define _FP200_IO_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -19,7 +19,7 @@
 
 class FILEIO;
 
-class IO : public DEVICE
+class FP200_IO : public DEVICE
 {
 private:
        DEVICE *d_cpu, *d_drec, *d_rtc;
@@ -150,11 +150,11 @@ private:
        void update_sid();
        
 public:
-       IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       FP200_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("I/O Bus"));
        }
-       ~IO() {}
+       ~FP200_IO() {}
        
        // common functions
        void initialize();
@@ -166,9 +166,7 @@ public:
        uint32_t read_io8w(uint32_t addr, int* wait);
        void write_signal(int id, uint32_t data, uint32_t mask);
        void event_callback(int event_id, int err);
-       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 3194ab4..72953ca 100644 (file)
@@ -58,7 +58,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        cpu_tf20->set_device_name(_T("TF20 CPU(Z80)"));
        sio_tf20->set_device_name(_T("TF20 SIO(Z80 SIO)"));
        fdc_tf20->set_device_name(_T("TF20 FDC(uPD765A)"));
-       memory = new MEMORY(this, emu);
+       memory = new HC20_MEMORY(this, emu);
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_cpu(cpu_tf20, 4000000);
@@ -344,70 +344,36 @@ 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::HC_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;
+               }
+       }
        return true;
 }
index 3382bec..cf0c0c6 100644 (file)
@@ -68,7 +68,7 @@ class UPD765A;
 class Z80;
 class Z80SIO;
 
-class MEMORY;
+class HC20_MEMORY;
 
 class VM : public VM_TEMPLATE
 {
@@ -90,7 +90,7 @@ protected:
        Z80* cpu_tf20;
        Z80SIO* sio_tf20;
        
-       MEMORY* memory;
+       HC20_MEMORY* memory;
        
 public:
        // ----------------------------------------
@@ -143,9 +143,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 18fcaf1..c04551a 100644 (file)
@@ -7,7 +7,7 @@
        [ memory ]
 */
 
-#include "memory.h"
+#include "./memory.h"
 #include "../beep.h"
 #include "../hd6301.h"
 #include "../z80sio.h"
@@ -47,7 +47,7 @@ static int key_table[8][10] = {
        0x79, 0x7a, 0x77, 0x75, 0x2e, 0x76, 0x00, 0x00, 0x00, 0x21
 };
 
-void MEMORY::initialize()
+void HC20_MEMORY::initialize()
 {
        // initialize memory
        memset(ram, 0, sizeof(ram));
@@ -127,7 +127,7 @@ void MEMORY::initialize()
        register_event_by_clock(this, EVENT_SOUND, 256, true, NULL);
 }
 
-void MEMORY::release()
+void HC20_MEMORY::release()
 {
        // save battery backuped ram
        FILEIO* fio = new FILEIO();
@@ -146,7 +146,7 @@ void MEMORY::release()
        delete cmd_buf;
 }
 
-void MEMORY::reset()
+void HC20_MEMORY::reset()
 {
        // select internal rom
 //     SET_BANK(0x4000, 0x7fff, wdmy, rdmy);
@@ -172,7 +172,7 @@ void MEMORY::reset()
        int_mask = 0;
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void HC20_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
        if(addr < 0x40) {
@@ -222,7 +222,7 @@ void MEMORY::write_data8(uint32_t addr, uint32_t data)
        }
 }
 
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t HC20_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
        if(addr < 0x40) {
@@ -284,7 +284,7 @@ uint32_t MEMORY::read_data8(uint32_t addr)
        return rbank[(addr >> 13) & 7][addr & 0x1fff];
 }
 
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void HC20_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(id == SIG_MEMORY_PORT_2) {
                sio_select = ((data & 0x04) != 0);
@@ -312,14 +312,14 @@ void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
        }
 }
 
-void MEMORY::event_callback(int event_id, int err)
+void HC20_MEMORY::event_callback(int event_id, int err)
 {
        if(event_id == EVENT_SOUND) {
                update_sound();
        }
 }
 
-void MEMORY::update_sound()
+void HC20_MEMORY::update_sound()
 {
        if(sound_ptr < sound_count) {
                if(sound[sound_ptr].remain-- == 0) {
@@ -342,7 +342,7 @@ void MEMORY::update_sound()
        }
 }
 
-void MEMORY::update_keyboard()
+void HC20_MEMORY::update_keyboard()
 {
        key_data = 0x3ff;
        
@@ -378,13 +378,13 @@ void MEMORY::update_keyboard()
        }
 }
 
-void MEMORY::notify_power_off()
+void HC20_MEMORY::notify_power_off()
 {
        int_status |= INT_POWER;
        update_intr();
 }
 
-void MEMORY::key_down(int code)
+void HC20_MEMORY::key_down(int code)
 {
        key_stat[code] = 1;
        
@@ -398,18 +398,18 @@ void MEMORY::key_down(int code)
        }
 }
 
-void MEMORY::key_up(int code)
+void HC20_MEMORY::key_up(int code)
 {
        key_stat[code] = 0;
 }
 
-void MEMORY::update_intr()
+void HC20_MEMORY::update_intr()
 {
 //     d_cpu->write_signal(SIG_CPU_IRQ, (int_status && !int_mask) ? 1 : 0, 1);
        d_cpu->write_signal(SIG_CPU_IRQ, int_status ? 1 : 0, 1);
 }
 
-void MEMORY::send_to_slave(uint8_t val)
+void HC20_MEMORY::send_to_slave(uint8_t val)
 {
        cmd_buf->write(val);
        uint8_t cmd = cmd_buf->read_not_remove(0);
@@ -729,13 +729,13 @@ void MEMORY::send_to_slave(uint8_t val)
        }
 }
 
-void MEMORY::send_to_main(uint8_t val)
+void HC20_MEMORY::send_to_main(uint8_t val)
 {
        // send to main cpu
        d_cpu->write_signal(SIG_MC6801_SIO_RECV, val, 0xff);
 }
 
-void MEMORY::play_tape(const _TCHAR* file_path)
+void HC20_MEMORY::play_tape(const _TCHAR* file_path)
 {
        close_tape();
        
@@ -748,7 +748,7 @@ void MEMORY::play_tape(const _TCHAR* file_path)
        }
 }
 
-void MEMORY::rec_tape(const _TCHAR* file_path)
+void HC20_MEMORY::rec_tape(const _TCHAR* file_path)
 {
        close_tape();
        
@@ -759,7 +759,7 @@ void MEMORY::rec_tape(const _TCHAR* file_path)
        }
 }
 
-void MEMORY::close_tape()
+void HC20_MEMORY::close_tape()
 {
        if(cmt_fio->IsOpened()) {
                if(cmt_rec && cmt_count) {
@@ -771,7 +771,7 @@ void MEMORY::close_tape()
        cmt_play = cmt_rec = false;
 }
 
-void MEMORY::draw_screen()
+void HC20_MEMORY::draw_screen()
 {
        static const int xtop[12] = {0, 0, 40, 40, 80, 80, 0, 0, 40, 40, 80, 80};
        static const int ytop[12] = {0, 8, 0, 8, 0, 8, 16, 24, 16, 24, 16, 24};
@@ -801,183 +801,7 @@ void MEMORY::draw_screen()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_BOOL(tmp_wbank_is_ext); // (wbank[0x8000 >> 13] == ext);
-       DECL_STATE_ENTRY_BOOL(tmp_rbank_is_ext); // (rbank[0x8000 >> 13] == ext);
-
-       DECL_STATE_ENTRY_1D_ARRAY(rom, sizeof(rom));
-       DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
-       DECL_STATE_ENTRY_FIFO(cmd_buf);
-       
-       DECL_STATE_ENTRY_BOOL(sio_select);
-       DECL_STATE_ENTRY_BOOL(special_cmd_masked);
-       DECL_STATE_ENTRY_1D_ARRAY(slave_mem, sizeof(slave_mem));
-       {
-               DECL_STATE_ENTRY_DOUBLE_STRIDE((sound[0].freq),  sizeof(sound) / sizeof(sound[0]), sizeof(sound[0]));
-               DECL_STATE_ENTRY_INT32_STRIDE((sound[0].period), sizeof(sound) / sizeof(sound[0]), sizeof(sound[0]));
-               DECL_STATE_ENTRY_INT32_STRIDE((sound[0].remain), sizeof(sound) / sizeof(sound[0]), sizeof(sound[0]));
-       }
-
-       DECL_STATE_ENTRY_INT32(sound_ptr);
-       DECL_STATE_ENTRY_INT32(sound_count);
-       DECL_STATE_ENTRY_UINT8(sound_reply);
-       DECL_STATE_ENTRY_DOUBLE(sound_freq);
-       DECL_STATE_ENTRY_1D_ARRAY(key_stat, sizeof(key_stat));
-       DECL_STATE_ENTRY_1D_ARRAY(key_flag, sizeof(key_flag));
-       DECL_STATE_ENTRY_INT32(key_data);
-       DECL_STATE_ENTRY_INT32(key_strobe);
-       DECL_STATE_ENTRY_INT32(key_intmask);
-       DECL_STATE_ENTRY_BOOL(cmt_play);
-       DECL_STATE_ENTRY_BOOL(cmt_rec);
-       DECL_STATE_ENTRY_STRING(cmt_file_path, sizeof(cmt_file_path));
-       DECL_STATE_ENTRY_CMT_RECORDING(cmt_fio, cmt_rec, cmt_file_path);
-       
-       DECL_STATE_ENTRY_INT32(cmt_count);
-       DECL_STATE_ENTRY_1D_ARRAY(cmt_buffer, sizeof(cmt_buffer));
-       for(int i = 0; i < 6; i++) {
-               DECL_STATE_ENTRY_1D_ARRAY_MEMBER((lcd[i].buffer), 80, i);
-               DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].bank), i);
-               DECL_STATE_ENTRY_INT32_MEMBER((lcd[i].addr), i);
-       }
-
-       DECL_STATE_ENTRY_UINT8(lcd_select);
-       DECL_STATE_ENTRY_UINT8(lcd_data);
-       DECL_STATE_ENTRY_INT32(lcd_clock);
-       DECL_STATE_ENTRY_INT32(int_status);
-       DECL_STATE_ENTRY_INT32(int_mask);
-
-       leave_decl_state();
-}
-
-void MEMORY::save_state(FILEIO* state_fio)
-{
-       tmp_wbank_is_ext = (wbank[0x8000 >> 13] == ext);
-       tmp_rbank_is_ext = (rbank[0x8000 >> 13] == ext);
-       
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->FputBool(wbank[0x8000 >> 13] == ext);
-//     state_fio->FputBool(rbank[0x8000 >> 13] == ext);
-//     state_fio->Fwrite(rom, sizeof(rom), 1);
-//     state_fio->Fwrite(ext, sizeof(ext), 1);
-//     cmd_buf->save_state((void *)state_fio);
-//     state_fio->FputBool(sio_select);
-//     state_fio->FputBool(special_cmd_masked);
-//     state_fio->Fwrite(slave_mem, sizeof(slave_mem), 1);
-//     state_fio->Fwrite(sound, sizeof(sound), 1);
-//     state_fio->FputInt32(sound_ptr);
-//     state_fio->FputInt32(sound_count);
-//     state_fio->FputUint8(sound_reply);
-//     state_fio->FputDouble(sound_freq);
-//     state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
-//     state_fio->Fwrite(key_flag, sizeof(key_flag), 1);
-//     state_fio->FputInt32(key_data);
-//     state_fio->FputInt32(key_strobe);
-//     state_fio->FputInt32(key_intmask);
-//     state_fio->FputBool(cmt_play);
-//     state_fio->FputBool(cmt_rec);
-//     state_fio->Fwrite(cmt_file_path, sizeof(cmt_file_path), 1);
-//     if(cmt_rec && cmt_fio->IsOpened()) {
-//             int length_tmp = (int)cmt_fio->Ftell();
-//             cmt_fio->Fseek(0, FILEIO_SEEK_SET);
-//             state_fio->FputInt32(length_tmp);
-//             while(length_tmp != 0) {
-//                     uint8_t buffer_tmp[1024];
-//                     int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-//                     cmt_fio->Fread(buffer_tmp, length_rw, 1);
-//                     state_fio->Fwrite(buffer_tmp, length_rw, 1);
-//                     length_tmp -= length_rw;
-//             }
-//     } else {
-//             state_fio->FputInt32(0);
-//     }
-//     state_fio->FputInt32(cmt_count);
-//     state_fio->Fwrite(cmt_buffer, sizeof(cmt_buffer), 1);
-//     state_fio->Fwrite(lcd, sizeof(lcd), 1);
-//     state_fio->FputUint8(lcd_select);
-//     state_fio->FputUint8(lcd_data);
-//     state_fio->FputInt32(lcd_clock);
-//     state_fio->FputInt32(int_status);
-//     state_fio->FputInt32(int_mask);
-}
-
-bool MEMORY::load_state(FILEIO* state_fio)
-{
-       close_tape();
-       
-       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;
-//     }
-//     bool wr = state_fio->FgetBool();
-//     bool rd = state_fio->FgetBool();
-//     state_fio->Fread(rom, sizeof(rom), 1);
-//     state_fio->Fread(ext, sizeof(ext), 1);
-//     if(!cmd_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     sio_select = state_fio->FgetBool();
-//     special_cmd_masked = state_fio->FgetBool();
-//     state_fio->Fread(slave_mem, sizeof(slave_mem), 1);
-//     state_fio->Fread(sound, sizeof(sound), 1);
-//     sound_ptr = state_fio->FgetInt32();
-//     sound_count = state_fio->FgetInt32();
-//     sound_reply = state_fio->FgetUint8();
-//     sound_freq = state_fio->FgetDouble();
-//     state_fio->Fread(key_stat, sizeof(key_stat), 1);
-//     state_fio->Fread(key_flag, sizeof(key_flag), 1);
-//     key_data = state_fio->FgetInt32();
-//     key_strobe = state_fio->FgetInt32();
-//     key_intmask = state_fio->FgetInt32();
-//     cmt_play = state_fio->FgetBool();
-//     cmt_rec = state_fio->FgetBool();
-//     state_fio->Fread(cmt_file_path, sizeof(cmt_file_path), 1);
-//     int length_tmp = state_fio->FgetInt32();
-//     if(cmt_rec) {
-//             cmt_fio->Fopen(cmt_file_path, FILEIO_READ_WRITE_NEW_BINARY);
-//             while(length_tmp != 0) {
-//                     uint8_t buffer_tmp[1024];
-//                     int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-//                     state_fio->Fread(buffer_tmp, length_rw, 1);
-//                     if(cmt_fio->IsOpened()) {
-//                             cmt_fio->Fread(buffer_tmp, length_rw, 1);
-//                     }
-//                     length_tmp -= length_rw;
-//             }
-//     }
-//     cmt_count = state_fio->FgetInt32();
-//     state_fio->Fread(cmt_buffer, sizeof(cmt_buffer), 1);
-//     state_fio->Fread(lcd, sizeof(lcd), 1);
-//     lcd_select = state_fio->FgetUint8();
-//     lcd_data = state_fio->FgetUint8();
-//     lcd_clock = state_fio->FgetInt32();
-//     int_status = state_fio->FgetInt32();
-//     int_mask = state_fio->FgetInt32();
-       
-       // post process
-       SET_BANK(0x8000, 0xbfff, tmp_wbank_is_ext ? ext : wdmy, tmp_rbank_is_ext ? ext : rom);
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool HC20_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        bool wr = false;
        bool rd = false;
@@ -996,6 +820,7 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
                state_fio->FputBool(rbank[0x8000 >> 13] == ext);
        }
        state_fio->StateBuffer(rom, sizeof(rom), 1);
+       state_fio->StateBuffer(ram, sizeof(ram), 1);
        state_fio->StateBuffer(ext, sizeof(ext), 1);
        if(!cmd_buf->process_state((void *)state_fio, loading)) {
                return false;
@@ -1003,7 +828,12 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateBool(sio_select);
        state_fio->StateBool(special_cmd_masked);
        state_fio->StateBuffer(slave_mem, sizeof(slave_mem), 1);
-       state_fio->StateBuffer(sound, sizeof(sound), 1);
+       //state_fio->StateBuffer(sound, sizeof(sound), 1);
+       for(int i = 0; i < 256; i++) {
+               state_fio->StateDouble(sound[i].freq);
+               state_fio->StateInt32(sound[i].period);
+               state_fio->StateInt32(sound[i].remain);
+       }               
        state_fio->StateInt32(sound_ptr);
        state_fio->StateInt32(sound_count);
        state_fio->StateUint8(sound_reply);
@@ -1048,7 +878,12 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
        }
        state_fio->StateInt32(cmt_count);
        state_fio->StateBuffer(cmt_buffer, sizeof(cmt_buffer), 1);
-       state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+       //state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+       for(int i = 0; i < (sizeof(lcd) / sizeof(lcd_t)); i++) {
+               state_fio->StateBuffer(lcd[i].buffer, 0x80, 1);
+               state_fio->StateInt32(lcd[i].bank);
+               state_fio->StateInt32(lcd[i].addr);
+       }               
        state_fio->StateUint8(lcd_select);
        state_fio->StateUint8(lcd_data);
        state_fio->StateInt32(lcd_clock);
index 6f47b67..ce76c3a 100644 (file)
@@ -7,8 +7,8 @@
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _HC20_MEMORY_H_
+#define _HC20_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -26,7 +26,7 @@
 class BEEP;
 class FIFO;
 
-class MEMORY : public DEVICE
+class HC20_MEMORY : public DEVICE
 {
 private:
        BEEP *d_beep;
@@ -92,11 +92,11 @@ private:
        void send_to_main(uint8_t val);
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       HC20_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~HC20_MEMORY() {}
        
        // common functions
        void initialize();
@@ -106,9 +106,7 @@ public:
        uint32_t read_data8(uint32_t addr);
        void write_signal(int id, uint32_t data, uint32_t mask);
        void event_callback(int event_id, int err);
-       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_beep(BEEP* device)
index 8c95401..a157edb 100644 (file)
@@ -45,8 +45,8 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        tf20 = new PTF20(this, emu);
        cpu = new Z80(this, emu);
        
-       io = new IO(this, emu);
-       memory = new MEMORY(this, emu);
+       io = new HC40_IO(this, emu);
+       memory = new HC40_MEMORY(this, emu);
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(beep);
@@ -79,7 +79,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()
@@ -320,69 +319,36 @@ 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::HC_40_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;
+               }
+       }
        return true;
 }
index fe104db..bd06b7b 100644 (file)
@@ -56,8 +56,8 @@ class DATAREC;
 class PTF20;
 class Z80;
 
-class IO;
-class MEMORY;
+class HC40_IO;
+class HC40_MEMORY;
 
 class VM : public VM_TEMPLATE
 {
@@ -73,8 +73,8 @@ protected:
        PTF20* tf20;
        Z80* cpu;
        
-       IO* io;
-       MEMORY* memory;
+       HC40_IO* io;
+       HC40_MEMORY* memory;
        
 public:
        // ----------------------------------------
@@ -137,9 +137,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 aeaca83..bedc475 100644 (file)
@@ -7,7 +7,7 @@
        [ i/o ]
 */
 
-#include "io.h"
+#include "./io.h"
 #include "../beep.h"
 #include "../datarec.h"
 #include "../ptf20.h"
@@ -58,7 +58,7 @@ static const int key_tbl[256] = {
 DLL_PREFIX_I struct cur_time_s cur_time;
 #endif
 
-void IO::initialize()
+void HC40_IO::initialize()
 {
        // init external ram disk
        memset(ext, 0, 0x20000);
@@ -100,7 +100,7 @@ void IO::initialize()
        register_event_by_clock(this, EVENT_1SEC, CPU_CLOCKS, true, &register_id_1sec);
 }
 
-void IO::release()
+void HC40_IO::release()
 {
        // save external ram disk
        FILEIO* fio = new FILEIO();
@@ -120,7 +120,7 @@ void IO::release()
        delete art_buf;
 }
 
-void IO::reset()
+void HC40_IO::reset()
 {
        // reset gapnit
        bcr = slbcr = isr = ier = bankr = ioctlr = 0;
@@ -136,7 +136,7 @@ void IO::reset()
        register_id_art = -1;
 }
 
-void IO::sysreset()
+void HC40_IO::sysreset()
 {
        // reset 7508
        onesec_intr = alarm_intr = false;
@@ -144,7 +144,7 @@ void IO::sysreset()
        res_7508 = true;
 }
 
-void IO::write_signal(int id, uint32_t data, uint32_t mask)
+void HC40_IO::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(id == SIG_IO_DREC) {
                // signal from data recorder
@@ -166,13 +166,13 @@ void IO::write_signal(int id, uint32_t data, uint32_t mask)
        }
 }
 
-void IO::event_frame()
+void HC40_IO::event_frame()
 {
        d_beep->write_signal(SIG_BEEP_ON, beep ? 1 : 0, 1);
        beep = false;
 }
 
-void IO::event_callback(int event_id, int err)
+void HC40_IO::event_callback(int event_id, int err)
 {
        if(event_id == EVENT_FRC) {
                // FRC overflow event
@@ -215,7 +215,7 @@ void IO::event_callback(int event_id, int err)
        }
 }
 
-void IO::write_io8(uint32_t addr, uint32_t data)
+void HC40_IO::write_io8(uint32_t addr, uint32_t data)
 {
        switch(addr & 0xff) {
        case 0x00:
@@ -322,7 +322,7 @@ void IO::write_io8(uint32_t addr, uint32_t data)
        }
 }
 
-uint32_t IO::read_io8(uint32_t addr)
+uint32_t HC40_IO::read_io8(uint32_t addr)
 {
        uint32_t val = 0xff;
        
@@ -377,7 +377,7 @@ uint32_t IO::read_io8(uint32_t addr)
        return 0xff;
 }
 
-uint32_t IO::get_intr_ack()
+uint32_t HC40_IO::get_intr_ack()
 {
        if(isr & BIT_7508) {
                isr &= ~BIT_7508;
@@ -395,7 +395,7 @@ uint32_t IO::get_intr_ack()
        return 0xff;
 }
 
-void IO::update_intr()
+void HC40_IO::update_intr()
 {
        // set int signal
        bool next = ((isr & ier & 0x1f) != 0);
@@ -406,7 +406,7 @@ void IO::update_intr()
 // 7508
 // ----------------------------------------------------------------------------
 
-void IO::send_to_7508(uint8_t val)
+void HC40_IO::send_to_7508(uint8_t val)
 {
        int res;
        
@@ -644,12 +644,12 @@ void IO::send_to_7508(uint8_t val)
        }
 }
 
-uint8_t IO::rec_from_7508()
+uint8_t HC40_IO::rec_from_7508()
 {
        return rsp_buf->read();
 }
 
-void IO::key_down(int code)
+void HC40_IO::key_down(int code)
 {
        if(code == 0x14) {
                // toggle caps lock
@@ -661,7 +661,7 @@ void IO::key_down(int code)
        }
 }
 
-void IO::key_up(int code)
+void HC40_IO::key_up(int code)
 {
        if(code == 0x10) {
                update_key(0xa3);       // break shift
@@ -670,7 +670,7 @@ void IO::key_up(int code)
        }
 }
 
-void IO::update_key(int code)
+void HC40_IO::update_key(int code)
 {
        if(code != 0xff) {
                // add to buffer
@@ -694,7 +694,7 @@ void IO::update_key(int code)
 // video
 // ----------------------------------------------------------------------------
 
-void IO::draw_screen()
+void HC40_IO::draw_screen()
 {
        if(yoff & 0x80) {
                uint8_t* vram = ram + ((vadr & 0xf8) << 8);
@@ -726,178 +726,7 @@ void IO::draw_screen()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void IO::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_UINT32(cur_clock);
-       DECL_STATE_ENTRY_UINT8(bcr);
-       DECL_STATE_ENTRY_UINT8(slbcr);
-       DECL_STATE_ENTRY_UINT8(isr);
-       DECL_STATE_ENTRY_UINT8(ier);
-       DECL_STATE_ENTRY_UINT8(bankr);
-       DECL_STATE_ENTRY_UINT8(ioctlr);
-       DECL_STATE_ENTRY_UINT32(icrc);
-       DECL_STATE_ENTRY_UINT32(icrb);
-       DECL_STATE_ENTRY_BOOL(ear);
-       DECL_STATE_ENTRY_UINT8(vadr);
-       DECL_STATE_ENTRY_UINT8(yoff);
-       DECL_STATE_ENTRY_FIFO(cmd_buf);
-       DECL_STATE_ENTRY_FIFO(rsp_buf);
-       DECL_STATE_ENTRY_CUR_TIME_T(cur_time);
-       
-       DECL_STATE_ENTRY_INT32(register_id_1sec);
-       DECL_STATE_ENTRY_BOOL(onesec_intr);
-       DECL_STATE_ENTRY_BOOL(onesec_intr_enb);
-       DECL_STATE_ENTRY_BOOL(alarm_intr);
-       DECL_STATE_ENTRY_BOOL(alarm_intr_enb);
-       DECL_STATE_ENTRY_1D_ARRAY(alarm, sizeof(alarm));
-       DECL_STATE_ENTRY_FIFO(key_buf);
-       DECL_STATE_ENTRY_BOOL(kb_intr_enb);
-       DECL_STATE_ENTRY_BOOL(kb_rep_enb);
-       DECL_STATE_ENTRY_BOOL(kb_caps);
-       DECL_STATE_ENTRY_UINT8(kb_rep_spd1);
-       DECL_STATE_ENTRY_UINT8(kb_rep_spd2);
-       DECL_STATE_ENTRY_FIFO(art_buf);
-       DECL_STATE_ENTRY_UINT8(artsr);
-       DECL_STATE_ENTRY_UINT8(artdir);
-       DECL_STATE_ENTRY_BOOL(txen);
-       DECL_STATE_ENTRY_BOOL(rxen);
-       DECL_STATE_ENTRY_BOOL(dsr);
-       DECL_STATE_ENTRY_INT32(register_id_art);
-       DECL_STATE_ENTRY_BOOL(beep);
-       DECL_STATE_ENTRY_BOOL(res_z80);
-       DECL_STATE_ENTRY_BOOL(res_7508);
-       DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
-       DECL_STATE_ENTRY_UINT32(extar);
-       DECL_STATE_ENTRY_UINT8(extcr);
-       
-       leave_decl_state();
-}
-
-
-void IO::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->FputUint32(cur_clock);
-//     state_fio->FputUint8(bcr);
-//     state_fio->FputUint8(slbcr);
-//     state_fio->FputUint8(isr);
-//     state_fio->FputUint8(ier);
-//     state_fio->FputUint8(bankr);
-//     state_fio->FputUint8(ioctlr);
-//     state_fio->FputUint32(icrc);
-//     state_fio->FputUint32(icrb);
-//     state_fio->FputBool(ear);
-//     state_fio->FputUint8(vadr);
-//     state_fio->FputUint8(yoff);
-//     cmd_buf->save_state((void *)state_fio);
-//     rsp_buf->save_state((void *)state_fio);
-//     cur_time.save_state((void *)state_fio);
-//     state_fio->FputInt32(register_id_1sec);
-//     state_fio->FputBool(onesec_intr);
-//     state_fio->FputBool(onesec_intr_enb);
-//     state_fio->FputBool(alarm_intr);
-//     state_fio->FputBool(alarm_intr_enb);
-//     state_fio->Fwrite(alarm, sizeof(alarm), 1);
-//     key_buf->save_state((void *)state_fio);
-//     state_fio->FputBool(kb_intr_enb);
-//     state_fio->FputBool(kb_rep_enb);
-//     state_fio->FputBool(kb_caps);
-//     state_fio->FputUint8(kb_rep_spd1);
-//     state_fio->FputUint8(kb_rep_spd2);
-//     art_buf->save_state((void *)state_fio);
-//     state_fio->FputUint8(artsr);
-//     state_fio->FputUint8(artdir);
-//     state_fio->FputBool(txen);
-//     state_fio->FputBool(rxen);
-//     state_fio->FputBool(dsr);
-//     state_fio->FputInt32(register_id_art);
-//     state_fio->FputBool(beep);
-//     state_fio->FputBool(res_z80);
-//     state_fio->FputBool(res_7508);
-//     state_fio->Fwrite(ext, sizeof(ext), 1);
-//     state_fio->FputUint32(extar);
-//     state_fio->FputUint8(extcr);
-}
-
-bool IO::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;
-//     }
-//     cur_clock = state_fio->FgetUint32();
-//     bcr = state_fio->FgetUint8();
-//     slbcr = state_fio->FgetUint8();
-//     isr = state_fio->FgetUint8();
-//     ier = state_fio->FgetUint8();
-//     bankr = state_fio->FgetUint8();
-//     ioctlr = state_fio->FgetUint8();
-//     icrc = state_fio->FgetUint32();
-//     icrb = state_fio->FgetUint32();
-//     ear = state_fio->FgetBool();
-//     vadr = state_fio->FgetUint8();
-//     yoff = state_fio->FgetUint8();
-//     if(!cmd_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     if(!rsp_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     if(!cur_time.load_state((void *)state_fio)) {
-//             return false;
-//     }
-       
-//     register_id_1sec = state_fio->FgetInt32();
-//     onesec_intr = state_fio->FgetBool();
-//     onesec_intr_enb = state_fio->FgetBool();
-//     alarm_intr = state_fio->FgetBool();
-//     alarm_intr_enb = state_fio->FgetBool();
-//     state_fio->Fread(alarm, sizeof(alarm), 1);
-//     if(!key_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     kb_intr_enb = state_fio->FgetBool();
-//     kb_rep_enb = state_fio->FgetBool();
-//     kb_caps = state_fio->FgetBool();
-//     kb_rep_spd1 = state_fio->FgetUint8();
-//     kb_rep_spd2 = state_fio->FgetUint8();
-//     if(!art_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     artsr = state_fio->FgetUint8();
-//     artdir = state_fio->FgetUint8();
-//     txen = state_fio->FgetBool();
-//     rxen = state_fio->FgetBool();
-//     dsr = state_fio->FgetBool();
-//     register_id_art = state_fio->FgetInt32();
-//     beep = state_fio->FgetBool();
-//     res_z80 = state_fio->FgetBool();
-//     res_7508 = state_fio->FgetBool();
-//     state_fio->Fread(ext, sizeof(ext), 1);
-//     extar = state_fio->FgetUint32();
-//     extcr = state_fio->FgetUint8();
-       return true;
-}
-
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool HC40_IO::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index a83e235..5576dc3 100644 (file)
@@ -7,8 +7,8 @@
        [ i/o ]
 */
 
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _HC40_IO_H_
+#define _HC40_IO_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -19,7 +19,7 @@
 
 class FIFO;
 
-class IO : public DEVICE
+class HC40_IO : public DEVICE
 {
 private:
        DEVICE *d_cpu, *d_mem, *d_tf20, *d_beep, *d_drec;
@@ -71,11 +71,11 @@ private:
        scrntype_t pd, pb;
        
 public:
-       IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       HC40_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("I/O Bus"));
        }
-       ~IO() {}
+       ~HC40_IO() {}
        
        // common functions
        void initialize();
@@ -88,9 +88,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
        uint32_t get_intr_ack();
-       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 681e635..4f76eba 100644 (file)
@@ -25,7 +25,7 @@
        } \
 }
 
-void MEMORY::initialize()
+void HC40_MEMORY::initialize()
 {
        // initialize memory
        memset(ram, 0, sizeof(ram));
@@ -55,7 +55,7 @@ void MEMORY::initialize()
        delete fio;
 }
 
-void MEMORY::release()
+void HC40_MEMORY::release()
 {
        // save battery backuped ram
        FILEIO* fio = new FILEIO();
@@ -66,29 +66,29 @@ void MEMORY::release()
        delete fio;
 }
 
-void MEMORY::reset()
+void HC40_MEMORY::reset()
 {
        set_bank(0);
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void HC40_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
        wbank[(addr >> 13) & 7][addr & 0x1fff] = data;
 }
 
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t HC40_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
        return rbank[(addr >> 13) & 7][addr & 0x1fff];
 }
 
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void HC40_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        set_bank(data);
 }
 
-void MEMORY::set_bank(uint32_t val)
+void HC40_MEMORY::set_bank(uint32_t val)
 {
        SET_BANK(0x0000, 0xffff, ram, ram);
        
@@ -130,54 +130,7 @@ void MEMORY::set_bank(uint32_t val)
 
 #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_UINT8(bank);
-       
-       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->FputUint8(bank);
-}
-
-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);
-//     bank = state_fio->FgetUint8();
-       
-       // post process
-       set_bank(bank);
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool HC40_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 2e6644c..3c8de09 100644 (file)
@@ -7,14 +7,14 @@
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _HC40_MEMORY_H_
+#define _HC40_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
 #include "../device.h"
 
-class MEMORY : public DEVICE
+class HC40_MEMORY : public DEVICE
 {
 private:
        // memory
@@ -32,11 +32,11 @@ private:
        void set_bank(uint32_t val);
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       HC40_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~HC40_MEMORY() {}
        
        // common functions
        void initialize();
@@ -45,9 +45,7 @@ public:
        void write_data8(uint32_t addr, uint32_t data);
        uint32_t read_data8(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 function
        uint8_t* get_ram()
index e62a495..3837e91 100644 (file)
@@ -21,8 +21,8 @@
 #include "../debugger.h"
 #endif
 
-#include "io.h"
-#include "memory.h"
+#include "./io.h"
+#include "./memory.h"
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -41,8 +41,8 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        tf20 = new PTF20(this, emu);
        cpu = new Z80(this, emu);
        
-       io = new IO(this, emu);
-       memory = new MEMORY(this, emu);
+       io = new HC80_IO(this, emu);
+       memory = new HC80_MEMORY(this, emu);
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(beep);
@@ -70,7 +70,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()
@@ -237,69 +236,36 @@ 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::HC_80_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;
+               }
+       }
        return true;
 }
index 1fdd5f9..159cf6b 100644 (file)
@@ -56,8 +56,8 @@ class I8251;
 class PTF20;
 class Z80;
 
-class IO;
-class MEMORY;
+class HC80_IO;
+class HC80_MEMORY;
 
 class VM : public VM_TEMPLATE
 {
@@ -73,8 +73,8 @@ protected:
        PTF20* tf20;
        Z80* cpu;
        
-       IO* io;
-       MEMORY* memory;
+       HC80_IO* io;
+       HC80_MEMORY* memory;
        
 public:
        // ----------------------------------------
@@ -123,9 +123,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 1d45033..9e00c77 100644 (file)
@@ -87,7 +87,7 @@ static const uint8_t dot_tbl[8] = {
 DLL_PREFIX_I struct cur_time_s cur_time;
 #endif
 
-void IO::initialize()
+void HC80_IO::initialize()
 {
        // config
        device_type = config.device_type;
@@ -161,7 +161,7 @@ void IO::initialize()
        register_event_by_clock(this, EVENT_6303, 100, true, NULL);
 }
 
-void IO::release()
+void HC80_IO::release()
 {
        // save external ram disk
        FILEIO* fio = new FILEIO();
@@ -194,7 +194,7 @@ void IO::release()
        delete key_buf;
 }
 
-void IO::reset()
+void HC80_IO::reset()
 {
        // reset gapnit
        bcr = slbcr = isr = ier = ioctlr = 0;
@@ -223,7 +223,7 @@ void IO::reset()
        iramdisk_ptr = iramdisk_buf;
 }
 
-void IO::sysreset()
+void HC80_IO::sysreset()
 {
        // reset 7508
        onesec_intr = alarm_intr = false;
@@ -231,7 +231,7 @@ void IO::sysreset()
        res_7508 = true;
 }
 
-void IO::write_signal(int id, uint32_t data, uint32_t mask)
+void HC80_IO::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(id == SIG_IO_RXRDY) {
                // notify rxrdy is changed from i8251
@@ -258,14 +258,14 @@ void IO::write_signal(int id, uint32_t data, uint32_t mask)
        }
 }
 
-void IO::event_frame()
+void HC80_IO::event_frame()
 {
        d_beep->write_signal(SIG_BEEP_ON, beep ? 1 : 0, 1);
        beep = false;
        blink++;
 }
 
-void IO::event_callback(int event_id, int err)
+void HC80_IO::event_callback(int event_id, int err)
 {
        if(event_id == EVENT_FRC) {
                // FRC overflow event
@@ -297,7 +297,7 @@ void IO::event_callback(int event_id, int err)
        }
 }
 
-void IO::write_io8(uint32_t addr, uint32_t data)
+void HC80_IO::write_io8(uint32_t addr, uint32_t data)
 {
        //this->out_debug_log(_T("OUT %2x,%2x\n"), addr & 0xff, data);
        switch(addr & 0xff) {
@@ -400,7 +400,7 @@ void IO::write_io8(uint32_t addr, uint32_t data)
        }
 }
 
-uint32_t IO::read_io8(uint32_t addr)
+uint32_t HC80_IO::read_io8(uint32_t addr)
 {
        uint32_t val = 0xff;
 //     this->out_debug_log(_T("IN %2x\n"), addr & 0xff);
@@ -482,7 +482,7 @@ uint32_t IO::read_io8(uint32_t addr)
        return 0xff;
 }
 
-uint32_t IO::get_intr_ack()
+uint32_t HC80_IO::get_intr_ack()
 {
        if(isr & BIT_7508) {
                isr &= ~BIT_7508;
@@ -502,7 +502,7 @@ uint32_t IO::get_intr_ack()
        return 0xff;
 }
 
-void IO::update_intr()
+void HC80_IO::update_intr()
 {
        // set int signal
        bool next = ((isr & ier & 0x3f) != 0);
@@ -513,7 +513,7 @@ void IO::update_intr()
 // 7508
 // ----------------------------------------------------------------------------
 
-void IO::send_to_7508(uint8_t val)
+void HC80_IO::send_to_7508(uint8_t val)
 {
        int res;
        
@@ -772,12 +772,12 @@ void IO::send_to_7508(uint8_t val)
        }
 }
 
-uint8_t IO::rec_from_7508()
+uint8_t HC80_IO::rec_from_7508()
 {
        return rsp7508_buf->read();
 }
 
-void IO::key_down(int code)
+void HC80_IO::key_down(int code)
 {
        if(code == 0x14) {
                // toggle caps lock
@@ -789,7 +789,7 @@ void IO::key_down(int code)
        }
 }
 
-void IO::key_up(int code)
+void HC80_IO::key_up(int code)
 {
        if(code == 0x10) {
                update_key(0xa3);       // break shift
@@ -798,7 +798,7 @@ void IO::key_up(int code)
        }
 }
 
-void IO::update_key(int code)
+void HC80_IO::update_key(int code)
 {
        if(code != 0xff) {
                // add to buffer
@@ -822,7 +822,7 @@ void IO::update_key(int code)
 // 6303
 // ----------------------------------------------------------------------------
 
-void IO::process_6303()
+void HC80_IO::process_6303()
 {
        switch(cmd6303) {
        case 0x00:
@@ -1581,7 +1581,7 @@ void IO::process_6303()
        }
 }
 
-uint8_t IO::get_point(int x, int y)
+uint8_t HC80_IO::get_point(int x, int y)
 {
        if(0 <= x && x < 480 && 0 <= y && y < 64) {
                uint8_t bit = dot_tbl[x & 7];
@@ -1591,7 +1591,7 @@ uint8_t IO::get_point(int x, int y)
        return 0;
 }
 
-void IO::draw_point(int x, int y, uint16_t dot)
+void HC80_IO::draw_point(int x, int y, uint16_t dot)
 {
        if(0 <= x && x < 480 && 0 <= y && y < 64) {
                uint8_t bit = dot_tbl[x & 7];
@@ -1604,7 +1604,7 @@ void IO::draw_point(int x, int y, uint16_t dot)
        }
 }
 
-void IO::draw_line(int sx, int sy, int ex, int ey, uint16_t ope)
+void HC80_IO::draw_line(int sx, int sy, int ex, int ey, uint16_t ope)
 {
        int next_x = sx, next_y = sy;
        int delta_x = abs(ex - sx) * 2;
@@ -1684,7 +1684,7 @@ SECTOR:           0-63
 BANK:          1 or 2
 */
 
-void IO::iramdisk_write_data(uint8_t val)
+void HC80_IO::iramdisk_write_data(uint8_t val)
 {
        if(iramdisk_dest == IRAMDISK_IN && iramdisk_count) {
                *(iramdisk_ptr++) = val;
@@ -1729,7 +1729,7 @@ void IO::iramdisk_write_data(uint8_t val)
        }
 }
 
-void IO::iramdisk_write_cmd(uint8_t val)
+void HC80_IO::iramdisk_write_cmd(uint8_t val)
 {
        iramdisk_cmd = val;
        iramdisk_count = 0;
@@ -1759,7 +1759,7 @@ void IO::iramdisk_write_cmd(uint8_t val)
        }
 }
 
-uint8_t IO::iramdisk_read_data()
+uint8_t HC80_IO::iramdisk_read_data()
 {
        if(iramdisk_dest == IRAMDISK_OUT) {
                if(iramdisk_count) {
@@ -1773,7 +1773,7 @@ uint8_t IO::iramdisk_read_data()
        return 0;
 }
 
-uint8_t IO::iramdisk_read_stat()
+uint8_t HC80_IO::iramdisk_read_stat()
 {
        if(iramdisk_dest == IRAMDISK_OUT) {
                return IRAMDISK_WAIT;
@@ -1787,7 +1787,7 @@ uint8_t IO::iramdisk_read_stat()
 // ----------------------------------------------------------------------------
 
 
-void IO::draw_screen()
+void HC80_IO::draw_screen()
 {
        if(lcd_on) {
                memset(lcd, 0, sizeof(lcd));
@@ -1900,260 +1900,7 @@ void IO::draw_screen()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void IO::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_UINT32(cur_clock);
-       DECL_STATE_ENTRY_UINT8(bcr);
-       DECL_STATE_ENTRY_UINT8(slbcr);
-       DECL_STATE_ENTRY_UINT8(isr);
-       DECL_STATE_ENTRY_UINT8(ier);
-       DECL_STATE_ENTRY_UINT8(ioctlr);
-       DECL_STATE_ENTRY_UINT32(icrc);
-       DECL_STATE_ENTRY_UINT32(icrb);
-       DECL_STATE_ENTRY_BOOL(ear);
-       DECL_STATE_ENTRY_UINT8(vadr);
-       DECL_STATE_ENTRY_UINT8(yoff);
-       DECL_STATE_ENTRY_FIFO(cmd7508_buf);
-       DECL_STATE_ENTRY_FIFO(rsp7508_buf);
-       DECL_STATE_ENTRY_CUR_TIME_T(cur_time);
-       DECL_STATE_ENTRY_INT32(register_id);
-       DECL_STATE_ENTRY_BOOL(onesec_intr);
-       DECL_STATE_ENTRY_BOOL(onesec_intr_enb);
-       DECL_STATE_ENTRY_BOOL(alarm_intr);
-       DECL_STATE_ENTRY_BOOL(alarm_intr_enb);
-       DECL_STATE_ENTRY_1D_ARRAY(alarm, sizeof(alarm));
-       DECL_STATE_ENTRY_FIFO(key_buf);
-       DECL_STATE_ENTRY_BOOL(kb_intr_enb);
-       DECL_STATE_ENTRY_BOOL(kb_rep_enb);
-       DECL_STATE_ENTRY_BOOL(kb_caps);
-       DECL_STATE_ENTRY_UINT8(kb_rep_spd1);
-       DECL_STATE_ENTRY_UINT8(kb_rep_spd2);
-       DECL_STATE_ENTRY_BOOL(beep);
-       DECL_STATE_ENTRY_BOOL(res_z80);
-       DECL_STATE_ENTRY_BOOL(res_7508);
-       DECL_STATE_ENTRY_UINT8(cmd6303);
-       DECL_STATE_ENTRY_UINT8(psr);
-       DECL_STATE_ENTRY_FIFO(cmd6303_buf);
-       DECL_STATE_ENTRY_FIFO(rsp6303_buf);
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_UINT16(cs_addr);
-       DECL_STATE_ENTRY_UINT16(gs_addr);
-       DECL_STATE_ENTRY_UINT8(lcd_on);
-       DECL_STATE_ENTRY_UINT8(scr_mode);
-       DECL_STATE_ENTRY_UINT16(scr_ptr);
-       DECL_STATE_ENTRY_UINT8(num_lines);
-       DECL_STATE_ENTRY_UINT8(curs_mode);
-       DECL_STATE_ENTRY_UINT8(curs_x);
-       DECL_STATE_ENTRY_UINT8(curs_y);
-       DECL_STATE_ENTRY_UINT8(wnd_ptr_x);
-       DECL_STATE_ENTRY_UINT8(wnd_ptr_y);
-       DECL_STATE_ENTRY_UINT8(flash_block);
-       DECL_STATE_ENTRY_UINT8(cs_blocks);
-       DECL_STATE_ENTRY_2D_ARRAY(cs_block, 40, 3);
-       DECL_STATE_ENTRY_UINT8(gs_blocks);
-       DECL_STATE_ENTRY_2D_ARRAY(gs_block, 144, 3);
-       DECL_STATE_ENTRY_1D_ARRAY(font, sizeof(font));
-       DECL_STATE_ENTRY_2D_ARRAY(udgc, 256, 255+2);
-       DECL_STATE_ENTRY_2D_ARRAY(mov, 64, 80);
-       DECL_STATE_ENTRY_2D_ARRAY(lcd, SCREEN_HEIGHT, SCREEN_WIDTH);
-       DECL_STATE_ENTRY_INT32(blink);
-       DECL_STATE_ENTRY_FIFO(tf20_buf);
-       DECL_STATE_ENTRY_INT32(device_type);
-       DECL_STATE_ENTRY_1D_ARRAY(ext, sizeof(ext));
-       DECL_STATE_ENTRY_UINT32(extar);
-       DECL_STATE_ENTRY_UINT8(extcr);
-       DECL_STATE_ENTRY_3D_ARRAY(iramdisk_sectors, 15, 64, 128);
-       DECL_STATE_ENTRY_UINT8(iramdisk_cmd);
-       DECL_STATE_ENTRY_INT32(iramdisk_count);
-       DECL_STATE_ENTRY_INT32(iramdisk_dest);
-       DECL_STATE_ENTRY_1D_ARRAY(iramdisk_buf, sizeof(iramdisk_buf));
-       DECL_STATE_ENTRY_INT32(tmp_iramdisk_size); // (int)(iramdisk_ptr - iramdisk_buf));
-
-       leave_decl_state();
-}
-
-void IO::save_state(FILEIO* state_fio)
-{
-       tmp_iramdisk_size = (int)(iramdisk_ptr - iramdisk_buf);
-
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-//     state_fio->FputInt32(this_device_id);
-       
-//     state_fio->FputUint32(cur_clock);
-//     state_fio->FputUint8(bcr);
-//     state_fio->FputUint8(slbcr);
-//     state_fio->FputUint8(isr);
-//     state_fio->FputUint8(ier);
-//     state_fio->FputUint8(ioctlr);
-//     state_fio->FputUint32(icrc);
-///    state_fio->FputUint32(icrb);
-//     state_fio->FputBool(ear);
-//     state_fio->FputUint8(vadr);
-//     state_fio->FputUint8(yoff);
-//     cmd7508_buf->save_state((void *)state_fio);
-//     rsp7508_buf->save_state((void *)state_fio);
-//     cur_time.save_state((void *)state_fio);
-//     state_fio->FputInt32(register_id);
-//     state_fio->FputBool(onesec_intr);
-//     state_fio->FputBool(onesec_intr_enb);
-//     state_fio->FputBool(alarm_intr);
-//     state_fio->FputBool(alarm_intr_enb);
-//     state_fio->Fwrite(alarm, sizeof(alarm), 1);
-//     key_buf->save_state((void *)state_fio);
-//     state_fio->FputBool(kb_intr_enb);
-//     state_fio->FputBool(kb_rep_enb);
-//     state_fio->FputBool(kb_caps);
-//     state_fio->FputUint8(kb_rep_spd1);
-//     state_fio->FputUint8(kb_rep_spd2);
-//     state_fio->FputBool(beep);
-//     state_fio->FputBool(res_z80);
-//     state_fio->FputBool(res_7508);
-//     state_fio->FputUint8(cmd6303);
-//     state_fio->FputUint8(psr);
-//     cmd6303_buf->save_state((void *)state_fio);
-//     rsp6303_buf->save_state((void *)state_fio);
-//     state_fio->Fwrite(ram, sizeof(ram), 1);
-//     state_fio->FputUint16(cs_addr);
-//     state_fio->FputUint16(gs_addr);
-//     state_fio->FputUint8(lcd_on);
-//     state_fio->FputUint8(scr_mode);
-//     state_fio->FputUint16(scr_ptr);
-//     state_fio->FputUint8(num_lines);
-//     state_fio->FputUint8(curs_mode);
-//     state_fio->FputUint8(curs_x);
-//     state_fio->FputUint8(curs_y);
-//     state_fio->FputUint8(wnd_ptr_x);
-//     state_fio->FputUint8(wnd_ptr_y);
-//     state_fio->FputUint8(flash_block);
-//     state_fio->FputUint8(cs_blocks);
-//     state_fio->Fwrite(cs_block, sizeof(cs_block), 1);
-//     state_fio->FputUint8(gs_blocks);
-//     state_fio->Fwrite(gs_block, sizeof(gs_block), 1);
-//     state_fio->Fwrite(font, sizeof(font), 1);
-//     state_fio->Fwrite(udgc, sizeof(udgc), 1);
-//     state_fio->Fwrite(mov, sizeof(mov), 1);
-//     state_fio->Fwrite(lcd, sizeof(lcd), 1);
-//     state_fio->FputInt32(blink);
-//     tf20_buf->save_state((void *)state_fio);
-//     state_fio->FputInt32(device_type);
-//     state_fio->Fwrite(ext, sizeof(ext), 1);
-//     state_fio->FputUint32(extar);
-//     state_fio->FputUint8(extcr);
-//     state_fio->Fwrite(iramdisk_sectors, sizeof(iramdisk_sectors), 1);
-//     state_fio->FputUint8(iramdisk_cmd);
-//     state_fio->FputInt32(iramdisk_count);
-//     state_fio->FputInt32(iramdisk_dest);
-//     state_fio->Fwrite(iramdisk_buf, sizeof(iramdisk_buf), 1);
-//     state_fio->FputInt32((int)(iramdisk_ptr - iramdisk_buf));
-}
-
-bool IO::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;
-//     }
-//     cur_clock = state_fio->FgetUint32();
-//     bcr = state_fio->FgetUint8();
-//     slbcr = state_fio->FgetUint8();
-//     isr = state_fio->FgetUint8();
-//     ier = state_fio->FgetUint8();
-//     ioctlr = state_fio->FgetUint8();
-//     icrc = state_fio->FgetUint32();
-//     icrb = state_fio->FgetUint32();
-//     ear = state_fio->FgetBool();
-//     vadr = state_fio->FgetUint8();
-//     yoff = state_fio->FgetUint8();
-//     if(!cmd7508_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     if(!rsp7508_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     if(!cur_time.load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     register_id = state_fio->FgetInt32();
-//     onesec_intr = state_fio->FgetBool();
-//     onesec_intr_enb = state_fio->FgetBool();
-//     alarm_intr = state_fio->FgetBool();
-//     alarm_intr_enb = state_fio->FgetBool();
-//     state_fio->Fread(alarm, sizeof(alarm), 1);
-//     if(!key_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     kb_intr_enb = state_fio->FgetBool();
-//     kb_rep_enb = state_fio->FgetBool();
-//     kb_caps = state_fio->FgetBool();
-//     kb_rep_spd1 = state_fio->FgetUint8();
-//     kb_rep_spd2 = state_fio->FgetUint8();
-//     beep = state_fio->FgetBool();
-//     res_z80 = state_fio->FgetBool();
-//     res_7508 = state_fio->FgetBool();
-//     cmd6303 = state_fio->FgetUint8();
-//     psr = state_fio->FgetUint8();
-//     if(!cmd6303_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     if(!rsp6303_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     state_fio->Fread(ram, sizeof(ram), 1);
-//     cs_addr = state_fio->FgetUint16();
-//     gs_addr = state_fio->FgetUint16();
-//     lcd_on = state_fio->FgetUint8();
-//     scr_mode = state_fio->FgetUint8();
-//     scr_ptr = state_fio->FgetUint16();
-//     num_lines = state_fio->FgetUint8();
-//     curs_mode = state_fio->FgetUint8();
-//     curs_x = state_fio->FgetUint8();
-//     curs_y = state_fio->FgetUint8();
-//     wnd_ptr_x = state_fio->FgetUint8();
-//     wnd_ptr_y = state_fio->FgetUint8();
-//     flash_block = state_fio->FgetUint8();
-//     cs_blocks = state_fio->FgetUint8();
-//     state_fio->Fread(cs_block, sizeof(cs_block), 1);
-//     gs_blocks = state_fio->FgetUint8();
-//     state_fio->Fread(gs_block, sizeof(gs_block), 1);
-//     state_fio->Fread(font, sizeof(font), 1);
-//     state_fio->Fread(udgc, sizeof(udgc), 1);
-//     state_fio->Fread(mov, sizeof(mov), 1);
-//     state_fio->Fread(lcd, sizeof(lcd), 1);
-//     blink = state_fio->FgetInt32();
-//     if(!tf20_buf->load_state((void *)state_fio)) {
-//             return false;
-//     }
-//     device_type = state_fio->FgetInt32();
-//     state_fio->Fread(ext, sizeof(ext), 1);
-//     extar = state_fio->FgetUint32();
-//     extcr = state_fio->FgetUint8();
-//     state_fio->Fread(iramdisk_sectors, sizeof(iramdisk_sectors), 1);
-//     iramdisk_cmd = state_fio->FgetUint8();
-//     iramdisk_count = state_fio->FgetInt32();
-//     iramdisk_dest = state_fio->FgetInt32();
-//     state_fio->Fread(iramdisk_buf, sizeof(iramdisk_buf), 1);
-       
-       iramdisk_ptr = iramdisk_buf + tmp_iramdisk_size;
-       return true;
-}
-
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool HC80_IO::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 7af8846..2cec7d1 100644 (file)
@@ -7,8 +7,8 @@
        [ i/o ]
 */
 
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _HC80_IO_H_
+#define _HC80_IO_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -20,7 +20,7 @@
 
 class FIFO;
 
-class IO : public DEVICE
+class HC80_IO : public DEVICE
 {
 private:
        DEVICE *d_cpu, *d_mem, *d_sio, *d_beep, *d_tf20;
@@ -110,13 +110,12 @@ private:
        uint8_t iramdisk_buf[130];
        uint8_t *iramdisk_ptr;
 
-       int tmp_iramdisk_size;
 public:
-       IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       HC80_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("I/O Bus"));
        }
-       ~IO() {}
+       ~HC80_IO() {}
        
        // common functions
        void initialize();
@@ -129,9 +128,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
        uint32_t get_intr_ack();
-       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 2493cf9..33394ed 100644 (file)
@@ -25,7 +25,7 @@
        } \
 }
 
-void MEMORY::initialize()
+void HC80_MEMORY::initialize()
 {
        // initialize memory
        memset(ram, 0, sizeof(ram));
@@ -45,7 +45,7 @@ void MEMORY::initialize()
        delete fio;
 }
 
-void MEMORY::release()
+void HC80_MEMORY::release()
 {
        // save battery backuped ram
        FILEIO* fio = new FILEIO();
@@ -56,29 +56,29 @@ void MEMORY::release()
        delete fio;
 }
 
-void MEMORY::reset()
+void HC80_MEMORY::reset()
 {
        set_bank(0);
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void HC80_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
        wbank[(addr >> 13) & 7][addr & 0x1fff] = data;
 }
 
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t HC80_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
        return rbank[(addr >> 13) & 7][addr & 0x1fff];
 }
 
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void HC80_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        set_bank(data);
 }
 
-void MEMORY::set_bank(uint32_t val)
+void HC80_MEMORY::set_bank(uint32_t val)
 {
        if(val & 1) {
                SET_BANK(0x0000, 0xffff, ram, ram);
@@ -91,54 +91,7 @@ void MEMORY::set_bank(uint32_t val)
 
 #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_UINT8(bank);
-       
-       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->FputUint8(bank);
-}
-
-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);
-//     bank = state_fio->FgetUint8();
-       
-       // post process
-       set_bank(bank);
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool HC80_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 0c466fd..a8620c6 100644 (file)
@@ -7,14 +7,14 @@
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _HC80_MEMORY_H_
+#define _HC80_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
 #include "../device.h"
 
-class MEMORY : public DEVICE
+class HC80_MEMORY : public DEVICE
 {
 private:
        // memory
@@ -30,11 +30,11 @@ private:
        void set_bank(uint32_t val);
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       HC80_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~HC80_MEMORY() {}
        
        // common functions
        void initialize();
@@ -43,9 +43,7 @@ public:
        void write_data8(uint32_t addr, uint32_t data);
        uint32_t read_data8(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);
 };
 
 #endif
index d975e00..ce1a798 100644 (file)
@@ -447,394 +447,133 @@ int I286::get_shutdown_flag()
 }
 #endif
 
-typedef struct i286_dtr_1_t{
-       UINT32 base;
-       UINT16 limit;
-};
-typedef struct i286_dtr_2_t{
-       UINT16 sel;
-       UINT32 base;
-       UINT16 limit;
-       UINT8 rights;
-};
-
-#if 0
-#include "../statesub.h"
+#define STATE_VERSION  5
 
-
-void I286::decl_state_cpustate()
+void I286::process_state_cpustate(FILEIO* state_fio, bool loading)
 {
-#if defined(HAS_I286)
-       struct i80286_state *state = (i80286_state *)opaque;
-       //state_fio->Fwrite(&(state->regs), sizeof(i80286basicregs), 1);
-       for(int i = 0; i < 8; i++) {
-               DECL_STATE_ENTRY_UINT16_MEMBER((state->regs.w[i]), i);
-       }
-       DECL_STATE_ENTRY_UINT32((state->amask));
-       DECL_STATE_ENTRY_UINT32((state->pc));
-       DECL_STATE_ENTRY_UINT32((state->prevpc));
-       DECL_STATE_ENTRY_UINT16((state->flags));
-       DECL_STATE_ENTRY_UINT16((state->msw));
-       DECL_STATE_ENTRY_1D_ARRAY((state->base), 4);
-       DECL_STATE_ENTRY_1D_ARRAY((state->sregs), 4);
-       DECL_STATE_ENTRY_1D_ARRAY((state->limit), 4);
-       DECL_STATE_ENTRY_1D_ARRAY((state->rights), 4);
-       DECL_STATE_ENTRY_1D_ARRAY((state->valid), 4);
-       
-       DECL_STATE_ENTRY_UINT32((state->gdtr.base));
-       DECL_STATE_ENTRY_UINT16((state->gdtr.limit));
+#if defined(HAS_I86) || defined(HAS_I88) || defined(HAS_I186) || defined(HAS_V30)
+       struct i8086_state *cpustate = (struct i8086_state *)opaque;
 
-       DECL_STATE_ENTRY_UINT32((state->idtr.base));
-       DECL_STATE_ENTRY_UINT16((state->idtr.limit));
-       
-       DECL_STATE_ENTRY_UINT16((state->ldtr.sel));
-       DECL_STATE_ENTRY_UINT32((state->ldtr.base));
-       DECL_STATE_ENTRY_UINT32((state->ldtr.limit));
-       DECL_STATE_ENTRY_UINT32((state->ldtr.rights));
-
-       DECL_STATE_ENTRY_UINT16((state->tr.sel));
-       DECL_STATE_ENTRY_UINT32((state->tr.base));
-       DECL_STATE_ENTRY_UINT32((state->tr.limit));
-       DECL_STATE_ENTRY_UINT32((state->tr.rights));
-
-       DECL_STATE_ENTRY_INT32((state->AuxVal));
-       DECL_STATE_ENTRY_INT32((state->OverVal));
-       DECL_STATE_ENTRY_INT32((state->SignVal));
-       DECL_STATE_ENTRY_INT32((state->ZeroVal));
-       DECL_STATE_ENTRY_INT32((state->CarryVal));
-       DECL_STATE_ENTRY_INT32((state->DirVal));
-       
-       DECL_STATE_ENTRY_UINT8((state->ParityVal));
-       DECL_STATE_ENTRY_UINT8((state->TF));
-       DECL_STATE_ENTRY_UINT8((state->IF));
-       DECL_STATE_ENTRY_UINT8((state->MF));
-       DECL_STATE_ENTRY_INT8((state->nmi_state));
-       DECL_STATE_ENTRY_INT8((state->irq_state));
-       DECL_STATE_ENTRY_INT8((state->test_state));
-       
-       DECL_STATE_ENTRY_UINT8((state->rep_in_progress));       
-       DECL_STATE_ENTRY_INT32((state->extra_cycles));
-       
-       DECL_STATE_ENTRY_INT32((state->halted));
-       DECL_STATE_ENTRY_INT32((state->busreq));
-       DECL_STATE_ENTRY_INT32((state->trap_level));
-       DECL_STATE_ENTRY_INT32((state->shutdown));
-       DECL_STATE_ENTRY_INT32((state->icount));
-
-       DECL_STATE_ENTRY_UINT8((state->seg_prefix));
-       DECL_STATE_ENTRY_UINT8((state->prefix_seg));
-       
-       DECL_STATE_ENTRY_UINT32((state->ea));
-       DECL_STATE_ENTRY_UINT16((state->eo));
-       DECL_STATE_ENTRY_UINT8((state->ea_seg));
-
-#  ifdef USE_DEBUGGER
-       DECL_STATE_ENTRY_UINT64((state->total_icount));
-#  endif
-#else // not I286
-
-       struct i8086_state *state = (i8086_state *)opaque;
-       for(int i = 0; i < 8; i++) {
-               DECL_STATE_ENTRY_UINT16_MEMBER((state->regs.w[i]), i);
+       state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+       state_fio->StateUint32(cpustate->pc);
+       state_fio->StateUint32(cpustate->prevpc);
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint32(cpustate->base[i]);
        }
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint16(cpustate->sregs[i]);
+       }
+       state_fio->StateUint16(cpustate->flags);
+       state_fio->StateInt32(cpustate->AuxVal);
+       state_fio->StateInt32(cpustate->OverVal);
+       state_fio->StateInt32(cpustate->SignVal);
+       state_fio->StateInt32(cpustate->ZeroVal);
+       state_fio->StateInt32(cpustate->CarryVal);
+       state_fio->StateInt32(cpustate->DirVal);
+       state_fio->StateUint8(cpustate->ParityVal);
+       state_fio->StateUint8(cpustate->TF);
+       state_fio->StateUint8(cpustate->IF);
+       state_fio->StateUint8(cpustate->MF);
+       
+       state_fio->StateUint8(cpustate->int_vector);
+       state_fio->StateInt8(cpustate->nmi_state);
+       state_fio->StateInt8(cpustate->irq_state);
+       state_fio->StateInt8(cpustate->test_state);
+       state_fio->StateUint8(cpustate->rep_in_progress);
+       state_fio->StateInt32(cpustate->extra_cycles);
+
+       state_fio->StateInt32(cpustate->halted);
+       state_fio->StateInt32(cpustate->busreq);
+
+       state_fio->StateUint16(cpustate->ip);
+       state_fio->StateUint32(cpustate->sp);
+
+  #ifdef USE_DEBUGGER
+       state_fio->StateUint64(cpustate->total_icount);
+  #endif
+       state_fio->StateInt32(cpustate->icount);
+
+       state_fio->StateUint8(cpustate->seg_prefix);
+       state_fio->StateUint8(cpustate->prefix_seg);
+       state_fio->StateUint32(cpustate->ea);
+       state_fio->StateUint16(cpustate->eo);
+       state_fio->StateUint8(cpustate->ea_seg);
 
-       DECL_STATE_ENTRY_UINT32((state->pc));
-       DECL_STATE_ENTRY_UINT32((state->prevpc));
-       DECL_STATE_ENTRY_1D_ARRAY((state->base), 4);
-       DECL_STATE_ENTRY_1D_ARRAY((state->sregs), 4);
-       
-       DECL_STATE_ENTRY_UINT16((state->flags));
-
-       DECL_STATE_ENTRY_INT32((state->AuxVal));
-       DECL_STATE_ENTRY_INT32((state->OverVal));
-       DECL_STATE_ENTRY_INT32((state->SignVal));
-       DECL_STATE_ENTRY_INT32((state->ZeroVal));
-       DECL_STATE_ENTRY_INT32((state->CarryVal));
-       DECL_STATE_ENTRY_INT32((state->DirVal));
-       
-       DECL_STATE_ENTRY_UINT8((state->ParityVal));
-       DECL_STATE_ENTRY_UINT8((state->TF));
-       DECL_STATE_ENTRY_UINT8((state->IF));
-       DECL_STATE_ENTRY_UINT8((state->MF));
-       
-       DECL_STATE_ENTRY_UINT8((state->int_vector));
-
-       DECL_STATE_ENTRY_INT8((state->nmi_state));
-       DECL_STATE_ENTRY_INT8((state->irq_state));
-       DECL_STATE_ENTRY_INT8((state->test_state));
-       
-       DECL_STATE_ENTRY_UINT8((state->rep_in_progress));       
-       DECL_STATE_ENTRY_INT32((state->extra_cycles));
-       
-       DECL_STATE_ENTRY_INT32((state->halted));
-       DECL_STATE_ENTRY_INT32((state->busreq));
-
-       DECL_STATE_ENTRY_UINT16((state->ip));
-       DECL_STATE_ENTRY_UINT32((state->sp));
-       
-       DECL_STATE_ENTRY_INT32((state->icount));
-
-       DECL_STATE_ENTRY_UINT8((state->seg_prefix));
-       DECL_STATE_ENTRY_UINT8((state->prefix_seg));
-       
-       DECL_STATE_ENTRY_UINT32((state->ea));
-       DECL_STATE_ENTRY_UINT16((state->eo));
-       DECL_STATE_ENTRY_UINT8((state->ea_seg));
-       
-#  ifdef USE_DEBUGGER
-       DECL_STATE_ENTRY_UINT64((state->total_icount));
-#  endif
-#endif
-}
-#endif
+#elif defined(HAS_I286)
 
-void I286::save_state_cpustate(FILEIO* state_fio)
-{
-#if defined(HAS_I286)
-       struct i80286_state *state = (i80286_state *)opaque;
-       state_fio->Fwrite(&(state->regs), sizeof(i80286basicregs), 1);
-       state_fio->Fwrite(&(state->amask), sizeof(UINT32), 1);
-       state_fio->Fwrite(&(state->pc), sizeof(UINT32), 1);
-       state_fio->Fwrite(&(state->prevpc), sizeof(UINT32), 1);
-       state_fio->Fwrite(&(state->flags), sizeof(UINT16), 1);
-       state_fio->Fwrite(&(state->msw), sizeof(UINT16), 1);
-       
-       state_fio->Fwrite(&(state->base[0]), sizeof(UINT32) * 4, 1);
-       state_fio->Fwrite(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-       
-       state_fio->Fwrite(&(state->limit[0]), sizeof(UINT16) * 4, 1);
-       state_fio->Fwrite(&(state->rights[0]), sizeof(UINT8) * 4, 1);
-       
-       state_fio->Fwrite(&(state->valid), sizeof(bool) * 4, 1);
-       
-       state_fio->Fwrite(&(state->gdtr), sizeof(i286_dtr_1_t), 1);
-       state_fio->Fwrite(&(state->idtr), sizeof(i286_dtr_1_t), 1);
-       state_fio->Fwrite(&(state->ldtr), sizeof(i286_dtr_2_t), 1);
-       state_fio->Fwrite(&(state->tr), sizeof(i286_dtr_2_t), 1);
-       
-       state_fio->Fwrite(&(state->pic), sizeof(DEVICE *), 1);
-       state_fio->Fwrite(&(state->program), sizeof(DEVICE *), 1);
-       state_fio->Fwrite(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
-       state_fio->Fwrite(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
-       state_fio->Fwrite(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
-       state_fio->Fwrite(&(state->emu), sizeof(EMU *), 1);
-       state_fio->Fwrite(&(state->debugger), sizeof(DEBUGGER *), 1);
-       state_fio->Fwrite(&(state->program_stored), sizeof(DEVICE *), 1);
-       state_fio->Fwrite(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
-       //INT32   AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
-       state_fio->Fwrite(&(state->AuxVal), sizeof(INT32) * 6, 1);
-       //UINT8   ParityVal;
-       //UINT8   TF, IF;     /* 0 or 1 valued flags */
-       //UINT8   MF;         /* V30 mode flag */
-       state_fio->Fwrite(&(state->ParityVal), sizeof(UINT8) * 4, 1);
-       //INT8    nmi_state;
-       //INT8    irq_state;
-       //INT8    test_state;
-       state_fio->Fwrite(&(state->nmi_state), sizeof(INT8) * 3, 1);
-       //UINT8 rep_in_progress;
-       state_fio->Fwrite(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
-       //INT32   extra_cycles;       /* extra cycles for interrupts */
-       state_fio->Fwrite(&(state->extra_cycles), sizeof(INT32) * 1, 1);
-       //int halted;         /* Is the CPU halted ? */
-       //int busreq;
-       //int trap_level;
-       //int shutdown;
-       //int icount;
-       state_fio->Fwrite(&(state->halted), sizeof(int) * 5, 1);
-       state_fio->Fwrite(&(state->seg_prefix), sizeof(char) * 1, 1);
-       state_fio->Fwrite(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
-       state_fio->Fwrite(&(state->ea), sizeof(unsigned), 1);
-       state_fio->Fwrite(&(state->eo), sizeof(UINT16), 1);
-       state_fio->Fwrite(&(state->ea_seg), sizeof(UINT8), 1);
-
-#else // not I286
-
-       struct i8086_state *state = (i8086_state *)opaque;
-       state_fio->Fwrite(&(state->regs), sizeof(i8086basicregs), 1);
-       state_fio->Fwrite(&(state->pc), sizeof(UINT32), 1);
-       state_fio->Fwrite(&(state->prevpc), sizeof(UINT32), 1);
-       state_fio->Fwrite(&(state->base[0]), sizeof(UINT32) * 4, 1);
-       state_fio->Fwrite(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-       
-       state_fio->Fwrite(&(state->flags), sizeof(UINT16), 1);
-
-       //INT32   AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
-       state_fio->Fwrite(&(state->AuxVal), sizeof(INT32) * 6, 1);
-       //UINT8   ParityVal;
-       //UINT8   TF, IF;     /* 0 or 1 valued flags */
-       //UINT8   MF;         /* V30 mode flag */
-       state_fio->Fwrite(&(state->ParityVal), sizeof(UINT8) * 4, 1);
-       state_fio->Fwrite(&(state->int_vector), sizeof(UINT8), 1);
-       //INT8    nmi_state;
-       //INT8    irq_state;
-       //INT8    test_state;
-       state_fio->Fwrite(&(state->nmi_state), sizeof(INT8) * 3, 1);
-       //UINT8 rep_in_progress;
-       state_fio->Fwrite(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
-       //INT32   extra_cycles;       /* extra cycles for interrupts */
-       state_fio->Fwrite(&(state->extra_cycles), sizeof(INT32) * 1, 1);
-       //int halted;         /* Is the CPU halted ? */
-       //int busreq;
-       state_fio->Fwrite(&(state->halted), sizeof(int) * 2, 1);
-
-       state_fio->Fwrite(&(state->ip), sizeof(UINT16) * 1, 1);
-       state_fio->Fwrite(&(state->sp), sizeof(UINT32) * 1, 1);
-       
-       state_fio->Fwrite(&(state->pic), sizeof(DEVICE *), 1);
-       state_fio->Fwrite(&(state->program), sizeof(DEVICE *), 1);
-       state_fio->Fwrite(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
-       state_fio->Fwrite(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
-       state_fio->Fwrite(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
-       state_fio->Fwrite(&(state->emu), sizeof(EMU *), 1);
-       state_fio->Fwrite(&(state->debugger), sizeof(DEBUGGER *), 1);
-       state_fio->Fwrite(&(state->program_stored), sizeof(DEVICE *), 1);
-       state_fio->Fwrite(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
-       state_fio->Fwrite(&(state->icount), sizeof(int) * 1, 1);
-       state_fio->Fwrite(&(state->seg_prefix), sizeof(char) * 1, 1);
-       state_fio->Fwrite(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
-       state_fio->Fwrite(&(state->ea), sizeof(unsigned), 1);
-       state_fio->Fwrite(&(state->eo), sizeof(UINT16), 1);
-       state_fio->Fwrite(&(state->ea_seg), sizeof(UINT8), 1);
-#endif
-}
+       struct i80286_state *cpustate = (struct i80286_state *)opaque;
 
-void I286::load_state_cpustate(FILEIO* state_fio)
-{
-#if defined(HAS_I286)
-       struct i80286_state *state = (i80286_state *)opaque;
-       state_fio->Fread(&(state->regs), sizeof(i80286basicregs), 1);
-       state_fio->Fread(&(state->amask), sizeof(UINT32), 1);
-       state_fio->Fread(&(state->pc), sizeof(UINT32), 1);
-       state_fio->Fread(&(state->prevpc), sizeof(UINT32), 1);
-       state_fio->Fread(&(state->flags), sizeof(UINT16), 1);
-       state_fio->Fread(&(state->msw), sizeof(UINT16), 1);
-       
-       state_fio->Fread(&(state->base[0]), sizeof(UINT32) * 4, 1);
-       state_fio->Fread(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-       
-       state_fio->Fread(&(state->limit[0]), sizeof(UINT16) * 4, 1);
-       state_fio->Fread(&(state->rights[0]), sizeof(UINT8) * 4, 1);
-       
-       state_fio->Fread(&(state->valid), sizeof(bool) * 4, 1);
-       
-       state_fio->Fread(&(state->gdtr), sizeof(i286_dtr_1_t), 1);
-       state_fio->Fread(&(state->idtr), sizeof(i286_dtr_1_t), 1);
-       state_fio->Fread(&(state->ldtr), sizeof(i286_dtr_2_t), 1);
-       state_fio->Fread(&(state->tr), sizeof(i286_dtr_2_t), 1);
-       
-       state_fio->Fread(&(state->pic), sizeof(DEVICE *), 1);
-       state_fio->Fread(&(state->program), sizeof(DEVICE *), 1);
-       state_fio->Fread(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
-       state_fio->Fread(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
-       state_fio->Fread(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
-       state_fio->Fread(&(state->emu), sizeof(EMU *), 1);
-       state_fio->Fread(&(state->debugger), sizeof(DEBUGGER *), 1);
-       state_fio->Fread(&(state->program_stored), sizeof(DEVICE *), 1);
-       state_fio->Fread(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
-       //INT32   AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
-       state_fio->Fread(&(state->AuxVal), sizeof(INT32) * 6, 1);
-       //UINT8   ParityVal;
-       //UINT8   TF, IF;     /* 0 or 1 valued flags */
-       //UINT8   MF;         /* V30 mode flag */
-       state_fio->Fread(&(state->ParityVal), sizeof(UINT8) * 4, 1);
-       //INT8    nmi_state;
-       //INT8    irq_state;
-       //INT8    test_state;
-       state_fio->Fread(&(state->nmi_state), sizeof(INT8) * 3, 1);
-       //UINT8 rep_in_progress;
-       state_fio->Fread(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
-       //INT32   extra_cycles;       /* extra cycles for interrupts */
-       state_fio->Fread(&(state->extra_cycles), sizeof(INT32) * 1, 1);
-       //int halted;         /* Is the CPU halted ? */
-       //int busreq;
-       //int trap_level;
-       //int shutdown;
-       //int icount;
-       state_fio->Fread(&(state->halted), sizeof(int) * 5, 1);
-       state_fio->Fread(&(state->seg_prefix), sizeof(char) * 1, 1);
-       state_fio->Fread(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
-       state_fio->Fread(&(state->ea), sizeof(unsigned), 1);
-       state_fio->Fread(&(state->eo), sizeof(UINT16), 1);
-       state_fio->Fread(&(state->ea_seg), sizeof(UINT8), 1);
-
-#else // not I286
-
-       struct i8086_state *state = (i8086_state *)opaque;
-       state_fio->Fread(&(state->regs), sizeof(i8086basicregs), 1);
-       state_fio->Fread(&(state->pc), sizeof(UINT32), 1);
-       state_fio->Fread(&(state->prevpc), sizeof(UINT32), 1);
-       state_fio->Fread(&(state->base[0]), sizeof(UINT32) * 4, 1);
-       state_fio->Fread(&(state->sregs[0]), sizeof(UINT16) * 4, 1);
-       
-       state_fio->Fread(&(state->flags), sizeof(UINT16), 1);
-
-       //INT32   AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */
-       state_fio->Fread(&(state->AuxVal), sizeof(INT32) * 6, 1);
-       //UINT8   ParityVal;
-       //UINT8   TF, IF;     /* 0 or 1 valued flags */
-       //UINT8   MF;         /* V30 mode flag */
-       state_fio->Fread(&(state->ParityVal), sizeof(UINT8) * 4, 1);
-       state_fio->Fread(&(state->int_vector), sizeof(UINT8), 1);
-       //INT8    nmi_state;
-       //INT8    irq_state;
-       //INT8    test_state;
-       state_fio->Fread(&(state->nmi_state), sizeof(INT8) * 3, 1);
-       //UINT8 rep_in_progress;
-       state_fio->Fread(&(state->rep_in_progress), sizeof(UINT8) * 1, 1);
-       //INT32   extra_cycles;       /* extra cycles for interrupts */
-       state_fio->Fread(&(state->extra_cycles), sizeof(INT32) * 1, 1);
-       //int halted;         /* Is the CPU halted ? */
-       //int busreq;
-       state_fio->Fread(&(state->halted), sizeof(int) * 2, 1);
-
-       state_fio->Fread(&(state->ip), sizeof(UINT16) * 1, 1);
-       state_fio->Fread(&(state->sp), sizeof(UINT32) * 1, 1);
-       
-       state_fio->Fread(&(state->pic), sizeof(DEVICE *), 1);
-       state_fio->Fread(&(state->program), sizeof(DEVICE *), 1);
-       state_fio->Fread(&(state->io), sizeof(DEVICE *), 1);
-#ifdef I86_PSEUDO_BIOS
-       state_fio->Fread(&(state->bios), sizeof(DEVICE *), 1);
-#endif
-#ifdef SINGLE_MODE_DMA
-       state_fio->Fread(&(state->dma), sizeof(DEVICE *), 1);
-#endif
-#ifdef USE_DEBUGGER
-       state_fio->Fread(&(state->emu), sizeof(EMU *), 1);
-       state_fio->Fread(&(state->debugger), sizeof(DEBUGGER *), 1);
-       state_fio->Fread(&(state->program_stored), sizeof(DEVICE *), 1);
-       state_fio->Fread(&(state->io_stored), sizeof(DEVICE *), 1);
-#endif
-       state_fio->Fread(&(state->icount), sizeof(int) * 1, 1);
-       state_fio->Fread(&(state->seg_prefix), sizeof(char) * 1, 1);
-       state_fio->Fread(&(state->prefix_seg), sizeof(UINT8) * 1, 1);
-       state_fio->Fread(&(state->ea), sizeof(unsigned), 1);
-       state_fio->Fread(&(state->eo), sizeof(UINT16), 1);
-       state_fio->Fread(&(state->ea_seg), sizeof(UINT8), 1);
+       state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+       state_fio->StateUint32(cpustate->amask);
+       state_fio->StateUint32(cpustate->pc);
+       state_fio->StateUint32(cpustate->prevpc);
+       state_fio->StateUint16(cpustate->flags);
+       state_fio->StateUint16(cpustate->msw);
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint32(cpustate->base[i]);
+       }
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint16(cpustate->sregs[i]);
+       }
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint16(cpustate->limit[i]);
+       }
+       state_fio->StateBuffer(cpustate->rights, 4, 1);
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateBool(cpustate->valid[i]);
+       }
+       state_fio->StateUint32(cpustate->gdtr.base);
+       state_fio->StateUint16(cpustate->gdtr.limit);
+
+       state_fio->StateUint32(cpustate->idtr.base);
+       state_fio->StateUint16(cpustate->idtr.limit);
+
+       state_fio->StateUint16(cpustate->ldtr.sel);
+       state_fio->StateUint32(cpustate->ldtr.base);
+       state_fio->StateUint16(cpustate->ldtr.limit);
+       state_fio->StateUint8(cpustate->ldtr.rights);
+       
+       state_fio->StateUint16(cpustate->tr.sel);
+       state_fio->StateUint32(cpustate->tr.base);
+       state_fio->StateUint16(cpustate->tr.limit);
+       state_fio->StateUint8(cpustate->tr.rights);
+       
+       state_fio->StateInt32(cpustate->AuxVal);
+       state_fio->StateInt32(cpustate->OverVal);
+       state_fio->StateInt32(cpustate->SignVal);
+       state_fio->StateInt32(cpustate->ZeroVal);
+       state_fio->StateInt32(cpustate->CarryVal);
+       state_fio->StateInt32(cpustate->DirVal);
+       state_fio->StateUint8(cpustate->ParityVal);
+       state_fio->StateUint8(cpustate->TF);
+       state_fio->StateUint8(cpustate->IF);
+       state_fio->StateUint8(cpustate->MF);
+       
+       state_fio->StateInt8(cpustate->nmi_state);
+       state_fio->StateInt8(cpustate->irq_state);
+       state_fio->StateInt8(cpustate->test_state);
+       state_fio->StateUint8(cpustate->rep_in_progress);
+       state_fio->StateInt32(cpustate->extra_cycles);
+
+       state_fio->StateInt32(cpustate->halted);
+       state_fio->StateInt32(cpustate->busreq);
+       state_fio->StateInt32(cpustate->trap_level);
+       state_fio->StateInt32(cpustate->shutdown);
+
+
+  #ifdef USE_DEBUGGER
+       state_fio->StateUint64(cpustate->total_icount);
+  #endif
+       state_fio->StateInt32(cpustate->icount);
+
+       state_fio->StateUint8(cpustate->seg_prefix);
+       state_fio->StateUint8(cpustate->prefix_seg);
+       state_fio->StateUint32(cpustate->ea);
+       state_fio->StateUint16(cpustate->eo);
+       state_fio->StateUint8(cpustate->ea_seg);
 #endif
 }
 
-
-#define STATE_VERSION  4
-
 bool I286::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
@@ -843,7 +582,8 @@ bool I286::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+       //state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+       process_state_cpustate(state_fio, loading);
        
        // post process
        if(loading) {
index ab3257d..13ba0d7 100644 (file)
@@ -108,6 +108,7 @@ public:
        void save_state_cpustate(FILEIO* state_fio);
        void load_state_cpustate(FILEIO* state_fio);
        
+       void process_state_cpustate(FILEIO* state_fio, bool loading);
        bool process_state(FILEIO* state_fio, bool loading);
        
        // unique function
index facfb11..1627e06 100644 (file)
@@ -425,41 +425,32 @@ 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;
+               }
+       }
        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 "
-               int len = strlen(name);
-               
-               if(!state_fio->StateCheckInt32(len)) {
-                       return false;
-               }
-               if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
-               if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
-       return true;
-}
index ecbab75..f766202 100644 (file)
@@ -24,7 +24,7 @@
 #include "../debugger.h"
 #endif
 
-#include "memory.h"
+#include "./memory.h"
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -51,7 +51,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        pcm = new PCM1BIT(this, emu);
        via = new SY6522(this, emu);
        
-       memory = new MEMORY(this, emu);
+       memory = new JR100_MEMORY(this, emu);
        // set contexts
        event->set_context_cpu(cpu);
        event->set_context_sound(pcm);
@@ -88,7 +88,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()
@@ -289,69 +288,36 @@ 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::JR_100_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;
+               }
+       }
        return true;
 }
index 7dbe5d8..9af3fe6 100644 (file)
@@ -111,7 +111,6 @@ static const _TCHAR *sound_device_caption[] = {
 };
 #endif
 
-class csp_state_utils;
 class EMU;
 class DEVICE;
 class EVENT;
@@ -123,13 +122,12 @@ class NOT;
 class PCM1BIT;
 class SY6522;
 
-class MEMORY;
+class JR100_MEMORY;
 
 class VM : public VM_TEMPLATE
 {
 protected:
        //EMU* emu;
-       //csp_state_utils *state_entry;
        
        // devices
        //EVENT* event;
@@ -142,7 +140,7 @@ protected:
        PCM1BIT* pcm;
        SY6522* via;
        
-       MEMORY* memory;
+       JR100_MEMORY* memory;
        
 public:
        // ----------------------------------------
@@ -200,9 +198,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 be6761c..1754e8c 100644 (file)
@@ -26,7 +26,7 @@
        } \
 }
 
-void MEMORY::initialize()
+void JR100_MEMORY::initialize()
 {
        // initialize memory
        memset(ram, 0, sizeof(ram));
@@ -64,7 +64,7 @@ void MEMORY::initialize()
        register_frame_event(this);
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void JR100_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        if((addr & 0xf000) == 0xc000) {
                switch(addr & 0xfc00) {
@@ -80,7 +80,7 @@ void MEMORY::write_data8(uint32_t addr, uint32_t data)
        wbank[(addr >> 13) & 7][addr & 0x1fff] = data;
 }
 
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t JR100_MEMORY::read_data8(uint32_t addr)
 {
        if((addr & 0xf000) == 0xc000) {
                switch(addr & 0xfc00) {
@@ -104,7 +104,7 @@ uint32_t MEMORY::read_data8(uint32_t addr)
        return rbank[(addr >> 13) & 7][addr & 0x1fff];
 }
 
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void JR100_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(id == SIG_MEMORY_VIA_PORT_A) {
                key_column = data & 0x0f;
@@ -126,7 +126,7 @@ static const int key_table[9][5] = {
        {0xbe, 0x20, 0xba, 0x0d, 0xbd}, //      .       SPACE   :       RET     -
 };
 
-void MEMORY::event_frame()
+void JR100_MEMORY::event_frame()
 {
        uint32_t data = 0;
        if(key_column < 9) {
@@ -139,7 +139,7 @@ void MEMORY::event_frame()
        d_via->write_signal(SIG_SY6522_PORT_B, ~data, 0x1f);
 }
 
-void MEMORY::draw_screen()
+void JR100_MEMORY::draw_screen()
 {
        int src = 0x100;
        for(int y = 0, yy = 0; y < 24; y++, yy += 8) {
@@ -166,57 +166,7 @@ void MEMORY::draw_screen()
 
 #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_INT32(key_column);
-       DECL_STATE_ENTRY_BOOL(cmode);
-       
-       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->FputInt32(key_column);
-//     state_fio->FputBool(cmode);
-}
-
-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);
-//     key_column = state_fio->FgetInt32();
-//     cmode = state_fio->FgetBool();
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool JR100_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 452eeb9..3e3056d 100644 (file)
@@ -7,8 +7,8 @@
        [ memory bus ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _JR100_MEMORY_H_
+#define _JR100_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -17,7 +17,7 @@
 #define SIG_MEMORY_VIA_PORT_A  0
 #define SIG_MEMORY_VIA_PORT_B  1
 
-class MEMORY : public DEVICE
+class JR100_MEMORY : public DEVICE
 {
 private:
        // contexts
@@ -40,11 +40,11 @@ private:
        scrntype_t palette_pc[2];
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       JR100_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~JR100_MEMORY() {}
        
        // common functions
        void initialize();
@@ -52,9 +52,7 @@ public:
        uint32_t read_data8(uint32_t addr);
        void write_signal(int id, uint32_t data, uint32_t mask);
        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);
        
        // unique functions
        void set_context_via(DEVICE* device)
index 1751d86..00b4e5b 100644 (file)
@@ -8,10 +8,10 @@
        [ memory mapped i/o ]
 */
 
-#include "io.h"
+#include "./io.h"
 #include "../hd44102.h"
 
-void IO::write_memory_mapped_io8(uint32_t addr, uint32_t data)
+void JR800_IO::write_memory_mapped_io8(uint32_t addr, uint32_t data)
 {
        int chip = 0;
        
@@ -33,7 +33,7 @@ void IO::write_memory_mapped_io8(uint32_t addr, uint32_t data)
        }
 }
 
-uint32_t IO::read_memory_mapped_io8(uint32_t addr)
+uint32_t JR800_IO::read_memory_mapped_io8(uint32_t addr)
 {
        const uint8_t* key_stat = emu->get_key_buffer();
        uint8_t data = 0;
@@ -164,43 +164,7 @@ uint32_t IO::read_memory_mapped_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void IO::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       leave_decl_state();
-}
-
-void IO::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);
-}
-
-bool IO::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;
-//     }
-       return true;
-}
-
-bool IO::process_state(FILEIO* state_fio, bool loading)
+bool JR800_IO::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 33097c9..7611852 100644 (file)
@@ -8,8 +8,8 @@
        [ memory mapped i/o ]
 */
 
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _JR800_IO_H_
+#define _JR800_IO_H_
 
 #include "../vm.h"
 #include "../../emu.h"
 
 class HD44102;
 
-class IO : public DEVICE
+class JR800_IO : public DEVICE
 {
 private:
        HD44102 *d_lcd[8];
        
 public:
-       IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       JR800_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Mapped I/O"));
        }
-       ~IO() {}
+       ~JR800_IO() {}
        
        // common functions
        void write_memory_mapped_io8(uint32_t addr, uint32_t data);
        uint32_t read_memory_mapped_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 function
        void set_context_lcd(int i, HD44102 *device)
index fcc6b1d..4599548 100644 (file)
@@ -24,7 +24,7 @@
 #include "../debugger.h"
 #endif
 
-#include "io.h"
+#include "./io.h"
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -49,7 +49,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        memory = new MEMORY(this, emu);
        pcm = new PCM1BIT(this, emu);
        
-       io = new IO(this, emu);
+       io = new JR800_IO(this, emu);
        
        // set contexts
        event->set_context_cpu(cpu);
@@ -91,7 +91,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()
@@ -287,73 +286,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::JR_800_HEAD")), csp_logger);
-       DECL_STATE_ENTRY_MULTI(void, 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);
-       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);
-}
-
-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);
-       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;
+               }
+       }
        state_fio->StateBuffer(ram, sizeof(ram), 1);
        return true;
 }
index 8354170..aad9867 100644 (file)
@@ -57,7 +57,7 @@ class HD6301;
 class MEMORY;
 class PCM1BIT;
 
-class IO;
+class JR800_IO;
 
 class VM : public VM_TEMPLATE
 {
@@ -75,7 +75,7 @@ protected:
        MEMORY* memory;
        PCM1BIT* pcm;
        
-       IO* io;
+       JR800_IO* io;
        
        uint8_t ram[0x6000];
        uint8_t rom[0x8000];
@@ -130,9 +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);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // ----------------------------------------
        // for each device
index 720086d..c384ad9 100644 (file)
@@ -548,25 +548,3 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateInt32(cblink);
        return true;
 }
-
-bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
-{
-       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
-               return false;
-       }
-       if(!state_fio->StateCheckInt32(this_device_id)) {
-               return false;
-       }
-       state_fio->StateBuffer(vram, sizeof(vram), 1);
-       state_fio->StateBuffer(extvram, sizeof(extvram), 1);
-       state_fio->StateBuffer(vgarray, sizeof(vgarray), 1);
-       state_fio->StateBuffer(palette, sizeof(palette), 1);
-       state_fio->StateInt32(vgarray_num);
-       state_fio->StateBuffer(bankreg, sizeof(bankreg), 1);
-       state_fio->StateInt32(bankreg_num);
-       state_fio->StateUint8(hires_mode);
-       state_fio->StateUint8(page);
-       state_fio->StateUint8(status);
-       state_fio->StateInt32(cblink);
-       return true;
-}
index 5a87bb6..63f6796 100644 (file)
@@ -67,15 +67,3 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
        return true;
 }
 
-bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
-{
-       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
-               return false;
-       }
-       if(!state_fio->StateCheckInt32(this_device_id)) {
-               return false;
-       }
-       state_fio->StateUint8(prev);
-       state_fio->StateInt32(register_id);
-       return true;
-}
index d668eb5..d85b5a7 100644 (file)
@@ -415,39 +415,131 @@ int I286::get_shutdown_flag()
 }
 #endif
 
-#define STATE_VERSION  4
+#define STATE_VERSION  5
 
-bool I286::process_state(FILEIO* state_fio, bool loading)
+void I286::process_state_cpustate(FILEIO* state_fio, bool loading)
 {
-       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
-               return false;
+#if defined(HAS_I86) || defined(HAS_I88) || defined(HAS_I186) || defined(HAS_V30)
+       struct i8086_state *cpustate = (struct i8086_state *)opaque;
+
+       state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+       state_fio->StateUint32(cpustate->pc);
+       state_fio->StateUint32(cpustate->prevpc);
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint32(cpustate->base[i]);
        }
-       if(!state_fio->StateCheckInt32(this_device_id)) {
-               return false;
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint16(cpustate->sregs[i]);
        }
-       state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+       state_fio->StateUint16(cpustate->flags);
+       state_fio->StateInt32(cpustate->AuxVal);
+       state_fio->StateInt32(cpustate->OverVal);
+       state_fio->StateInt32(cpustate->SignVal);
+       state_fio->StateInt32(cpustate->ZeroVal);
+       state_fio->StateInt32(cpustate->CarryVal);
+       state_fio->StateInt32(cpustate->DirVal);
+       state_fio->StateUint8(cpustate->ParityVal);
+       state_fio->StateUint8(cpustate->TF);
+       state_fio->StateUint8(cpustate->IF);
+       state_fio->StateUint8(cpustate->MF);
        
-       // post process
-       if(loading) {
-               cpu_state *cpustate = (cpu_state *)opaque;
-               cpustate->pic = d_pic;
-               cpustate->program = d_mem;
-               cpustate->io = d_io;
-#ifdef I86_PSEUDO_BIOS
-               cpustate->bios = d_bios;
-#endif
-#ifdef SINGLE_MODE_DMA
-               cpustate->dma = d_dma;
-#endif
-#ifdef USE_DEBUGGER
-               cpustate->emu = emu;
-               cpustate->debugger = d_debugger;
-               cpustate->program_stored = d_mem;
-               cpustate->io_stored = d_io;
-               cpustate->prev_total_icount = cpustate->total_icount;
-#endif
+       state_fio->StateUint8(cpustate->int_vector);
+       state_fio->StateInt8(cpustate->nmi_state);
+       state_fio->StateInt8(cpustate->irq_state);
+       state_fio->StateInt8(cpustate->test_state);
+       state_fio->StateUint8(cpustate->rep_in_progress);
+       state_fio->StateInt32(cpustate->extra_cycles);
+
+       state_fio->StateInt32(cpustate->halted);
+       state_fio->StateInt32(cpustate->busreq);
+
+       state_fio->StateUint16(cpustate->ip);
+       state_fio->StateUint32(cpustate->sp);
+
+  #ifdef USE_DEBUGGER
+       state_fio->StateUint64(cpustate->total_icount);
+  #endif
+       state_fio->StateInt32(cpustate->icount);
+
+       state_fio->StateUint8(cpustate->seg_prefix);
+       state_fio->StateUint8(cpustate->prefix_seg);
+       state_fio->StateUint32(cpustate->ea);
+       state_fio->StateUint16(cpustate->eo);
+       state_fio->StateUint8(cpustate->ea_seg);
+
+#elif defined(HAS_I286)
+
+       struct i80286_state *cpustate = (struct i80286_state *)opaque;
+
+       state_fio->StateBuffer(&(cpustate->regs.b[0]), 16, 1);
+       state_fio->StateUint32(cpustate->amask);
+       state_fio->StateUint32(cpustate->pc);
+       state_fio->StateUint32(cpustate->prevpc);
+       state_fio->StateUint16(cpustate->flags);
+       state_fio->StateUint16(cpustate->msw);
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint32(cpustate->base[i]);
        }
-       return true;
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint16(cpustate->sregs[i]);
+       }
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateUint16(cpustate->limit[i]);
+       }
+       state_fio->StateBuffer(cpustate->rights, 4, 1);
+       for(int i = 0; i < 4; i++) {
+               state_fio->StateBool(cpustate->valid[i]);
+       }
+       state_fio->StateUint32(cpustate->gdtr.base);
+       state_fio->StateUint16(cpustate->gdtr.limit);
+
+       state_fio->StateUint32(cpustate->idtr.base);
+       state_fio->StateUint16(cpustate->idtr.limit);
+
+       state_fio->StateUint16(cpustate->ldtr.sel);
+       state_fio->StateUint32(cpustate->ldtr.base);
+       state_fio->StateUint16(cpustate->ldtr.limit);
+       state_fio->StateUint8(cpustate->ldtr.rights);
+       
+       state_fio->StateUint16(cpustate->tr.sel);
+       state_fio->StateUint32(cpustate->tr.base);
+       state_fio->StateUint16(cpustate->tr.limit);
+       state_fio->StateUint8(cpustate->tr.rights);
+
+       
+       state_fio->StateInt32(cpustate->AuxVal);
+       state_fio->StateInt32(cpustate->OverVal);
+       state_fio->StateInt32(cpustate->SignVal);
+       state_fio->StateInt32(cpustate->ZeroVal);
+       state_fio->StateInt32(cpustate->CarryVal);
+       state_fio->StateInt32(cpustate->DirVal);
+       state_fio->StateUint8(cpustate->ParityVal);
+       state_fio->StateUint8(cpustate->TF);
+       state_fio->StateUint8(cpustate->IF);
+       state_fio->StateUint8(cpustate->MF);
+       
+       state_fio->StateInt8(cpustate->nmi_state);
+       state_fio->StateInt8(cpustate->irq_state);
+       state_fio->StateInt8(cpustate->test_state);
+       state_fio->StateUint8(cpustate->rep_in_progress);
+       state_fio->StateInt32(cpustate->extra_cycles);
+
+       state_fio->StateInt32(cpustate->halted);
+       state_fio->StateInt32(cpustate->busreq);
+       state_fio->StateInt32(cpustate->trap_level);
+       state_fio->StateInt32(cpustate->shutdown);
+
+  #ifdef USE_DEBUGGER
+       state_fio->StateUint64(cpustate->total_icount);
+  #endif
+       state_fio->StateInt32(cpustate->icount);
+
+       state_fio->StateUint8(cpustate->seg_prefix);
+       state_fio->StateUint8(cpustate->prefix_seg);
+       state_fio->StateUint32(cpustate->ea);
+       state_fio->StateUint16(cpustate->eo);
+       state_fio->StateUint8(cpustate->ea_seg);
+#endif
 }
 
 bool I286::process_state(FILEIO* state_fio, bool loading)
@@ -458,7 +550,8 @@ bool I286::process_state(FILEIO* state_fio, bool loading)
        if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+       //state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
+       process_state_cpustate(state_fio, loading);
        
        // post process
        if(loading) {
@@ -482,3 +575,4 @@ bool I286::process_state(FILEIO* state_fio, bool loading)
        }
        return true;
 }
+
index 28dca4e..c7233c3 100644 (file)
@@ -103,6 +103,7 @@ public:
        void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
        int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
 #endif
+       void process_state_cpustate(FILEIO* state_fio, bool loading);
        bool process_state(FILEIO* state_fio, bool loading);
        
        // unique function
index 9667c4e..ba80f9e 100644 (file)
@@ -355,43 +355,33 @@ 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;
+               }
+       }
        state_fio->StateBuffer(ram, sizeof(ram), 1);
        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 "
-               int len = strlen(name);
-               
-               if(!state_fio->StateCheckInt32(len)) {
-                       return false;
-               }
-               if(!state_fio->StateCheckBuffer(name, len, 1)) {
-                       return false;
-               }
-               if(!device->process_state(state_fio, loading)) {
-                       return false;
-               }
-       }
-       state_fio->StateBuffer(ram, sizeof(ram), 1);
-       return true;
-}
index 2d18c40..e964040 100644 (file)
@@ -43,6 +43,7 @@
 #define USE_SCANLINE
 #define USE_SOUND_VOLUME       2
 #define USE_DEBUGGER
+#define USE_STATE
 #define USE_CPU_I286
 
 #define KEYBOARD_HACK
index 8c325d1..b7df5c7 100644 (file)
@@ -214,22 +214,3 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
        return true;
 }
 
-bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
-{
-       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
-               return false;
-       }
-       if(!state_fio->StateCheckInt32(this_device_id)) {
-               return false;
-       }
-       if(!key_buf->process_state(state_fio, loading)) {
-               return false;
-       }
-#ifndef KEYBOARD_HACK
-       state_fio->StateUint64(send_data);
-       state_fio->StateInt32(send_count);
-#endif
-       state_fio->StateBool(key_latched);
-       state_fio->StateUint8(nmi_reg);
-       return true;
-}
index 5e8839a..d5a5753 100644 (file)
@@ -70,65 +70,6 @@ void CMT::write_signal(int id, uint32_t data, uint32_t mask)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void CMT::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_BOOL(in);
-       DECL_STATE_ENTRY_BOOL(out);
-       DECL_STATE_ENTRY_BOOL(remote);
-       DECL_STATE_ENTRY_BOOL(eot);
-       DECL_STATE_ENTRY_UINT8(pout);
-       DECL_STATE_ENTRY_BOOL(strobe);
-       DECL_STATE_ENTRY_BOOL(busy);
-       
-       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->FputBool(in);
-//     state_fio->FputBool(out);
-//     state_fio->FputBool(remote);
-//     state_fio->FputBool(eot);
-//     state_fio->FputUint8(pout);
-//     state_fio->FputBool(strobe);
-//     state_fio->FputBool(busy);
-}
-
-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;
-//     }
-//     in = state_fio->FgetBool();
-//     out = state_fio->FgetBool();
-//     remote = state_fio->FgetBool();
-//     eot = state_fio->FgetBool();
-//     pout = state_fio->FgetUint8();
-//     strobe = state_fio->FgetBool();
-//     busy = state_fio->FgetBool();
-       return true;
-}
-
 bool CMT::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index dbfc9ef..97a7dfa 100644 (file)
@@ -45,9 +45,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 function
        void set_context_drec(DEVICE* device)
index 37bfc6d..48fc4fe 100644 (file)
@@ -111,7 +111,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;
 }
 
@@ -329,80 +328,38 @@ 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::M5_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 60c8926..c96d31c 100644 (file)
@@ -147,9 +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);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // ----------------------------------------
        // for each device
index 2bb4c7f..ffcec50 100644 (file)
@@ -394,7 +394,7 @@ public:
        {
                ssl[0] = ssl[1] = ssl[2] = ssl[3] = 0;
                expanded[0] = expanded[1] = expanded[2] = expanded[3] = false;
-               set_device_name(_T("Memory Bus"));
+               set_device_name(_T("Memory Bus (ex)"));
        }
        ~MEMORY_EX() {}
        
index f988c88..2d26262 100644 (file)
@@ -99,92 +99,6 @@ void CMT::release_tape()
 
 #define STATE_VERSION  2
 
-#include "../../statesub.h"
-
-void CMT::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_BOOL(play);
-       DECL_STATE_ENTRY_BOOL(rec);
-       DECL_STATE_ENTRY_BOOL(remote);
-       DECL_STATE_ENTRY_STRING(rec_file_path, sizeof(rec_file_path));  
-       DECL_STATE_ENTRY_CMT_RECORDING(fio, rec, rec_file_path);
-       
-       DECL_STATE_ENTRY_INT32(bufcnt);
-       DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
-
-       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->FputBool(play);
-//     state_fio->FputBool(rec);
-//     state_fio->FputBool(remote);
-//     state_fio->Fwrite(rec_file_path, sizeof(rec_file_path), 1);
-//     if(rec && fio->IsOpened()) {
-//             int length_tmp = (int)fio->Ftell();
-//             fio->Fseek(0, FILEIO_SEEK_SET);
-//             state_fio->FputInt32(length_tmp);
-//             while(length_tmp != 0) {
-//                     uint8_t buffer_tmp[1024];
-//                     int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-//                     fio->Fread(buffer_tmp, length_rw, 1);
-//                     state_fio->Fwrite(buffer_tmp, length_rw, 1);
-//                     length_tmp -= length_rw;
-//             }
-//     } else {
-//             state_fio->FputInt32(0);
-//     }
-//     state_fio->FputInt32(bufcnt);
-//     state_fio->Fwrite(buffer, sizeof(buffer), 1);
-}
-
-bool CMT::load_state(FILEIO* state_fio)
-{
-       release_tape();
-       
-       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;
-//     }
-//     play = state_fio->FgetBool();
-//     rec = state_fio->FgetBool();
-//     remote = state_fio->FgetBool();
-//     state_fio->Fread(rec_file_path, sizeof(rec_file_path), 1);
-//     int length_tmp = state_fio->FgetInt32();
-//     if(rec) {
-//             fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
-//             while(length_tmp != 0) {
-//                     uint8_t buffer_tmp[1024];
-//                     int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
-//                     state_fio->Fread(buffer_tmp, length_rw, 1);
-//                     if(fio->IsOpened()) {
-//                             fio->Fwrite(buffer_tmp, length_rw, 1);
-//                     }
-//                     length_tmp -= length_rw;
-//             }
-//     }
-//     bufcnt = state_fio->FgetInt32();
-//     state_fio->Fread(buffer, sizeof(buffer), 1);
-       return true;
-}
-
 bool CMT::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 97c6633..c9b4d8b 100644 (file)
@@ -45,9 +45,7 @@ public:
        void release();
        void reset();
        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 play_tape(const _TCHAR* file_path);
index 12402a5..08db54c 100644 (file)
@@ -311,77 +311,6 @@ void DISPLAY::draw_text_normal()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void DISPLAY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(pal, sizeof(pal));
-       DECL_STATE_ENTRY_BOOL(text_wide);
-       DECL_STATE_ENTRY_BOOL(text_color);
-       DECL_STATE_ENTRY_UINT8(graph_color);
-       DECL_STATE_ENTRY_UINT8(graph_page);
-       DECL_STATE_ENTRY_UINT16(cursor);
-       DECL_STATE_ENTRY_UINT16(cblink);
-       DECL_STATE_ENTRY_BOOL(hsync);
-       DECL_STATE_ENTRY_BOOL(vsync);
-       DECL_STATE_ENTRY_BOOL(display);
-       DECL_STATE_ENTRY_BOOL(blink);
-
-       leave_decl_state();
-}
-
-void DISPLAY::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(pal, sizeof(pal), 1);
-//     state_fio->FputBool(text_wide);
-//     state_fio->FputBool(text_color);
-//     state_fio->FputUint8(graph_color);
-//     state_fio->FputUint8(graph_page);
-//     state_fio->FputUint16(cursor);
-//     state_fio->FputUint16(cblink);
-//     state_fio->FputBool(hsync);
-//     state_fio->FputBool(vsync);
-//     state_fio->FputBool(display);
-//     state_fio->FputBool(blink);
-}
-
-bool DISPLAY::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(pal, sizeof(pal), 1);
-//     text_wide = state_fio->FgetBool();
-//     text_color = state_fio->FgetBool();
-//     graph_color = state_fio->FgetUint8();
-//     graph_page = state_fio->FgetUint8();
-//     cursor = state_fio->FgetUint16();
-//     cblink = state_fio->FgetUint16();
-//     hsync = state_fio->FgetBool();
-//     vsync = state_fio->FgetBool();
-//     display = state_fio->FgetBool();
-//     blink = state_fio->FgetBool();
-       return true;
-}
-
 bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 05495c3..58b1fb5 100644 (file)
@@ -53,9 +53,7 @@ public:
        uint32_t read_io8(uint32_t addr);
        void write_signal(int id, uint32_t data, uint32_t mask);
        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);
        
        // unique functions
        void set_vram_ptr(uint8_t* ptr)
index c68c898..0783357 100644 (file)
@@ -47,46 +47,6 @@ void FLOPPY::write_signal(int id, uint32_t data, uint32_t mask)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void FLOPPY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_BOOL(drq);
-       
-       leave_decl_state();
-}
-void FLOPPY::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->FputBool(drq);
-}
-
-bool FLOPPY::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;
-//     }
-//     drq = state_fio->FgetBool();
-       return true;
-}
-
 bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index fae509e..5e34bad 100644 (file)
@@ -33,9 +33,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 function
        void set_context_fdc(DEVICE* device)
index 329dc55..617f4e8 100644 (file)
@@ -57,43 +57,6 @@ uint32_t KANJI::read_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void KANJI::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_UINT32(ptr);
-
-       leave_decl_state();
-}
-
-void KANJI::save_state(FILEIO* state_fio)
-{
-       if(state_entry != NULL) {
-               state_entry->save_state(state_fio);
-       }
-//     state_fio->FputUint32(STATE_VERSION);
-       
-//     state_fio->FputUint32(ptr);
-}
-
-bool KANJI::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;
-//     }
-//     ptr = state_fio->FgetUint32();
-       return true;
-}
-
 bool KANJI::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 758a114..3148695 100644 (file)
@@ -34,9 +34,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 function
        void set_context_pio(DEVICE* device)
index 9f800eb..ce77cbb 100644 (file)
@@ -244,74 +244,6 @@ void KEYBOARD::event_frame()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_INT32(init);
-       DECL_STATE_ENTRY_UINT8(code);
-       DECL_STATE_ENTRY_UINT8(code_prev);
-       DECL_STATE_ENTRY_UINT8(stat);
-       DECL_STATE_ENTRY_BOOL(caps);
-       DECL_STATE_ENTRY_BOOL(caps_prev);
-       DECL_STATE_ENTRY_BOOL(graph);
-       DECL_STATE_ENTRY_BOOL(graph_prev);
-       DECL_STATE_ENTRY_BOOL(kana);
-       DECL_STATE_ENTRY_BOOL(kana_prev);
-       
-       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);
-       
-//     state_fio->FputInt32(init);
-//     state_fio->FputUint8(code);
-//     state_fio->FputUint8(code_prev);
-//     state_fio->FputUint8(stat);
-//     state_fio->FputBool(caps);
-//     state_fio->FputBool(caps_prev);
-//     state_fio->FputBool(graph);
-//     state_fio->FputBool(graph_prev);
-//     state_fio->FputBool(kana);
-//     state_fio->FputBool(kana_prev);
-}
-
-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;
-//     }
-//     init = state_fio->FgetInt32();
-//     code = state_fio->FgetUint8();
-//     code_prev = state_fio->FgetUint8();
-//     stat = state_fio->FgetUint8();
-//     caps = state_fio->FgetBool();
-//     caps_prev = state_fio->FgetBool();
-//     graph = state_fio->FgetBool();
-//     graph_prev = state_fio->FgetBool();
-//     kana = state_fio->FgetBool();
-//     kana_prev = state_fio->FgetBool();
-       return true;
-}
-
 bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 7fdc117..48f687f 100644 (file)
@@ -37,9 +37,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);
        
        // unique functions
        bool get_caps_locked()
index 9771724..8125091 100644 (file)
@@ -26,7 +26,7 @@
        } \
 }
 
-void MEMORY::initialize()
+void MULTI8_MEMORY::initialize()
 {
        // init memory
        memset(rom, 0xff, sizeof(rom));
@@ -55,14 +55,14 @@ void MEMORY::initialize()
        delete fio;
 }
 
-void MEMORY::reset()
+void MULTI8_MEMORY::reset()
 {
        map1 = 0xf;
        map2 = 0;
        update_map();
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void MULTI8_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
        if((addr & 0xc000) == 0x8000 && (map1 & 0x10)) {
@@ -85,7 +85,7 @@ void MEMORY::write_data8(uint32_t addr, uint32_t data)
        wbank[addr >> 12][addr & 0xfff] = data;
 }
 
-uint32_t MEMORY::read_data8(uint32_t addr)
+uint32_t MULTI8_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
        if((addr & 0xc000) == 0x8000 && (map1 & 0x10)) {
@@ -109,13 +109,13 @@ uint32_t MEMORY::read_data8(uint32_t addr)
        return rbank[addr >> 12][addr & 0xfff];
 }
 
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void MULTI8_MEMORY::write_io8(uint32_t addr, uint32_t data)
 {
        map2 = data;
        update_map();
 }
 
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void MULTI8_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(id == SIG_MEMORY_I8255_C) {
                map1 = data & mask;
@@ -123,7 +123,7 @@ void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
        }
 }
 
-void MEMORY::update_map()
+void MULTI8_MEMORY::update_map()
 {
        if(map1 & 0x20) {
                SET_BANK(0x0000, 0x7fff, ram0, ram0);
@@ -139,63 +139,7 @@ void MEMORY::update_map()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(ram0, sizeof(ram0));
-       DECL_STATE_ENTRY_1D_ARRAY(ram1, sizeof(ram1));
-       DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
-       DECL_STATE_ENTRY_UINT8(map1);
-       DECL_STATE_ENTRY_UINT8(map2);
-       
-       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(ram0, sizeof(ram0), 1);
-//     state_fio->Fwrite(ram1, sizeof(ram1), 1);
-//     state_fio->Fwrite(vram, sizeof(vram), 1);
-//     state_fio->FputUint8(map1);
-//     state_fio->FputUint8(map2);
-}
-
-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(ram0, sizeof(ram0), 1);
-//     state_fio->Fread(ram1, sizeof(ram1), 1);
-//     state_fio->Fread(vram, sizeof(vram), 1);
-//     map1 = state_fio->FgetUint8();
-//     map2 = state_fio->FgetUint8();
-       
-       // post process
-       update_map();
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool MULTI8_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 426463c..b750110 100644 (file)
@@ -16,7 +16,7 @@
 
 #define SIG_MEMORY_I8255_C     0
 
-class MEMORY : public DEVICE
+class MULTI8_MEMORY : public DEVICE
 {
 private:
        DEVICE* d_pio;
@@ -36,11 +36,11 @@ private:
        uint8_t map1, map2;
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       MULTI8_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~MULTI8_MEMORY() {}
        
        // common functions
        void initialize();
@@ -49,9 +49,7 @@ public:
        uint32_t read_data8(uint32_t addr);
        void write_io8(uint32_t addr, uint32_t data);
        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_pio(DEVICE* device)
index 1dc54ec..68da418 100644 (file)
@@ -35,7 +35,7 @@
 #include "floppy.h"
 #include "kanji.h"
 #include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
 
 // ----------------------------------------------------------------------------
 // initialize
@@ -69,7 +69,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        floppy = new FLOPPY(this, emu);
        kanji = new KANJI(this, emu);
        key = new KEYBOARD(this, emu);
-       memory = new MEMORY(this, emu);
+       memory = new MULTI8_MEMORY(this, emu);
        
        // set contexts
        event->set_context_cpu(cpu);
@@ -132,7 +132,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        for(DEVICE* device = first_device; device; device = device->next_device) {
                device->initialize();
        }
-       decl_state();
        
        for(int i = 0; i < 4; i++) {
                fdc->set_drive_type(i, DRIVE_TYPE_2D);
@@ -326,69 +325,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)
-{
-       state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::MULTI8_HEAD")), csp_logger);
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               device->decl_state();
-       }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
-       //state_fio->FputUint32(STATE_VERSION);
-       
-       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 7c6f323..e8c2988 100644 (file)
@@ -80,7 +80,7 @@ class DISPLAY;
 class FLOPPY;
 class KANJI;
 class KEYBOARD;
-class MEMORY;
+class MULTI8_MEMORY;
 
 class VM : public VM_TEMPLATE
 {
@@ -108,7 +108,7 @@ protected:
        FLOPPY* floppy;
        KANJI* kanji;
        KEYBOARD* key;
-       MEMORY* memory;
+       MULTI8_MEMORY* memory;
        
 public:
        // ----------------------------------------
@@ -161,9 +161,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 441dc88..d7c4be6 100644 (file)
@@ -84,53 +84,6 @@ uint32_t CMOS::read_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void CMOS::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_1D_ARRAY(data_buffer, DATA_SIZE);
-       DECL_STATE_ENTRY_UINT32(data_addr);
-       DECL_STATE_ENTRY_BOOL(modified);
-       
-       leave_decl_state();
-}
-
-void CMOS::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(data_buffer, DATA_SIZE, 1);
-//     state_fio->FputUint32(data_addr);
-//     state_fio->FputBool(modified);
-}
-
-bool CMOS::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(data_buffer, DATA_SIZE, 1);
-//     data_addr = state_fio->FgetUint32();
-//     modified = state_fio->FgetBool();
-       return true;
-}
-
 bool CMOS::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index c2d6097..3e0ac3e 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);
 };
 
 #endif
index 7906e8a..9151bef 100644 (file)
@@ -75,50 +75,6 @@ uint32_t EMM::read_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void EMM::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_1D_ARRAY(data_buffer, DATA_SIZE);
-       DECL_STATE_ENTRY_UINT32(data_addr);
-       
-       leave_decl_state();
-}
-
-void EMM::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(data_buffer, DATA_SIZE, 1);
-//     state_fio->FputUint32(data_addr);
-}
-
-bool EMM::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(data_buffer, DATA_SIZE, 1);
-//     data_addr = state_fio->FgetUint32();
-       return true;
-}
-
 bool EMM::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 5d427d7..ee9a802 100644 (file)
@@ -35,9 +35,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);
 };
 
 #endif
index 93069ca..14ec994 100644 (file)
@@ -96,56 +96,6 @@ void FLOPPY::write_signal(int id, uint32_t data, uint32_t mask)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void FLOPPY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_UINT32(prev_dc);
-       DECL_STATE_ENTRY_INT32(register_id);
-       DECL_STATE_ENTRY_BOOL(motor_on);
-       DECL_STATE_ENTRY_BOOL(irq_enabled);
-
-       leave_decl_state();
-}
-
-void FLOPPY::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->FputUint32(prev_dc);
-//     state_fio->FputInt32(register_id);
-//     state_fio->FputBool(motor_on);
-//     state_fio->FputBool(irq_enabled);
-}
-
-bool FLOPPY::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;
-//     }
-//     prev_dc = state_fio->FgetUint32();
-//     register_id = state_fio->FgetInt32();
-//     motor_on = state_fio->FgetBool();
-//     irq_enabled = state_fio->FgetBool();
-       return true;
-}
-
 bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index ef2a57d..084a2f0 100644 (file)
@@ -41,9 +41,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        void event_callback(int event_id, int err);
        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_cpu(DEVICE* device)
index dea0a9a..06a6423 100644 (file)
@@ -74,53 +74,6 @@ uint32_t KANJI::read_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void KANJI::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_UINT32(control_reg);
-       DECL_STATE_ENTRY_UINT32(kanji_addr);
-       DECL_STATE_ENTRY_UINT32(dic_addr);
-       
-       leave_decl_state();
-}
-
-void KANJI::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->FputUint32(control_reg);
-//     state_fio->FputUint32(kanji_addr);
-//     state_fio->FputUint32(dic_addr);
-}
-
-bool KANJI::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;
-//     }
-//     control_reg = state_fio->FgetUint32();
-//     kanji_addr = state_fio->FgetUint32();
-//     dic_addr = state_fio->FgetUint32();
-       return true;
-}
-
 bool KANJI::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index f7b45d1..d85ff7f 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);
 };
 
 #endif
index 6a1dc2c..8e64133 100644 (file)
@@ -65,47 +65,6 @@ void KEYBOARD::update_key()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_UINT8(column);
-
-       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);
-       
-//     state_fio->FputUint8(column);
-}
-
-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;
-//     }
-//     column = state_fio->FgetUint8();
-       return true;
-}
-
 bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 7bf1b47..add99ac 100644 (file)
@@ -38,9 +38,7 @@ public:
        void initialize();
        void write_signal(int id, uint32_t data, uint32_t mask);
        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);
        
        // unique function
        void set_context_pio(DEVICE* device)
index 65b5031..fe3a9c3 100644 (file)
@@ -9,7 +9,7 @@
        [ memory ]
 */
 
-#include "memory.h"
+#include "./memory.h"
 #include "../i8253.h"
 #include "../i8255.h"
 #if defined(_MZ800)
@@ -65,7 +65,7 @@
 #define EXT_FILE_NAME  "EXT.ROM"
 #endif
 
-void MEMORY::initialize()
+void MZ700_MEMORY::initialize()
 {
        // init memory
        memset(ipl, 0xff, sizeof(ipl));
@@ -127,7 +127,7 @@ void MEMORY::initialize()
 }
 
 
-void MEMORY::reset()
+void MZ700_MEMORY::reset()
 {
 #if defined(_MZ800)
        // check dip-switch
@@ -191,7 +191,7 @@ void MEMORY::reset()
 }
 
 #if defined(_MZ800)
-void MEMORY::update_config()
+void MZ700_MEMORY::update_config()
 {
        if(config.monitor_type == 0) {
                // color
@@ -215,7 +215,7 @@ void MEMORY::update_config()
 }
 #endif
 
-void MEMORY::event_vline(int v, int clock)
+void MZ700_MEMORY::event_vline(int v, int clock)
 {
        // vblank / vsync
        set_vblank(v >= 200);
@@ -275,7 +275,7 @@ void MEMORY::event_vline(int v, int clock)
        }
 }
 
-void MEMORY::event_callback(int event_id, int err)
+void MZ700_MEMORY::event_callback(int event_id, int err)
 {
        if(event_id == EVENT_TEMPO) {
                // 32KHz
@@ -307,7 +307,7 @@ void MEMORY::event_callback(int event_id, int err)
        }
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void MZ700_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
 #if defined(_MZ800)
@@ -456,7 +456,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 MZ700_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
 #if defined(_MZ800)
@@ -541,19 +541,19 @@ uint32_t MEMORY::read_data8(uint32_t addr)
        return rbank[addr >> 11][addr & 0x7ff];
 }
 
-void MEMORY::write_data8w(uint32_t addr, uint32_t data, int* wait)
+void MZ700_MEMORY::write_data8w(uint32_t addr, uint32_t data, int* wait)
 {
        *wait = ((mem_bank & MEM_BANK_MON_L) && addr < 0x1000) ? 1 : 0;
        write_data8(addr, data);
 }
 
-uint32_t MEMORY::read_data8w(uint32_t addr, int* wait)
+uint32_t MZ700_MEMORY::read_data8w(uint32_t addr, int* wait)
 {
        *wait = ((mem_bank & MEM_BANK_MON_L) && addr < 0x1000) ? 1 : 0;
        return read_data8(addr);
 }
 
-void MEMORY::write_io8(uint32_t addr, uint32_t data)
+void MZ700_MEMORY::write_io8(uint32_t addr, uint32_t data)
 {
        switch(addr & 0xff) {
 #if defined(_MZ800)
@@ -656,7 +656,7 @@ void MEMORY::write_io8(uint32_t addr, uint32_t data)
 }
 
 #if defined(_MZ800)
-uint32_t MEMORY::read_io8(uint32_t addr)
+uint32_t MZ700_MEMORY::read_io8(uint32_t addr)
 {
        switch(addr & 0xff) {
        case 0xce:
@@ -675,7 +675,7 @@ uint32_t MEMORY::read_io8(uint32_t addr)
 }
 #endif
 
-void MEMORY::set_vblank(bool val)
+void MZ700_MEMORY::set_vblank(bool val)
 {
        if(vblank != val) {
                // VBLANK -> 8255:PC7
@@ -688,14 +688,14 @@ void MEMORY::set_vblank(bool val)
        }
 }
 
-void MEMORY::set_hblank(bool val)
+void MZ700_MEMORY::set_hblank(bool val)
 {
        if(hblank != val) {
                hblank = val;
        }
 }
 
-void MEMORY::update_map_low()
+void MZ700_MEMORY::update_map_low()
 {
        if(mem_bank & MEM_BANK_MON_L) {
                SET_BANK(0x0000, 0x0fff, wdmy, ipl);
@@ -704,7 +704,7 @@ void MEMORY::update_map_low()
        }
 }
 
-void MEMORY::update_map_middle()
+void MZ700_MEMORY::update_map_middle()
 {
 #if defined(_MZ800)
        if(MZ700_MODE) {
@@ -726,7 +726,7 @@ void MEMORY::update_map_middle()
 #endif
 }
 
-void MEMORY::update_map_high()
+void MZ700_MEMORY::update_map_high()
 {
 #if defined(_MZ800)
        // MZ-800
@@ -781,7 +781,7 @@ void MEMORY::update_map_high()
 }
 
 #if defined(_MZ800)
-int MEMORY::vram_page_mask(uint8_t f)
+int MZ700_MEMORY::vram_page_mask(uint8_t f)
 {
        switch(dmd & 7) {
        case 0: // 320x200,4col
@@ -798,7 +798,7 @@ int MEMORY::vram_page_mask(uint8_t f)
        return 0;
 }
 
-int MEMORY::vram_addr(int addr)
+int MZ700_MEMORY::vram_addr(int addr)
 {
        if(dmd & 4) {
                // 640x200
@@ -822,7 +822,7 @@ int MEMORY::vram_addr(int addr)
 #endif
 
 #if defined(_MZ700) || defined(_MZ1500)
-void MEMORY::draw_line(int v)
+void MZ700_MEMORY::draw_line(int v)
 {
        int ptr = 40 * (v >> 3);
 #if defined(_MZ700)
@@ -899,7 +899,7 @@ void MEMORY::draw_line(int v)
        }
 }
 
-void MEMORY::draw_screen()
+void MZ700_MEMORY::draw_screen()
 {
        // copy to real screen
        emu->set_vm_screen_lines(200);
@@ -924,7 +924,7 @@ void MEMORY::draw_screen()
        emu->screen_skip_line(true);
 }
 #else
-void MEMORY::draw_line_320x200_2bpp(int v)
+void MZ700_MEMORY::draw_line_320x200_2bpp(int v)
 {
        int ofs1 = (dmd & 1) ? 0x4000 : 0;
        int ofs2 = ofs1 | 0x2000;
@@ -947,7 +947,7 @@ void MEMORY::draw_line_320x200_2bpp(int v)
        }
 }
 
-void MEMORY::draw_line_320x200_4bpp(int v)
+void MZ700_MEMORY::draw_line_320x200_4bpp(int v)
 {
        int ptr = 40 * v;
        
@@ -970,7 +970,7 @@ void MEMORY::draw_line_320x200_4bpp(int v)
        }
 }
 
-void MEMORY::draw_line_640x200_1bpp(int v)
+void MZ700_MEMORY::draw_line_640x200_1bpp(int v)
 {
        int ofs = (dmd & 1) ? 0x4000 : 0;
        int ptr = 80 * v;
@@ -991,7 +991,7 @@ void MEMORY::draw_line_640x200_1bpp(int v)
        }
 }
 
-void MEMORY::draw_line_640x200_2bpp(int v)
+void MZ700_MEMORY::draw_line_640x200_2bpp(int v)
 {
        int ptr = 80 * v;
        
@@ -1012,7 +1012,7 @@ void MEMORY::draw_line_640x200_2bpp(int v)
        }
 }
 
-void MEMORY::draw_line_mz700(int v)
+void MZ700_MEMORY::draw_line_mz700(int v)
 {
        int ptr = (40 * (v >> 3)) | 0x3000;
        
@@ -1037,7 +1037,7 @@ void MEMORY::draw_line_mz700(int v)
        }
 }
 
-void MEMORY::draw_screen()
+void MZ700_MEMORY::draw_screen()
 {
        // copy to real screen
        emu->set_vm_screen_lines(200);
@@ -1074,200 +1074,7 @@ void MEMORY::draw_screen()
 
 #define STATE_VERSION  2
 
-#include "../../statesub.h"
-
-void MEMORY::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-#if defined(_MZ700)
-       DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0x400]), 0x400);
-       DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0xc00]), 0x400);
-#elif defined(_MZ1500)
-       DECL_STATE_ENTRY_1D_ARRAY(pcg, sizeof(pcg));
-#endif
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
-       DECL_STATE_ENTRY_UINT8(mem_bank);
-#if defined(_MZ700)
-       DECL_STATE_ENTRY_UINT8(pcg_data);
-       DECL_STATE_ENTRY_UINT8(pcg_addr);
-       DECL_STATE_ENTRY_UINT8(pcg_ctrl);
-#elif defined(_MZ800)
-       DECL_STATE_ENTRY_UINT8(wf);
-       DECL_STATE_ENTRY_UINT8(rf);
-       DECL_STATE_ENTRY_UINT8(dmd);
-       DECL_STATE_ENTRY_UINT32(vram_addr_top);
-       DECL_STATE_ENTRY_BOOL(is_mz800);
-#elif defined(_MZ1500)
-       DECL_STATE_ENTRY_UINT8(pcg_bank);
-#endif
-#if defined(_MZ800)
-       DECL_STATE_ENTRY_UINT16(sof);
-       DECL_STATE_ENTRY_UINT8(sw);
-       DECL_STATE_ENTRY_UINT8(ssa);
-       DECL_STATE_ENTRY_UINT8(sea);
-       DECL_STATE_ENTRY_UINT8(palette_sw);
-       DECL_STATE_ENTRY_1D_ARRAY(palette, sizeof(palette));
-       DECL_STATE_ENTRY_1D_ARRAY(palette16, sizeof(palette16));
-#elif defined(_MZ1500)
-       DECL_STATE_ENTRY_UINT8(priority);
-       DECL_STATE_ENTRY_1D_ARRAY(palette, sizeof(palette));
-#endif
-       DECL_STATE_ENTRY_BOOL(blink);
-       DECL_STATE_ENTRY_BOOL(tempo);
-       DECL_STATE_ENTRY_BOOL(hblank);
-       DECL_STATE_ENTRY_BOOL(hsync);
-       DECL_STATE_ENTRY_BOOL(vblank);
-       DECL_STATE_ENTRY_BOOL(vsync);
-#if defined(_MZ700) || defined(_MZ1500)
-       DECL_STATE_ENTRY_BOOL(hblank_vram);
-#endif
-#if defined(_MZ1500)
-       DECL_STATE_ENTRY_BOOL(hblank_pcg);
-#endif
-#if defined(_MZ800)
-       DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_mz800_pc, sizeof(palette_mz800_pc) / sizeof(scrntype_t));
-#endif
-       DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_pc, sizeof(palette_pc) / sizeof(scrntype_t));
-
-       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);
-       
-//#if defined(_MZ700)
-//     state_fio->Fwrite(pcg + 0x400, 0x400, 1);
-//     state_fio->Fwrite(pcg + 0xc00, 0x400, 1);
-//#elif defined(_MZ1500)
-//     state_fio->Fwrite(pcg, sizeof(pcg), 1);
-//#endif
-//     state_fio->Fwrite(ram, sizeof(ram), 1);
-//     state_fio->Fwrite(vram, sizeof(vram), 1);
-//     state_fio->FputUint8(mem_bank);
-//#if defined(_MZ700)
-//     state_fio->FputUint8(pcg_data);
-//     state_fio->FputUint8(pcg_addr);
-//     state_fio->FputUint8(pcg_ctrl);
-//#elif defined(_MZ800)
-//     state_fio->FputUint8(wf);
-//     state_fio->FputUint8(rf);
-//     state_fio->FputUint8(dmd);
-//     state_fio->FputUint32(vram_addr_top);
-//     state_fio->FputBool(is_mz800);
-//#elif defined(_MZ1500)
-//     state_fio->FputUint8(pcg_bank);
-//#endif
-//#if defined(_MZ800)
-//     state_fio->FputUint16(sof);
-//     state_fio->FputUint8(sw);
-//     state_fio->FputUint8(ssa);
-//     state_fio->FputUint8(sea);
-//     state_fio->FputUint8(palette_sw);
-//     state_fio->Fwrite(palette, sizeof(palette), 1);
-//     state_fio->Fwrite(palette16, sizeof(palette16), 1);
-//#elif defined(_MZ1500)
-//     state_fio->FputUint8(priority);
-//     state_fio->Fwrite(palette, sizeof(palette), 1);
-//#endif
-//     state_fio->FputBool(blink);
-//     state_fio->FputBool(tempo);
-//     state_fio->FputBool(hblank);
-//     state_fio->FputBool(hsync);
-//     state_fio->FputBool(vblank);
-//     state_fio->FputBool(vsync);
-//#if defined(_MZ700) || defined(_MZ1500)
-//     state_fio->FputBool(hblank_vram);
-//#endif
-//#if defined(_MZ1500)
-//     state_fio->FputBool(hblank_pcg);
-//#endif
-//#if defined(_MZ800)
-//     state_fio->Fwrite(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
-//#endif
-//     state_fio->Fwrite(palette_pc, sizeof(palette_pc), 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;
-//     }
-//#if defined(_MZ700)
-//     state_fio->Fread(pcg + 0x400, 0x400, 1);
-//     state_fio->Fread(pcg + 0xc00, 0x400, 1);
-//#elif defined(_MZ1500)
-//     state_fio->Fread(pcg, sizeof(pcg), 1);
-//#endif
-//     state_fio->Fread(ram, sizeof(ram), 1);
-//     state_fio->Fread(vram, sizeof(vram), 1);
-//     mem_bank = state_fio->FgetUint8();
-//#if defined(_MZ700)
-//     pcg_data = state_fio->FgetUint8();
-//     pcg_addr = state_fio->FgetUint8();
-//     pcg_ctrl = state_fio->FgetUint8();
-//#elif defined(_MZ800)
-//     wf = state_fio->FgetUint8();
-//     rf = state_fio->FgetUint8();
-//     dmd = state_fio->FgetUint8();
-//     vram_addr_top = state_fio->FgetUint32();
-//     is_mz800 = state_fio->FgetBool();
-//#elif defined(_MZ1500)
-//     pcg_bank = state_fio->FgetUint8();
-//#endif
-//#if defined(_MZ800)
-//     sof = state_fio->FgetUint16();
-//     sw = state_fio->FgetUint8();
-//     ssa = state_fio->FgetUint8();
-//     sea = state_fio->FgetUint8();
-//     palette_sw = state_fio->FgetUint8();
-//     state_fio->Fread(palette, sizeof(palette), 1);
-//     state_fio->Fread(palette16, sizeof(palette16), 1);
-//#elif defined(_MZ1500)
-//     priority = state_fio->FgetUint8();
-//     state_fio->Fread(palette, sizeof(palette), 1);
-//#endif
-//     blink = state_fio->FgetBool();
-//     tempo = state_fio->FgetBool();
-//     hblank = state_fio->FgetBool();
-//     hsync = state_fio->FgetBool();
-//     vblank = state_fio->FgetBool();
-//     vsync = state_fio->FgetBool();
-//#if defined(_MZ700) || defined(_MZ1500)
-//     hblank_vram = state_fio->FgetBool();
-//#endif
-//#if defined(_MZ1500)
-//     hblank_pcg = state_fio->FgetBool();
-//#endif
-//#if defined(_MZ800)
-//     state_fio->Fread(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
-//#endif
-//     state_fio->Fread(palette_pc, sizeof(palette_pc), 1);
-       
-       // post process
-       update_map_low();
-       update_map_middle();
-       update_map_high();
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool MZ700_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
@@ -1322,9 +1129,47 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateBool(hblank_pcg);
 #endif
 #if defined(_MZ800)
-       state_fio->StateBuffer(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
+       //state_fio->StateBuffer(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
+       if(loading) {
+               for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
+                       uint8_t r, g, b;
+                       r = state_fio->FgetUint8();
+                       g = state_fio->FgetUint8();
+                       b = state_fio->FgetUint8();
+                       palette_mz800_pc[i] = RGB_COLOR(r, g, b);
+               }
+       } else {
+               for(int i = 0; i < (sizeof(palette_mz800_pc) / sizeof(scrntype_t)); i++) {
+                       uint8_t r, g, b;
+                       r = R_OF_COLOR(palette_mz800_pc[i]);
+                       g = G_OF_COLOR(palette_mz800_pc[i]);
+                       b = B_OF_COLOR(palette_mz800_pc[i]);
+                       state_fio->FputUint8(r);
+                       state_fio->FputUint8(g);
+                       state_fio->FputUint8(b);
+               }
+       }
 #endif
-       state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+       //state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+       if(loading) {
+               for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
+                       uint8_t r, g, b;
+                       r = state_fio->FgetUint8();
+                       g = state_fio->FgetUint8();
+                       b = state_fio->FgetUint8();
+                       palette_pc[i] = RGB_COLOR(r, g, b);
+               }
+       } else {
+               for(int i = 0; i < (sizeof(palette_pc) / sizeof(scrntype_t)); i++) {
+                       uint8_t r, g, b;
+                       r = R_OF_COLOR(palette_pc[i]);
+                       g = G_OF_COLOR(palette_pc[i]);
+                       b = B_OF_COLOR(palette_pc[i]);
+                       state_fio->FputUint8(r);
+                       state_fio->FputUint8(g);
+                       state_fio->FputUint8(b);
+               }
+       }
        
        // post process
        if(loading) {
index c4a708d..e3d3177 100644 (file)
@@ -9,8 +9,8 @@
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _MZ700_MEMORY_H_
+#define _MZ700_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -20,7 +20,7 @@
 class DISPLAY;
 #endif
 
-class MEMORY : public DEVICE
+class MZ700_MEMORY : public DEVICE
 {
 private:
        DEVICE *d_cpu, *d_pit, *d_pio;
@@ -114,11 +114,11 @@ private:
 #endif
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       MZ700_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~MZ700_MEMORY() {}
        
        // common functions
        void initialize();
@@ -136,9 +136,7 @@ public:
 #if defined(_MZ800)
        uint32_t read_io8(uint32_t addr);
 #endif
-       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 7282f95..b4b6d3a 100644 (file)
@@ -31,7 +31,7 @@
 #include "emm.h"
 #include "kanji.h"
 #include "keyboard.h"
-#include "memory.h"
+#include "./memory.h"
 #include "ramfile.h"
 
 #if defined(_MZ800) || defined(_MZ1500)
@@ -84,7 +84,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        emm = new EMM(this, emu);
        kanji = new KANJI(this, emu);
        keyboard = new KEYBOARD(this, emu);
-       memory = new MEMORY(this, emu);
+       memory = new MZ700_MEMORY(this, emu);
        ramfile = new RAMFILE(this, emu);
 
 #if defined(_MZ800) || defined(_MZ1500)
@@ -399,7 +399,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
 //             }
        }
 #endif
-       decl_state();
 }
 
 VM::~VM()
@@ -699,69 +698,38 @@ 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::MZ700_SERIES_HEAD")), csp_logger);
-#if defined(_MZ800)
-       DECL_STATE_ENTRY_INT32(boot_mode);
-#endif
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               device->decl_state();
-       }
-}
-
-void VM::save_state(FILEIO* state_fio)
-{
-       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)
-{
-       bool mb = false;
-       if(state_entry != NULL) {
-               mb = state_entry->load_state(state_fio);
-       }
-       if(!mb) {
-               printf("INFO: HEADER DATA ERROR\n");
-               return false;
-       }
-       for(DEVICE* device = first_device; device; device = device->next_device) {
-               if(!device->load_state(state_fio)) {
-                       printf("INFO: DATA ERROR at DEVID=%d\n", device->this_device_id);
-                       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;
+               }
+       }
 #if defined(_MZ800)
        state_fio->StateInt32(boot_mode);
 #endif
index c57bb86..be79f90 100644 (file)
@@ -195,7 +195,7 @@ class Z80;
 class EMM;
 class KANJI;
 class KEYBOARD;
-class MEMORY;
+class MZ700_MEMORY;
 class RAMFILE;
 
 #if defined(_MZ800) || defined(_MZ1500)
@@ -232,7 +232,7 @@ protected:
        EMM* emm;
        KANJI* kanji;
        KEYBOARD* keyboard;
-       MEMORY* memory;
+       MZ700_MEMORY* memory;
        RAMFILE* ramfile;
        
 #if defined(_MZ800) || defined(_MZ1500)
@@ -325,9 +325,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 282290d..d4d6419 100644 (file)
@@ -560,95 +560,6 @@ void QUICKDISK::release_disk()
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void QUICKDISK::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_STRING(file_path, sizeof(file_path) / sizeof(_TCHAR));
-       DECL_STATE_ENTRY_BOOL(insert);
-       DECL_STATE_ENTRY_BOOL(protect);
-       DECL_STATE_ENTRY_BOOL(home);
-       DECL_STATE_ENTRY_BOOL(modified);
-       DECL_STATE_ENTRY_BOOL(accessed);
-       DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer) / sizeof(uint16_t));
-       DECL_STATE_ENTRY_INT32(buffer_ptr);
-       DECL_STATE_ENTRY_INT32(write_ptr);
-       DECL_STATE_ENTRY_BOOL(first_data);
-       DECL_STATE_ENTRY_BOOL(send_break);
-       DECL_STATE_ENTRY_BOOL(wrga);
-       DECL_STATE_ENTRY_BOOL(mton);
-       DECL_STATE_ENTRY_BOOL(sync);
-       DECL_STATE_ENTRY_BOOL(motor_on);
-       DECL_STATE_ENTRY_INT32(restore_id);
-       DECL_STATE_ENTRY_INT32(end_id);
-       
-       leave_decl_state();
-}
-
-void QUICKDISK::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(file_path, sizeof(file_path), 1);
-//     state_fio->FputBool(insert);
-//     state_fio->FputBool(protect);
-//     state_fio->FputBool(home);
-//     state_fio->FputBool(modified);
-//     state_fio->FputBool(accessed);
-//     state_fio->Fwrite(buffer, sizeof(buffer), 1);
-//     state_fio->FputInt32(buffer_ptr);
-//     state_fio->FputInt32(write_ptr);
-//     state_fio->FputBool(first_data);
-//     state_fio->FputBool(send_break);
-//     state_fio->FputBool(wrga);
-//     state_fio->FputBool(mton);
-//     state_fio->FputBool(sync);
-//     state_fio->FputBool(motor_on);
-//     state_fio->FputInt32(restore_id);
-//     state_fio->FputInt32(end_id);
-}
-
-bool QUICKDISK::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(file_path, sizeof(file_path), 1);
-//     insert = state_fio->FgetBool();
-//     protect = state_fio->FgetBool();
-//     home = state_fio->FgetBool();
-//     modified = state_fio->FgetBool();
-//     accessed = state_fio->FgetBool();
-//     state_fio->Fread(buffer, sizeof(buffer), 1);
-//     buffer_ptr = state_fio->FgetInt32();
-//     write_ptr = state_fio->FgetInt32();
-//     first_data = state_fio->FgetBool();
-//     send_break = state_fio->FgetBool();
-//     wrga = state_fio->FgetBool();
-//     mton = state_fio->FgetBool();
-//     sync = state_fio->FgetBool();
-//     motor_on = state_fio->FgetBool();
-//     restore_id = state_fio->FgetInt32();
-//     end_id = state_fio->FgetInt32();
-       return true;
-}
-
 bool QUICKDISK::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
@@ -663,7 +574,10 @@ bool QUICKDISK::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateBool(home);
        state_fio->StateBool(modified);
        state_fio->StateBool(accessed);
-       state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+       //state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+       for(int i = 0; i < QUICKDISK_BUFFER_SIZE; i++) {
+               state_fio->StateUint16(buffer[i]);
+       }
        state_fio->StateInt32(buffer_ptr);
        state_fio->StateInt32(write_ptr);
        state_fio->StateBool(first_data);
index 58d1b02..96fc245 100644 (file)
@@ -67,9 +67,7 @@ public:
        void write_signal(int id, uint32_t data, uint32_t mask);
        uint32_t read_signal(int ch);
        void event_callback(int event_id, int err);
-       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_sio(DEVICE* device)
index ee3f5d7..185120a 100644 (file)
@@ -55,50 +55,6 @@ uint32_t RAMFILE::read_io8(uint32_t addr)
 
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void RAMFILE::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(data_buffer, DATA_SIZE);
-       DECL_STATE_ENTRY_UINT32(data_addr);
-       
-       leave_decl_state();
-}
-
-void RAMFILE::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(data_buffer, DATA_SIZE, 1);
-//     state_fio->FputUint32(data_addr);
-}
-
-bool RAMFILE::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(data_buffer, DATA_SIZE, 1);
-//     data_addr = state_fio->FgetUint32();
-       return true;
-}
-
 bool RAMFILE::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index e4f1a52..ea4ee03 100644 (file)
@@ -35,9 +35,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);
 };
 
 #endif
index 4f10cf3..c0b1f86 100644 (file)
@@ -122,50 +122,6 @@ void KEYBOARD::key_down(int code)
 
 #define STATE_VERSION  2
 
-#include "../../statesub.h"
-
-void KEYBOARD::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-       
-       DECL_STATE_ENTRY_UINT8(column);
-       DECL_STATE_ENTRY_BOOL(kana);
-       
-       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);
-       
-//     state_fio->FputUint8(column);
-//     state_fio->FputBool(kana);
-}
-
-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;
-//     }
-//     column = state_fio->FgetUint8();
-//     kana = state_fio->FgetBool();
-       return true;
-}
-
 bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
index 92ba4e7..b803e53 100644 (file)
@@ -41,9 +41,7 @@ public:
        void initialize();
        void write_signal(int id, uint32_t data, uint32_t mask);
        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);
        
        // unique functions
        void set_context_pio(DEVICE* device)
index 2e2f3e9..d7a0ebb 100644 (file)
@@ -12,7 +12,7 @@
        [ memory ]
 */
 
-#include "memory.h"
+#include "./memory.h"
 #include "../i8253.h"
 #include "../i8255.h"
 
@@ -36,7 +36,7 @@
        } \
 }
 
-void MEMORY::initialize()
+void MZ80A_MEMORY::initialize()
 {
        // init memory
        memset(ram, 0, sizeof(ram));
@@ -131,7 +131,7 @@ void MEMORY::initialize()
        register_event_by_clock(this, EVENT_BLINK, CPU_CLOCKS / 3, true, NULL);         // 1.5hz * 2
 }
 
-void MEMORY::reset()
+void MZ80A_MEMORY::reset()
 {
 #if defined(_MZ1200) || defined(_MZ80A)
        // reset memory swap
@@ -156,7 +156,7 @@ void MEMORY::reset()
        d_pio->write_signal(SIG_I8255_PORT_C, 0xff, 0x10);
 }
 
-void MEMORY::event_vline(int v, int clock)
+void MZ80A_MEMORY::event_vline(int v, int clock)
 {
        // draw one line
        if(0 <= v && v < 200) {
@@ -212,7 +212,7 @@ void MEMORY::event_vline(int v, int clock)
 #endif
 }
 
-void MEMORY::event_callback(int event_id, int err)
+void MZ80A_MEMORY::event_callback(int event_id, int err)
 {
        if(event_id == EVENT_TEMPO) {
                // 32khz
@@ -227,7 +227,7 @@ void MEMORY::event_callback(int event_id, int err)
        }
 }
 
-void MEMORY::write_data8(uint32_t addr, uint32_t data)
+void MZ80A_MEMORY::write_data8(uint32_t addr, uint32_t data)
 {
        addr &= 0xffff;
        if(0xe000 <= addr && addr <= 0xe7ff) {
@@ -266,7 +266,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 MZ80A_MEMORY::read_data8(uint32_t addr)
 {
        addr &= 0xffff;
        if(0xe000 <= addr && addr <= 0xe7ff) {
@@ -320,7 +320,7 @@ uint32_t MEMORY::read_data8(uint32_t addr)
 }
 
 #if defined(_MZ1200) || defined(_MZ80A)
-void MEMORY::update_memory_swap()
+void MZ80A_MEMORY::update_memory_swap()
 {
        if(memory_swap) {
                SET_BANK(0x0000, 0x0fff, ram + 0xc000, ram + 0xc000);
@@ -333,7 +333,7 @@ void MEMORY::update_memory_swap()
 #endif
 
 #if defined(SUPPORT_MZ80AIF)
-void MEMORY::update_fdif_rom_bank()
+void MZ80A_MEMORY::update_fdif_rom_bank()
 {
        // FD IF ROM BANK switching
        if(fdc_drq) {
@@ -348,7 +348,7 @@ void MEMORY::update_fdif_rom_bank()
 }
 #endif
 
-void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
+void MZ80A_MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        bool signal = ((data & mask) != 0);
        
@@ -376,7 +376,7 @@ void MEMORY::write_signal(int id, uint32_t data, uint32_t mask)
 }
 
 #if defined(_MZ80K)
-void MEMORY::update_config()
+void MZ80A_MEMORY::update_config()
 {
        if(config.monitor_type) {
                palette_pc[1] = RGB_COLOR(0, 255, 0);
@@ -386,7 +386,7 @@ void MEMORY::update_config()
 }
 #endif
 
-void MEMORY::draw_screen()
+void MZ80A_MEMORY::draw_screen()
 {
        // copy to real screen
        emu->set_vm_screen_lines(200);
@@ -410,132 +410,7 @@ void MEMORY::draw_screen()
 
 #define STATE_VERSION  3
 
-#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_BOOL(tempo);
-       DECL_STATE_ENTRY_BOOL(blink);
-#if defined(_MZ1200) || defined(_MZ80A)
-       DECL_STATE_ENTRY_BOOL(hblank);
-       DECL_STATE_ENTRY_BOOL(memory_swap);
-#endif
-#if defined(SUPPORT_MZ80AIF)
-       DECL_STATE_ENTRY_BOOL(fdc_irq);
-       DECL_STATE_ENTRY_BOOL(fdc_drq);
-#endif
-       DECL_STATE_ENTRY_BOOL(vgate);
-#if defined(_MZ1200) || defined(_MZ80A)
-       DECL_STATE_ENTRY_BOOL(reverse);
-#endif
-#if defined(_MZ80A)
-       DECL_STATE_ENTRY_UINT32(e200);
-#endif
-       DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0x400]), 0x400);
-#if defined(_MZ1200)
-       DECL_STATE_ENTRY_1D_ARRAY(&(pcg[0xc00]), 0x400);
-#endif
-       DECL_STATE_ENTRY_UINT8(pcg_data);
-       DECL_STATE_ENTRY_UINT8(pcg_addr);
-       DECL_STATE_ENTRY_UINT8(pcg_ctrl);
-       
-       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->FputBool(tempo);
-//     state_fio->FputBool(blink);
-//#if defined(_MZ1200) || defined(_MZ80A)
-//     state_fio->FputBool(hblank);
-//     state_fio->FputBool(memory_swap);
-//#endif
-//#if defined(SUPPORT_MZ80AIF)
-//     state_fio->FputBool(fdc_irq);
-//     state_fio->FputBool(fdc_drq);
-//#endif
-//     vgate = state_fio->FgetBool();
-//#if defined(_MZ1200) || defined(_MZ80A)
-//     reverse = state_fio->FgetBool();
-//#endif
-//#if defined(_MZ80A)
-//     state_fio->FputUint32(e200);
-//#endif
-//     state_fio->Fwrite(pcg + 0x400, 0x400, 1);
-//#if defined(_MZ1200)
-//     state_fio->Fwrite(pcg + 0xc00, 0x400, 1);
-//#endif
-//     state_fio->FputUint8(pcg_data);
-//     state_fio->FputUint8(pcg_addr);
-//     state_fio->FputUint8(pcg_ctrl);
-}
-
-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);
-//     tempo = state_fio->FgetBool();
-//     blink = state_fio->FgetBool();
-//#if defined(_MZ1200) || defined(_MZ80A)
-//     hblank = state_fio->FgetBool();
-//     memory_swap = state_fio->FgetBool();
-//#endif
-//#if defined(SUPPORT_MZ80AIF)
-//     fdc_irq = state_fio->FgetBool();
-//     fdc_drq = state_fio->FgetBool();
-//#endif
-//     state_fio->FputBool(vgate);
-//#if defined(_MZ1200) || defined(_MZ80A)
-//     state_fio->FputBool(reverse);
-//#endif
-//#if defined(_MZ80A)
-//     e200 = state_fio->FgetUint32();
-//#endif
-//     state_fio->Fread(pcg + 0x400, 0x400, 1);
-//#if defined(_MZ1200)
-//     state_fio->Fread(pcg + 0xc00, 0x400, 1);
-//#endif
-//     pcg_data = state_fio->FgetUint8();
-//     pcg_addr = state_fio->FgetUint8();
-//     pcg_ctrl = state_fio->FgetUint8();
-       
-       // post process
-#if defined(_MZ1200) || defined(_MZ80A)
-       update_memory_swap();
-#endif
-#if defined(SUPPORT_MZ80AIF)
-       update_fdif_rom_bank();
-#endif
-       return true;
-}
-
-bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+bool MZ80A_MEMORY::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
index 1ff5a81..c2821bc 100644 (file)
@@ -12,8 +12,8 @@
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _MZ80A_MEMORY_H_
+#define _MZ80A_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
@@ -25,7 +25,7 @@
 #define SIG_MEMORY_FDC_DRQ     2
 #endif
 
-class MEMORY : public DEVICE
+class MZ80A_MEMORY : public DEVICE
 {
 private:
        DEVICE *d_ctc, *d_pio;
@@ -81,11 +81,11 @@ private:
        uint8_t pcg_ctrl;
        
 public:
-       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       MZ80A_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
                set_device_name(_T("Memory Bus"));
        }
-       ~MEMORY() {}
+       ~MZ80A_MEMORY() {}
        
        // common functions
        void initialize();
@@ -98,9 +98,7 @@ public:
 #if defined(_MZ80K)
        void update_config();
 #endif
-       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_ctc(DEVICE* device)
index 5a95c4e..1ccc980 100644 (file)
@@ -78,7 +78,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        counter->set_device_name(_T("74LS393 Counter (CTC/Sound)"));
        
        keyboard = new KEYBOARD(this, emu);
-       memory = new MEMORY(this, emu);
+       memory = new MZ80A_MEMORY(this, emu);
        printer = new PRINTER(this, emu);
 #if defined(SUPPORT_MZ80AIF)
        io = new IO(this, emu);
@@ -185,7 +185,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()
@@ -468,66 +467,36 @@ void VM::update_config()
 
 #define STATE_VERSION  7
 
-#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::MZ80_SERIES_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)
-{
-       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;
-       //}
-       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;
+               }
+       }
        return true;
 }
index 69fa6c7..62e3124 100644 (file)
@@ -109,7 +109,7 @@ class PCM1BIT;
 class Z80;
 
 class KEYBOARD;
-class MEMORY;
+class MZ80A_MEMORY;
 class PRINTER;
 
 #if defined(SUPPORT_MZ80AIF)
@@ -142,7 +142,7 @@ protected:
        Z80* cpu;
        
        KEYBOARD* keyboard;
-       MEMORY* memory;
+       MZ80A_MEMORY* memory;
        PRINTER* printer;
        
 #if defined(SUPPORT_MZ80AIF)
@@ -219,9 +219,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 2346ef4..90b2ff4 100644 (file)
@@ -44,48 +44,6 @@ uint32_t PRINTER::read_io8(uint32_t addr)
 #if defined(_MZ1200) || defined(_MZ80K)
 #define STATE_VERSION  1
 
-#include "../../statesub.h"
-
-void PRINTER::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_UINT8(out_ch);
-       
-       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_ch);
-}
-
-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_ch = state_fio->FgetUint8();
-       return true;
-}
-#endif
-
 bool PRINTER::process_state(FILEIO* state_fio, bool loading)
 {
        if(!state_fio->StateCheckUint32(STATE_VERSION)) {
@@ -97,3 +55,4 @@ bool PRINTER::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateUint8(out_ch);
        return true;
 }
+#endif
index dbfc726..70f8235 100644 (file)
@@ -35,9 +35,7 @@ public:
        void write_io8(uint32_t addr, uint32_t data);
        uint32_t read_io8(uint32_t addr);
 #if defined(_MZ1200) || defined(_MZ80K)
-       void decl_state();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
 #endif
        
        // unique function