74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
/***************************************************************************/
|
|
/* Description: Timer.cxx */
|
|
/* */
|
|
/* Author: M. Trabucato */
|
|
/* Last Update : 30/04/98 Take PSX account */
|
|
/***************************************************************************/
|
|
|
|
|
|
/* this file is included by Timer.c*/
|
|
|
|
/*
|
|
Makes some internal initializations.
|
|
*/
|
|
short __stdcall TMR_fn_wInitLibrary( void )
|
|
{
|
|
/* Test if the library has already been initialized */
|
|
if (TimerLibOk != 0) return (0);
|
|
|
|
memset((unsigned char*)a_stTimerTab,0,sizeof(tdstTimer)*C_uwTimerMaxCount);
|
|
wTimerCount = 0;
|
|
|
|
/* Set the low frequency timer number of ticks per second */
|
|
a3_ulTimerFrequency[C_wTimerFrequencyLow] = fn_ulTimerTickPerSecond(C_wTimerFrequencyLow);
|
|
|
|
/* Set the medium frequency timer number of ticks per second */
|
|
a3_ulTimerFrequency[C_wTimerFrequencyMedium] = fn_ulTimerTickPerSecond(C_wTimerFrequencyMedium);
|
|
|
|
/* Set the high frequency timer number of ticks per second */
|
|
a3_ulTimerFrequency[C_wTimerFrequencyHigh] = fn_ulTimerTickPerSecond(C_wTimerFrequencyHigh);
|
|
|
|
/* Define the Timer event resolution */
|
|
a3_ulEventFrequency[C_wTimerFrequencyLow] = fn_ulTimerEventTickPerSecond(C_wTimerFrequencyLow);
|
|
|
|
/* Define the Timer event resolution */
|
|
a3_ulEventFrequency[C_wTimerFrequencyMedium] = fn_ulTimerEventTickPerSecond(C_wTimerFrequencyMedium);
|
|
|
|
/* Define the Timer event resolution */
|
|
a3_ulEventFrequency[C_wTimerFrequencyHigh] = fn_ulTimerEventTickPerSecond(C_wTimerFrequencyHigh);
|
|
|
|
/* Init CPA errors */
|
|
if (!TMR_g_wErmOK)
|
|
{
|
|
Erm_M_InitErrMsg(Tmr);
|
|
TMR_g_wErmOK = 1;
|
|
}
|
|
|
|
TimerLibOk++;
|
|
|
|
return (0);
|
|
}
|
|
|
|
|
|
/*
|
|
Makes some internal initializations.
|
|
*/
|
|
short __stdcall TMR_fn_wExitLibrary( void )
|
|
{
|
|
short wTimerNum;
|
|
|
|
if (TimerLibOk > 0)
|
|
{
|
|
/* Destroy all Timer*/
|
|
for (wTimerNum=0 ; wTimerNum < C_uwTimerMaxCount ; wTimerNum++)
|
|
if (a_stTimerTab[wTimerNum].m_wTimerState != C_wTimerUnused)
|
|
TMR_fn_wDestroyTimer(wTimerNum);
|
|
fn_wTimerReleaseEvents();
|
|
wTimerCount = 0;
|
|
|
|
TimerLibOk = 0;
|
|
}
|
|
|
|
return (0);
|
|
}
|