Diff for /xmil/timing.c between versions 1.2 and 1.5

version 1.2, 2004/08/07 07:19:56 version 1.5, 2008/06/02 20:07:30
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
   #include        "pccore.h"
 #include        "timing.h"  #include        "timing.h"
 #include        "fdd_mtr.h"  #include        "fdd_mtr.h"
   
   
 static const UINT8 tick3[3] = {16, 17, 17};  #define MSSHIFT         16
   
 typedef struct {  typedef struct {
         UINT32  tick;          UINT32  tick;
           UINT32  msstep;
         UINT    cnt;          UINT    cnt;
         UINT    fraction;          UINT32  fraction;
 } TIMING;  } TIMING;
   
 static  TIMING  timing;  static  TIMING  timing;
Line 21  void timing_reset(void) { Line 23  void timing_reset(void) {
         timing.fraction = 0;          timing.fraction = 0;
 }  }
   
   void timing_setrate(UINT32 clock) {
   
           /* timing.msstep = (1 << MSSHIFT) / (clock / 4000) */;
           timing.msstep = (4000 << MSSHIFT) / clock;
   }
   
 void timing_setcount(UINT value) {  void timing_setcount(UINT value) {
   
         timing.cnt = value;          timing.cnt = value;
Line 30  UINT timing_getcount(void) { Line 38  UINT timing_getcount(void) {
   
         UINT32  ticknow;          UINT32  ticknow;
         UINT32  span;          UINT32  span;
         UINT32  steps;          UINT32  fraction;
   
         ticknow = GETTICK();          ticknow = GETTICK();
         span = ticknow - timing.tick;          span = ticknow - timing.tick;
 #if 1  
         if (span < tick3[timing.fraction]) {  
                 ticknow = GETTICK();  
                 span = ticknow - timing.tick;  
         }  
 #endif  
         if (span) {          if (span) {
                 FDDMTR_CALLBACK(ticknow);                  timing.tick = ticknow;
                 if (span >= 50) {                  fddmtr_callback(ticknow);
                         steps = span / 50;  
                         span %= 50;                  if (span >= 1000) {
                         timing.tick += (steps * 50);                          span = 1000;
                         timing.cnt += steps * 3;  
                 }  
                 while(span >= tick3[timing.fraction]) {  
                         span -= tick3[timing.fraction];  
                         timing.tick += tick3[timing.fraction];  
                         timing.cnt++;  
                         timing.fraction++;  
                         if (timing.fraction >= 3) {  
                                 timing.fraction = 0;  
                         }  
                 }                  }
                   fraction = timing.fraction + (span * timing.msstep);
                   timing.cnt += fraction >> MSSHIFT;
                   timing.fraction = fraction & ((1 << MSSHIFT) - 1);
         }          }
         return(timing.cnt);          return(timing.cnt);
 }  }

Removed from v.1.2  
changed lines
  Added in v.1.5


RetroPC.NET-CVS <cvs@retropc.net>