OSDN Git Service

[General] Merge from upstream version, 2015-01-28.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz5500 / keyboard.cpp
index ae1167f..b721882 100644 (file)
@@ -11,6 +11,7 @@
 #include "../i8255.h"
 #include "../i8259.h"
 #include "../../fifo.h"
+#include "../../fileio.h"
 
 #define BIT_DK 8
 #define BIT_SRK        0x10
@@ -464,3 +465,53 @@ void KEYBOARD::process(int cmd)
        }
 }
 
+#define STATE_VERSION  1
+
+void KEYBOARD::save_state(FILEIO* state_fio)
+{
+       state_fio->FputUint32(STATE_VERSION);
+       state_fio->FputInt32(this_device_id);
+       
+       key_buf->save_state((void *)state_fio);
+       rsp_buf->save_state((void *)state_fio);
+       state_fio->FputBool(caps);
+       state_fio->FputBool(kana);
+       state_fio->FputBool(graph);
+       state_fio->FputInt32(dk);
+       state_fio->FputInt32(srk);
+       state_fio->FputInt32(dc);
+       state_fio->FputInt32(stc);
+       state_fio->FputInt32(send);
+       state_fio->FputInt32(recv);
+       state_fio->FputInt32(phase);
+       state_fio->FputInt32(timeout);
+}
+
+bool KEYBOARD::load_state(FILEIO* state_fio)
+{
+       if(state_fio->FgetUint32() != STATE_VERSION) {
+               return false;
+       }
+       if(state_fio->FgetInt32() != this_device_id) {
+               return false;
+       }
+       if(!key_buf->load_state((void *)state_fio)) {
+               return false;
+       }
+       if(!rsp_buf->load_state((void *)state_fio)) {
+               return false;
+       }
+       caps = state_fio->FgetBool();
+       kana = state_fio->FgetBool();
+       graph = state_fio->FgetBool();
+       dk = state_fio->FgetInt32();
+       srk = state_fio->FgetInt32();
+       dc = state_fio->FgetInt32();
+       stc = state_fio->FgetInt32();
+       send = state_fio->FgetInt32();
+       recv = state_fio->FgetInt32();
+       phase = state_fio->FgetInt32();
+       timeout = state_fio->FgetInt32();
+       return true;
+}
+