OSDN Git Service

[VM][General] Apply Upstream 2018-10-07.Still WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / prnfile.cpp
index 46da1cf..2fc3c93 100644 (file)
@@ -91,12 +91,7 @@ void PRNFILE::write_signal(int id, uint32_t data, uint32_t mask)
                        set_busy(true);
                        
                        // wait 1sec and finish printing
-//#ifdef SUPPORT_VARIABLE_TIMING
-//                     wait_frames = (int)(vm->get_frame_rate() * 1.0 + 0.5);
-//#else
-//                     wait_frames = (int)(FRAMES_PER_SEC * 1.0 + 0.5);
-//#endif
-                       wait_frames = (int)(osd->vm_frame_rate() * 1.0 + 0.5);
+                       wait_frames = (int)(vm->get_frame_rate() * 1.0 + 0.5);
                }
        } else if(id == SIG_PRINTER_RESET) {
                bool new_res = ((data & mask) != 0);
@@ -177,40 +172,30 @@ void PRNFILE::close_file()
 
 #define STATE_VERSION  2
 
-void PRNFILE::save_state(FILEIO* state_fio)
-{
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
-       
-       state_fio->FputInt32(value);
-       state_fio->FputInt32(busy_id);
-       state_fio->FputInt32(ack_id);
-       state_fio->FputBool(strobe);
-       state_fio->FputBool(res);
-       state_fio->FputBool(busy);
-       state_fio->FputBool(ack);
-}
-
-bool PRNFILE::load_state(FILEIO* state_fio)
+bool PRNFILE::process_state(FILEIO* state_fio, bool loading)
 {
-       close_file();
-       
-       if(state_fio->FgetUint32() != STATE_VERSION) {
-               return false;
+       if(loading) {
+               //close_file();
        }
-       if(state_fio->FgetInt32() != this_device_id) {
-               return false;
-       }
-       value = state_fio->FgetInt32();
-       busy_id = state_fio->FgetInt32();
-       ack_id = state_fio->FgetInt32();
-       strobe = state_fio->FgetBool();
-       res = state_fio->FgetBool();
-       busy = state_fio->FgetBool();
-       ack = state_fio->FgetBool();
        
-       // post process
-       wait_frames = -1;
-       return true;
+       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+               return false;
+       }
+       if(!state_fio->StateCheckInt32(this_device_id)) {
+               return false;
+       }
+       state_fio->StateInt32(value);
+       state_fio->StateInt32(busy_id);
+       state_fio->StateInt32(ack_id);
+       state_fio->StateBool(strobe);
+       state_fio->StateBool(res);
+       state_fio->StateBool(busy);
+       state_fio->StateBool(ack);
+       
+       // post process
+       if(loading) {
+               wait_frames = -1;
+       }
+       return true;
 }