OSDN Git Service

[VM][STATE] Use namespace {VMNAME} to separate per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz5500 / keyboard.cpp
index 2ff7f96..e5e6762 100644 (file)
 #include "../i8259.h"
 #include "../../fifo.h"
 
-#define BIT_DK 8
+#define BIT_DK 0x08
 #define BIT_SRK        0x10
-#define BIT_DC 1
-#define BIT_STC        2
+#define BIT_DC 0x01
+#define BIT_STC        0x02
 
 #define PHASE_IDLE     0
 
@@ -61,6 +61,8 @@
 #define TIMEOUT_500MSEC        30
 #define TIMEOUT_100MSEC        6
 
+namespace MZ5500 {
+
 static const int key_table[256] = {
        0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x008,0x009,0x000,0x000,0x000,0x00d,0x000,0x000,
        0x000,0x000,0x000,0x006,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x01b,0x000,0x000,0x000,0x000,
@@ -185,8 +187,8 @@ static const int key_table_graph_shift[256] = {
 
 void KEYBOARD::initialize()
 {
-       key_stat = emu->key_buffer();
-       mouse_stat = emu->mouse_buffer();
+       key_stat = emu->get_key_buffer();
+       mouse_stat = emu->get_mouse_buffer();
        key_buf = new FIFO(64);
        rsp_buf = new FIFO(16);
        caps = kana = graph = false;
@@ -213,7 +215,7 @@ void KEYBOARD::reset()
        timeout = 0;
 }
 
-void KEYBOARD::write_signal(int id, uint32 data, uint32 mask)
+void KEYBOARD::write_signal(int id, uint32_t data, uint32_t mask)
 {
        // from 8255 port c
        dc = (data & BIT_DC) ? 0 : 1;
@@ -466,51 +468,32 @@ 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)
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
 {
-       if(state_fio->FgetUint32() != STATE_VERSION) {
+       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       if(state_fio->FgetInt32() != this_device_id) {
+       if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       if(!key_buf->load_state((void *)state_fio)) {
+       if(!key_buf->process_state((void *)state_fio, loading)) {
                return false;
        }
-       if(!rsp_buf->load_state((void *)state_fio)) {
+       if(!rsp_buf->process_state((void *)state_fio, loading)) {
                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();
+       state_fio->StateBool(caps);
+       state_fio->StateBool(kana);
+       state_fio->StateBool(graph);
+       state_fio->StateInt32(dk);
+       state_fio->StateInt32(srk);
+       state_fio->StateInt32(dc);
+       state_fio->StateInt32(stc);
+       state_fio->StateInt32(send);
+       state_fio->StateInt32(recv);
+       state_fio->StateInt32(phase);
+       state_fio->StateInt32(timeout);
        return true;
 }
 
+}