forked from sin365/AxibugEmuOnline
59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
|
//
|
|||
|
// Multimedia timer support
|
|||
|
//
|
|||
|
#include "DebugOut.h"
|
|||
|
#include "MMTimer.h"
|
|||
|
|
|||
|
// <20>R<EFBFBD><52><EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>N<EFBFBD>^/<2F>f<EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>N<EFBFBD>^<5E>ׂ̈̃C<CC83><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X
|
|||
|
static CMMTimer MMTimer;
|
|||
|
|
|||
|
BOOL CMMTimer::m_bInitialize = FALSE;
|
|||
|
|
|||
|
BOOL CMMTimer::m_bHigh = FALSE;
|
|||
|
SQWORD CMMTimer::m_hpFrequency = 0;
|
|||
|
|
|||
|
CMMTimer::CMMTimer()
|
|||
|
{
|
|||
|
// 1ms<6D>P<EFBFBD>ʂ<EFBFBD><CA82>ۏ<DB8F><D882><EFBFBD><EFBFBD>ׂ<EFBFBD><D782><EFBFBD><EFBFBD>ɌĂԁc<D481>Ȃイ<F182BF82>d<EFBFBD>l<EFBFBD><6C><EFBFBD><EFBFBD>
|
|||
|
if( !m_bInitialize ) {
|
|||
|
if( ::timeBeginPeriod( 1 ) == TIMERR_NOERROR )
|
|||
|
m_bInitialize = TRUE;
|
|||
|
}
|
|||
|
|
|||
|
// <20>n<EFBFBD>C<EFBFBD>p<EFBFBD>t<EFBFBD>H<EFBFBD>[<5B>}<7D><><EFBFBD>X<EFBFBD>J<EFBFBD>E<EFBFBD><45><EFBFBD>^<5E>ł̎<C582><CC8E>Ԍv<D48C><76><EFBFBD>p
|
|||
|
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;
|
|||
|
}
|
|||
|
|