OSDN Git Service

[VM][STATE] Apply new state framework to some devices a lot (excepts some devices...
[csp-qt/common_source_project-fm7.git] / source / src / vm / nor.cpp
index c3e3ffe..0dfe88e 100644 (file)
@@ -26,27 +26,50 @@ void NOR::write_signal(int id, uint32_t data, uint32_t mask)
 
 #define STATE_VERSION  1
 
+#include "../statesub.h"
+
+void NOR::decl_state()
+{
+       enter_decl_state(STATE_VERSION);
+
+       DECL_STATE_ENTRY_UINT32(bits_in);
+       DECL_STATE_ENTRY_BOOL(prev);
+       DECL_STATE_ENTRY_BOOL(first);
+
+       leave_decl_state();
+}
+
 void NOR::save_state(FILEIO* state_fio)
 {
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
+       if(state_entry != NULL) {
+               state_entry->save_state(state_fio);
+       }
+       
+//     state_fio->FputUint32(STATE_VERSION);
+//     state_fio->FputInt32(this_device_id);
        
-       state_fio->FputUint32(bits_in);
-       state_fio->FputBool(prev);
-       state_fio->FputBool(first);
+//     state_fio->FputUint32(bits_in);
+//     state_fio->FputBool(prev);
+//     state_fio->FputBool(first);
 }
 
 bool NOR::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(state_fio->FgetInt32() != this_device_id) {
-               return false;
-       }
-       bits_in = state_fio->FgetUint32();
-       prev = state_fio->FgetBool();
-       first = state_fio->FgetBool();
+       if(!mb) return false;
+       
+//     if(state_fio->FgetUint32() != STATE_VERSION) {
+//             return false;
+//     }
+//     if(state_fio->FgetInt32() != this_device_id) {
+//             return false;
+//     }
+//     bits_in = state_fio->FgetUint32();
+//     prev = state_fio->FgetBool();
+//     first = state_fio->FgetBool();
        return true;
 }