AxibugEmuOnline/References/virtuanessrc097-master/MMTimer.cpp

59 lines
2.2 KiB
C++
Raw Normal View History

<EFBFBD><EFBFBD>//
// Multimedia timer support
//
#include "DebugOut.h"
#include "MMTimer.h"
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0/<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0n0<EFBFBD>pn0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
static CMMTimer MMTimer;
BOOL CMMTimer::m_bInitialize = FALSE;
BOOL CMMTimer::m_bHigh = FALSE;
SQWORD CMMTimer::m_hpFrequency = 0;
CMMTimer::CMMTimer()
{
// 1msXSMO<EFBFBD>0<EFBFBD>O<<EFBFBD>Y0<EFBFBD>0<EFBFBD>p`0Q0k0|Tv0& j0<EFBFBD>0a0<EFBFBD>0F0<EFBFBD>N<EFBFBD>iX0<EFBFBD>0
if( !m_bInitialize ) {
if( ::timeBeginPeriod( 1 ) == TIMERR_NOERROR )
m_bInitialize = TRUE;
}
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0g0n0Bf<EFBFBD><EFBFBD><EFBFBD>,n(u
if( ::QueryPerformanceFrequency( (LARGE_INTEGER*)&m_hpFrequency ) ) {
DEBUGOUT( "CMMTimer:Use high performance counter.(QueryPerformanceCounter)\n" );
m_bHigh = TRUE;
}
}
CMMTimer::~CMMTimer()
{
if( m_bInitialize ) {
::timeEndPeriod( 1 );
m_bInitialize = FALSE;
}
}
SQWORD CMMTimer::GetMMTimer()
{
if( m_bHigh ) {
SQWORD freq;
::QueryPerformanceCounter( (LARGE_INTEGER*)&freq );
return freq;
}
return (SQWORD)::timeGetTime();
}
FLOAT CMMTimer::CalcTimeDifference( SQWORD t0, SQWORD t1 )
{
if( m_bHigh ) {
return (FLOAT)(1000.0*(double)(t1-t0)/(double)m_hpFrequency);
}
return (FLOAT)(t1-t0)*1000.0f;
}