OSDN Git Service

[General][Qt] Merge upstream, datarecorder with sound.
[csp-qt/common_source_project-fm7.git] / source / src / vm / hc40 / memory.cpp
index 54fe8e4..076643b 100644 (file)
@@ -126,5 +126,33 @@ void MEMORY::set_bank(uint32 val)
                SET_BANK(0x8000, 0xdfff, wdmy, util);
                break;
        }
+       bank = val;
+}
+
+#define STATE_VERSION  1
+
+void MEMORY::save_state(FILEIO* 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)
+{
+       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;
 }