OSDN Git Service

[VM][WIP] Apply some devices merging upstream 2018-10-05.This still not build.WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / tf20.cpp
index 33268c2..6c56a92 100644 (file)
@@ -143,53 +143,24 @@ uint32_t TF20::get_intr_ack()
 
 #define STATE_VERSION  1
 
-#include "../statesub.h"
-
-void TF20::decl_state()
-{
-       enter_decl_state(STATE_VERSION);
-
-       DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
-       DECL_STATE_ENTRY_BOOL(rom_selected);
-
-       leave_decl_state();
-}
-void TF20::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(rom_selected);
-}
-
-bool TF20::load_state(FILEIO* state_fio)
+bool TF20::process_state(FILEIO* state_fio, bool loading)
 {
-       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);
-//     rom_selected = state_fio->FgetBool();
-       
-       // post process
-       if(rom_selected) {
-               SET_BANK(0x0000, 0x07ff, ram, rom);
-       } else {
-               SET_BANK(0x0000, 0x07ff, ram, ram);
-       }
-       return true;
+       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+               return false;
+       }
+       if(!state_fio->StateCheckInt32(this_device_id)) {
+               return false;
+       }
+       state_fio->StateBuffer(ram, sizeof(ram), 1);
+       state_fio->StateBool(rom_selected);
+       
+       // post process
+       if(loading) {
+               if(rom_selected) {
+                       SET_BANK(0x0000, 0x07ff, ram, rom);
+               } else {
+                       SET_BANK(0x0000, 0x07ff, ram, ram);
+               }
+       }
+       return true;
 }
-