//This file should not be modifed. //It has always worked properly #include "timer.h" TIMER gTimer; void TimerInit(void) // Initialize Our Timer (Get It Ready) { memset(&gTimer, 0, sizeof(gTimer)); // Clear Our Timer Structure #ifdef WIN32 // Check To See If A Performance Counter Is Available // If One Is Available The Timer Frequency Will Be Updated if (!QueryPerformanceFrequency((LARGE_INTEGER *) &gTimer.frequency)) { // No Performace Counter Available gTimer.performance_timer = FALSE; // Set Performance Timer To FALSE gTimer.mm_timer_start = (unsigned long)TimerGetTime(); // Use TimerGetTime() To Get Current Time gTimer.resolution = 1.0f/1000.0f; // Set Our Timer Resolution To .001f gTimer.frequency = 1000; // Set Our Timer Frequency To 1000 gTimer.mm_timer_elapsed = gTimer.mm_timer_start; // Set The Elapsed Time To The Current Time } else { // Performance Counter Is Available, Use It Instead Of The Multimedia Timer // Get The Current Time And Store It In performance_timer_start QueryPerformanceCounter((LARGE_INTEGER *) &gTimer.performance_timer_start); gTimer.performance_timer = TRUE; // Set Performance Timer To TRUE // Calculate The Timer Resolution Using The Timer Frequency gTimer.resolution = (float) (((double)1.0f)/((double)gTimer.frequency)); // Set The Elapsed Time To The Current Time gTimer.performance_timer_elapsed = gTimer.performance_timer_start; } #else #endif } float TimerGetTime() // Get Time In Milliseconds { #ifdef WIN32 __int64 time; // time Will Hold A 64 Bit Integer if (true || gTimer.performance_timer) // Are We Using The Performance Timer? { QueryPerformanceCounter((LARGE_INTEGER *) &time); // Grab The Current Performance Time // Return The Current Time Minus The Start Time Multiplied By The Resolution And 1000 (To Get MS) return ( (float) ( time - gTimer.performance_timer_start) * gTimer.resolution)*1000.0f; } #endif return 0; }