OSDN Git Service

[VM][STATE] Apply New framework to some VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pv2000 / keyboard.cpp
index 0ea142b..9e7e713 100644 (file)
@@ -40,15 +40,15 @@ void KEYBOARD::reset()
        intr_enb = false;
 }
 
-void KEYBOARD::write_io8(uint32 addr, uint32 data)
+void KEYBOARD::write_io8(uint32_t addr, uint32_t data)
 {
        intr_enb = (data == 0xf);
        key_no = data & 0xf;
 }
 
-uint32 KEYBOARD::read_io8(uint32 addr)
+uint32_t KEYBOARD::read_io8(uint32_t addr)
 {
-       uint32 val = 0;
+       uint32_t val = 0;
        
        switch(addr & 0xff) {
        case 0x10:
@@ -110,27 +110,17 @@ void KEYBOARD::key_up(int code)
 
 #define STATE_VERSION  1
 
-void KEYBOARD::save_state(FILEIO* state_fio)
-{
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
-       
-       state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
-       state_fio->FputInt32(key_no);
-       state_fio->FputBool(intr_enb);
-}
 
-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;
        }
-       state_fio->Fread(key_stat, sizeof(key_stat), 1);
-       key_no = state_fio->FgetInt32();
-       intr_enb = state_fio->FgetBool();
+       state_fio->StateBuffer(key_stat, sizeof(key_stat), 1);
+       state_fio->StateInt32(key_no);
+       state_fio->StateBool(intr_enb);
        return true;
 }
-