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 d6874e1..2fc3c93 100644 (file)
@@ -18,11 +18,15 @@ void PRNFILE::initialize()
        fio = new FILEIO();
        
        value = busy_id = ack_id = wait_frames = -1;
-#ifdef PRINTER_STROBE_RISING_EDGE
-       strobe = false;
-#else
+       _PRINTER_STROBE_RISING_EDGE = osd->check_feature(_T("PRINTER_STROBE_RISING_EDGE"));
+//#ifdef PRINTER_STROBE_RISING_EDGE
+       if(_PRINTER_STROBE_RISING_EDGE) {
+               strobe = false;
+       } else {
+//#else
        strobe = true;
-#endif
+       }
+//#endif
        res = busy = false;
        set_busy(false);
        set_ack(true);
@@ -62,11 +66,15 @@ void PRNFILE::write_signal(int id, uint32_t data, uint32_t mask)
                value |= (data & mask);
        } else if(id == SIG_PRINTER_STROBE) {
                bool new_strobe = ((data & mask) != 0);
-#ifdef PRINTER_STROBE_RISING_EDGE
-               bool edge = (!strobe && new_strobe);
-#else
-               bool edge = (strobe && !new_strobe);
-#endif
+//#ifdef PRINTER_STROBE_RISING_EDGE
+               bool edge;
+               if(_PRINTER_STROBE_RISING_EDGE) {
+                       edge = (!strobe && new_strobe);
+               } else {
+//#else
+                       edge = (strobe && !new_strobe);
+               }
+//#endif
                strobe = new_strobe;
                
                if(edge && value != -1) {
@@ -83,11 +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
                }
        } else if(id == SIG_PRINTER_RESET) {
                bool new_res = ((data & mask) != 0);
@@ -168,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;
 }