OSDN Git Service

[VM][STATE][HC20][HC40][HC80][M5][MSX] Apply new state framerork to some VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / hc80 / memory.cpp
index 1a63fd5..00d6b5a 100644 (file)
@@ -91,25 +91,47 @@ 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)
 {
-       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->Fwrite(ram, sizeof(ram), 1);
-       state_fio->FputUint8(bank);
+//     state_fio->Fwrite(ram, sizeof(ram), 1);
+//     state_fio->FputUint8(bank);
 }
 
 bool MEMORY::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) {
+       if(!mb) {
                return false;
        }
-       state_fio->Fread(ram, sizeof(ram), 1);
-       bank = state_fio->FgetUint8();
+//     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);