OSDN Git Service

[VM][WIP] Pre-process to apply new state framework.Still not buildable.
[csp-qt/common_source_project-fm7.git] / source / src / vm / tk80bs / membus.cpp
index a1df97e..3aecc1b 100644 (file)
@@ -51,29 +51,58 @@ void MEMBUS::write_signal(int id, uint32_t data, uint32_t mask)
 
 #define STATE_VERSION  1
 
-void MEMBUS::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void MEMBUS::decl_state()
 {
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
-       
+       enter_decl_state(STATE_VERSION);
+
 #if defined(_TK85)
-       state_fio->FputUint32(pc7);
-       state_fio->FputUint32(count);
+       DECL_STATE_ENTRY_UINT32(pc7);
+       DECL_STATE_ENTRY_UINT32(count);
 #endif
+       MEMORY::decl_state();
+       
+       leave_decl_state();
+}
+
+void MEMBUS::save_state(FILEIO* state_fio)
+{
+//     state_fio->FputUint32(STATE_VERSION);
+//     state_fio->FputInt32(this_device_id);
+       
+//#if defined(_TK85)
+//     state_fio->FputUint32(pc7);
+//     state_fio->FputUint32(count);
+//#endif
        MEMORY::save_state(state_fio);
 }
 
 bool MEMBUS::load_state(FILEIO* state_fio)
 {
-       if(state_fio->FgetUint32() != STATE_VERSION) {
+//     if(state_fio->FgetUint32() != STATE_VERSION) {
+//             return false;
+//     }
+//     if(state_fio->FgetInt32() != this_device_id) {
+//             return false;
+//     }
+//#if defined(_TK85)
+//     pc7 = state_fio->FgetUint32();
+//     count = state_fio->FgetUint32();
+//#endif
+       return MEMORY::load_state(state_fio);
+}
+bool MEMBUS::process_state(FILEIO* state_fio, bool loading)
+{
+       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       if(state_fio->FgetInt32() != this_device_id) {
+       if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
 #if defined(_TK85)
-       pc7 = state_fio->FgetUint32();
-       count = state_fio->FgetUint32();
+       state_fio->StateUint32(pc7);
+       state_fio->StateUint32(count);
 #endif
-       return MEMORY::load_state(state_fio);
+       return MEMORY::process_state(state_fio, loading);
 }