OSDN Git Service

[General] Tracking to upstream, rev 2015-01-14.
[csp-qt/common_source_project-fm7.git] / source / src / vm / rx78 / keyboard.cpp
index 6462da5..80d99a2 100644 (file)
@@ -8,6 +8,7 @@
 */\r
 \r
 #include "keyboard.h"\r
+#include "../../fileio.h"\r
 \r
 static const int key_map[9][8] = {\r
        {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37},\r
@@ -91,3 +92,28 @@ void KEYBOARD::event_frame()
        }\r
        status[15] = total;\r
 }\r
+\r
+#define STATE_VERSION  1\r
+\r
+void KEYBOARD::save_state(FILEIO* state_fio)\r
+{\r
+       state_fio->FputUint32(STATE_VERSION);\r
+       state_fio->FputInt32(this_device_id);\r
+       \r
+       state_fio->Fwrite(status, sizeof(status), 1);\r
+       state_fio->FputUint8(column);\r
+}\r
+\r
+bool KEYBOARD::load_state(FILEIO* state_fio)\r
+{\r
+       if(state_fio->FgetUint32() != STATE_VERSION) {\r
+               return false;\r
+       }\r
+       if(state_fio->FgetInt32() != this_device_id) {\r
+               return false;\r
+       }\r
+       state_fio->Fread(status, sizeof(status), 1);\r
+       column = state_fio->FgetUint8();\r
+       return true;\r
+}\r
+\r