
#endif
#ifdef OLD      
#ifndef BASIC
      if (++test_val == refresh_rate)
	{
	  ANTIC_RunDisplayList ();
	  Atari_DisplayScreen ((UBYTE*)atari_screen);
	  test_val = 0;
	}
      else
	{
	  ANTIC_RunDisplayList ();
/*
	  for (ypos = 0;ypos < 8; ypos++)
	    GO (114);
	  NMIST = 0x3f; // Reset VBLANK

	  for (ypos=8;ypos<ATARI_HEIGHT;ypos++)
	    {
	      GO (114);
	    }

	  NMIST |= 0x40; // Set VBLANK 
	  if (NMIEN & 0x40)
	    {
	      GO (1); 
	      NMI ();
	    }
*/

	}
#else
      for (ypos=0;ypos<ATARI_HEIGHT;ypos++)
	{
	  GO (114);
	}
#endif
#endif
    }

#ifndef DJGPP
      if (deltatime > 0.0)
	{
	  if (lasttime >= 0.0)
	    {
	      double curtime;

	      do
		{
		  gettimeofday (&tp, &tzp);
		  curtime = tp.tv_sec + (tp.tv_usec / 1000000.0);
		} while (curtime < (lasttime + deltatime));
	  
	      lasttime = curtime;
	    }
	  else
	    {
	      gettimeofday (&tp, &tzp);
	      lasttime = tp.tv_sec + (tp.tv_usec / 1000000.0);
	    }
	}
#else  // for dos, count ticks and use the ticks_per_second global variable
       // Use the high speed clock tick function uclock()
      if (deltatime > 0.0) {
        static uclock_t lasttime = 0;
        uclock_t curtime, uclockd;
        unsigned long uclockd_hi, uclockd_lo;
        unsigned long uclocks_per_int;

        uclocks_per_int = (deltatime * (double) UCLOCKS_PER_SEC) + 0.5;
        // printf( "ticks_per_int %d, %.8X\n", uclocks_per_int, (unsigned long) lasttime );

        do {
          curtime = uclock();
          if( curtime > lasttime ) {
            uclockd = curtime - lasttime;
          }
          else {
            uclockd = ((uclock_t) ~0 - lasttime) + curtime + (uclock_t) 1;
          }
          uclockd_lo = (unsigned long) uclockd;
          uclockd_hi = (unsigned long) (uclockd >> 32);
        } while( (uclockd_hi == 0) && (uclocks_per_int > uclockd_lo) );

        lasttime = curtime;
      }
#endif
    }
