[Project64] Clean up SystemTiming.cpp

This commit is contained in:
zilmar 2015-12-13 17:58:08 +11:00
parent fa680564bd
commit 199fa2f7f8
2 changed files with 362 additions and 365 deletions

View File

@ -15,392 +15,389 @@
#include <Project64-core/N64System/N64Class.h> #include <Project64-core/N64System/N64Class.h>
#include <Project64-core/3rdParty/zip.h> #include <Project64-core/3rdParty/zip.h>
CSystemTimer::CSystemTimer( int & NextTimer ) : CSystemTimer::CSystemTimer(int & NextTimer) :
m_NextTimer(NextTimer), m_NextTimer(NextTimer),
m_inFixTimer(false) m_inFixTimer(false)
{ {
} }
void CSystemTimer::Reset() void CSystemTimer::Reset()
{ {
//initialise Structure //initialise Structure
for (int i = 0; i < MaxTimer; i++) for (int i = 0; i < MaxTimer; i++)
{ {
m_TimerDetatils[i].Active = false; m_TimerDetatils[i].Active = false;
m_TimerDetatils[i].CyclesToTimer = 0; m_TimerDetatils[i].CyclesToTimer = 0;
} }
m_Current = UnknownTimer; m_Current = UnknownTimer;
m_LastUpdate = 0; m_LastUpdate = 0;
m_NextTimer = 0; m_NextTimer = 0;
SetTimer(ViTimer,50000,false); SetTimer(ViTimer, 50000, false);
SetCompareTimer(); SetCompareTimer();
} }
void CSystemTimer::SetTimer ( TimerType Type, uint32_t Cycles, bool bRelative ) void CSystemTimer::SetTimer(TimerType Type, uint32_t Cycles, bool bRelative)
{ {
if (Type >= MaxTimer || Type == UnknownTimer) if (Type >= MaxTimer || Type == UnknownTimer)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
return; return;
} }
UpdateTimers(); UpdateTimers();
m_TimerDetatils[Type].Active = true; m_TimerDetatils[Type].Active = true;
if (bRelative) if (bRelative)
{ {
if (m_TimerDetatils[Type].Active) if (m_TimerDetatils[Type].Active)
{ {
m_TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer m_TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer
} }
else else
{ {
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
} }
} }
else else
{ {
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
} }
FixTimers(); FixTimers();
} }
uint32_t CSystemTimer::GetTimer ( TimerType Type ) uint32_t CSystemTimer::GetTimer(TimerType Type)
{ {
if (Type >= MaxTimer || Type == UnknownTimer) if (Type >= MaxTimer || Type == UnknownTimer)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
return 0; return 0;
} }
if (!m_TimerDetatils[Type].Active) if (!m_TimerDetatils[Type].Active)
{ {
return 0; return 0;
} }
__int64 CyclesToTimer = m_TimerDetatils[Type].CyclesToTimer + m_NextTimer; __int64 CyclesToTimer = m_TimerDetatils[Type].CyclesToTimer + m_NextTimer;
if (CyclesToTimer < 0) if (CyclesToTimer < 0)
{ {
return 0; return 0;
} }
if (CyclesToTimer > 0x7FFFFFFF) if (CyclesToTimer > 0x7FFFFFFF)
{ {
return 0x7FFFFFFF; return 0x7FFFFFFF;
} }
return (uint32_t)CyclesToTimer; return (uint32_t)CyclesToTimer;
} }
void CSystemTimer::StopTimer ( TimerType Type ) void CSystemTimer::StopTimer(TimerType Type)
{ {
if (Type >= MaxTimer || Type == UnknownTimer) if (Type >= MaxTimer || Type == UnknownTimer)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
return; return;
} }
m_TimerDetatils[Type].Active = false; m_TimerDetatils[Type].Active = false;
FixTimers(); FixTimers();
} }
void CSystemTimer::FixTimers() void CSystemTimer::FixTimers()
{ {
if (m_inFixTimer)
{
return;
}
m_inFixTimer = true;
if (m_inFixTimer) UpdateTimers();
{ if (GetTimer(CompareTimer) > 0x60000000)
return; {
} SetCompareTimer();
m_inFixTimer = true; }
UpdateTimers();
if (GetTimer(CompareTimer) > 0x60000000)
{
SetCompareTimer();
}
//Update the cycles for the remaining number of cycles to timer //Update the cycles for the remaining number of cycles to timer
int count; int count;
for (count = 0; count < MaxTimer; count++) for (count = 0; count < MaxTimer; count++)
{ {
if (!m_TimerDetatils[count].Active) if (!m_TimerDetatils[count].Active)
{ {
continue; continue;
} }
m_TimerDetatils[count].CyclesToTimer += m_NextTimer; m_TimerDetatils[count].CyclesToTimer += m_NextTimer;
} }
//Set Max timer //Set Max timer
m_NextTimer = 0x7FFFFFFF; m_NextTimer = 0x7FFFFFFF;
//Find the smallest timer left to go
for (count = 0; count < MaxTimer; count++)
{
if (!m_TimerDetatils[count].Active)
{
continue;
}
if (m_TimerDetatils[count].CyclesToTimer >= m_NextTimer)
{
continue;
}
m_NextTimer = (int)m_TimerDetatils[count].CyclesToTimer;
m_Current = (TimerType)count;
}
//Move the timer back this value //Find the smallest timer left to go
for (count = 0; count < MaxTimer; count++) for (count = 0; count < MaxTimer; count++)
{ {
if (!m_TimerDetatils[count].Active) if (!m_TimerDetatils[count].Active)
{ {
continue; continue;
} }
m_TimerDetatils[count].CyclesToTimer -= m_NextTimer; if (m_TimerDetatils[count].CyclesToTimer >= m_NextTimer)
} {
m_LastUpdate = m_NextTimer; continue;
m_inFixTimer = false; }
m_NextTimer = (int)m_TimerDetatils[count].CyclesToTimer;
m_Current = (TimerType)count;
}
//Move the timer back this value
for (count = 0; count < MaxTimer; count++)
{
if (!m_TimerDetatils[count].Active)
{
continue;
}
m_TimerDetatils[count].CyclesToTimer -= m_NextTimer;
}
m_LastUpdate = m_NextTimer;
m_inFixTimer = false;
} }
void CSystemTimer::UpdateTimers() void CSystemTimer::UpdateTimers()
{ {
int TimeTaken = m_LastUpdate - m_NextTimer; int TimeTaken = m_LastUpdate - m_NextTimer;
if (TimeTaken != 0) if (TimeTaken != 0)
{ {
m_LastUpdate = m_NextTimer; m_LastUpdate = m_NextTimer;
g_Reg->COUNT_REGISTER += TimeTaken; g_Reg->COUNT_REGISTER += TimeTaken;
g_Reg->RANDOM_REGISTER -= TimeTaken / g_System->CountPerOp(); g_Reg->RANDOM_REGISTER -= TimeTaken / g_System->CountPerOp();
while ((int)g_Reg->RANDOM_REGISTER < (int)g_Reg->WIRED_REGISTER) while ((int)g_Reg->RANDOM_REGISTER < (int)g_Reg->WIRED_REGISTER)
{ {
g_Reg->RANDOM_REGISTER += 32 - g_Reg->WIRED_REGISTER; g_Reg->RANDOM_REGISTER += 32 - g_Reg->WIRED_REGISTER;
} }
} }
} }
void CSystemTimer::TimerDone() void CSystemTimer::TimerDone()
{ {
UpdateTimers(); UpdateTimers();
/* uint32_t LastTimer; /* uint32_t LastTimer;
if (Profiling) if (Profiling)
{ {
LastTimer = StartTimer(Timer_Done); LastTimer = StartTimer(Timer_Done);
} }
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts)
{ {
LogMessage("%08X: Timer Done (Type: %d CurrentTimer: %d)", *_PROGRAM_COUNTER, m_Current, *_Timer ); LogMessage("%08X: Timer Done (Type: %d CurrentTimer: %d)", *_PROGRAM_COUNTER, m_Current, *_Timer );
} }
*/ */
switch (m_Current) switch (m_Current)
{ {
case CSystemTimer::CompareTimer: case CSystemTimer::CompareTimer:
g_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP7; g_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP7;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
UpdateCompareTimer(); UpdateCompareTimer();
break; break;
case CSystemTimer::SoftResetTimer: case CSystemTimer::SoftResetTimer:
g_SystemTimer->StopTimer(CSystemTimer::SoftResetTimer); g_SystemTimer->StopTimer(CSystemTimer::SoftResetTimer);
g_System->ExternalEvent(SysEvent_ResetCPU_SoftDone); g_System->ExternalEvent(SysEvent_ResetCPU_SoftDone);
break; break;
case CSystemTimer::SiTimer: case CSystemTimer::SiTimer:
g_SystemTimer->StopTimer(CSystemTimer::SiTimer); g_SystemTimer->StopTimer(CSystemTimer::SiTimer);
g_Reg->MI_INTR_REG |= MI_INTR_SI; g_Reg->MI_INTR_REG |= MI_INTR_SI;
g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
break; break;
case CSystemTimer::PiTimer: case CSystemTimer::PiTimer:
g_SystemTimer->StopTimer(CSystemTimer::PiTimer); g_SystemTimer->StopTimer(CSystemTimer::PiTimer);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
break; break;
case CSystemTimer::ViTimer: case CSystemTimer::ViTimer:
try try
{ {
g_System->RefreshScreen(); g_System->RefreshScreen();
} }
catch (...) catch (...)
{ {
WriteTraceF(TraceError,__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); WriteTraceF(TraceError, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__);
} }
g_Reg->MI_INTR_REG |= MI_INTR_VI; g_Reg->MI_INTR_REG |= MI_INTR_VI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
break; break;
case CSystemTimer::RspTimer: case CSystemTimer::RspTimer:
g_SystemTimer->StopTimer(CSystemTimer::RspTimer); g_SystemTimer->StopTimer(CSystemTimer::RspTimer);
try try
{ {
g_System->RunRSP(); g_System->RunRSP();
} }
catch (...) catch (...)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
} }
break; break;
case CSystemTimer::RSPTimerDlist: case CSystemTimer::RSPTimerDlist:
g_SystemTimer->StopTimer(CSystemTimer::RSPTimerDlist); g_SystemTimer->StopTimer(CSystemTimer::RSPTimerDlist);
g_Reg->m_GfxIntrReg |= MI_INTR_DP; g_Reg->m_GfxIntrReg |= MI_INTR_DP;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
break; break;
case CSystemTimer::AiTimerInterrupt: case CSystemTimer::AiTimerInterrupt:
g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt); g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt);
g_Audio->InterruptTimerDone(); g_Audio->InterruptTimerDone();
break; break;
case CSystemTimer::AiTimerBusy: case CSystemTimer::AiTimerBusy:
g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy); g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy);
g_Audio->BusyTimerDone(); g_Audio->BusyTimerDone();
break; break;
default: default:
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
} }
//CheckTimer(); //CheckTimer();
/*if (Profiling) /*if (Profiling)
{ {
StartTimer(LastTimer); StartTimer(LastTimer);
}*/ }*/
} }
void CSystemTimer::SetCompareTimer() void CSystemTimer::SetCompareTimer()
{ {
uint32_t NextCompare = 0x7FFFFFFF; uint32_t NextCompare = 0x7FFFFFFF;
if (g_Reg) if (g_Reg)
{ {
NextCompare = g_Reg->COMPARE_REGISTER - g_Reg->COUNT_REGISTER; NextCompare = g_Reg->COMPARE_REGISTER - g_Reg->COUNT_REGISTER;
if ((NextCompare & 0x80000000) != 0) if ((NextCompare & 0x80000000) != 0)
{ {
NextCompare = 0x7FFFFFFF; NextCompare = 0x7FFFFFFF;
} }
} }
SetTimer(CompareTimer,NextCompare,false); SetTimer(CompareTimer, NextCompare, false);
} }
void CSystemTimer::UpdateCompareTimer ( void ) void CSystemTimer::UpdateCompareTimer(void)
{ {
SetCompareTimer(); SetCompareTimer();
} }
bool CSystemTimer::SaveAllowed ( void ) bool CSystemTimer::SaveAllowed(void)
{ {
if (GetTimer(CompareTimer) <= 0) if (GetTimer(CompareTimer) <= 0)
{ {
return false; return false;
} }
for (int i = 0; i < MaxTimer; i++) for (int i = 0; i < MaxTimer; i++)
{ {
if (i == CompareTimer) if (i == CompareTimer)
{ {
continue; continue;
} }
if (i == ViTimer) if (i == ViTimer)
{ {
continue; continue;
} }
if (m_TimerDetatils[i].Active) if (m_TimerDetatils[i].Active)
{ {
return false; return false;
} }
} }
return true; return true;
} }
void CSystemTimer::SaveData ( void * file ) const void CSystemTimer::SaveData(void * file) const
{ {
uint32_t TimerDetailsSize = sizeof(TIMER_DETAILS); uint32_t TimerDetailsSize = sizeof(TIMER_DETAILS);
uint32_t Entries = sizeof(m_TimerDetatils)/sizeof(m_TimerDetatils[0]); uint32_t Entries = sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]);
zipWriteInFileInZip(file,&TimerDetailsSize,sizeof(TimerDetailsSize)); zipWriteInFileInZip(file, &TimerDetailsSize, sizeof(TimerDetailsSize));
zipWriteInFileInZip(file,&Entries,sizeof(Entries)); zipWriteInFileInZip(file, &Entries, sizeof(Entries));
zipWriteInFileInZip(file,(void *)&m_TimerDetatils,sizeof(m_TimerDetatils)); zipWriteInFileInZip(file, (void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
zipWriteInFileInZip(file,(void *)&m_LastUpdate,sizeof(m_LastUpdate)); zipWriteInFileInZip(file, (void *)&m_LastUpdate, sizeof(m_LastUpdate));
zipWriteInFileInZip(file,&m_NextTimer,sizeof(m_NextTimer)); zipWriteInFileInZip(file, &m_NextTimer, sizeof(m_NextTimer));
zipWriteInFileInZip(file,(void *)&m_Current,sizeof(m_Current)); zipWriteInFileInZip(file, (void *)&m_Current, sizeof(m_Current));
} }
void CSystemTimer::LoadData ( void * file ) void CSystemTimer::LoadData(void * file)
{ {
uint32_t TimerDetailsSize, Entries; uint32_t TimerDetailsSize, Entries;
unzReadCurrentFile( file,&TimerDetailsSize,sizeof(TimerDetailsSize)); unzReadCurrentFile(file, &TimerDetailsSize, sizeof(TimerDetailsSize));
unzReadCurrentFile( file,&Entries,sizeof(Entries)); unzReadCurrentFile(file, &Entries, sizeof(Entries));
if (TimerDetailsSize != sizeof(TIMER_DETAILS)) if (TimerDetailsSize != sizeof(TIMER_DETAILS))
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
return; return;
} }
if (Entries != sizeof(m_TimerDetatils)/sizeof(m_TimerDetatils[0])) if (Entries != sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]))
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
return; return;
} }
unzReadCurrentFile(file,(void *)&m_TimerDetatils,sizeof(m_TimerDetatils)); unzReadCurrentFile(file, (void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
unzReadCurrentFile(file,(void *)&m_LastUpdate,sizeof(m_LastUpdate)); unzReadCurrentFile(file, (void *)&m_LastUpdate, sizeof(m_LastUpdate));
unzReadCurrentFile(file,&m_NextTimer,sizeof(m_NextTimer)); unzReadCurrentFile(file, &m_NextTimer, sizeof(m_NextTimer));
unzReadCurrentFile(file,(void *)&m_Current,sizeof(m_Current)); unzReadCurrentFile(file, (void *)&m_Current, sizeof(m_Current));
} }
void CSystemTimer::RecordDifference( CLog &LogFile, const CSystemTimer& rSystemTimer) void CSystemTimer::RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer)
{ {
if (m_LastUpdate != rSystemTimer.m_LastUpdate) if (m_LastUpdate != rSystemTimer.m_LastUpdate)
{ {
LogFile.LogF("Timer-LastUpdate: %X %X\r\n",m_LastUpdate,rSystemTimer.m_LastUpdate); LogFile.LogF("Timer-LastUpdate: %X %X\r\n", m_LastUpdate, rSystemTimer.m_LastUpdate);
} }
if (m_NextTimer != rSystemTimer.m_NextTimer) if (m_NextTimer != rSystemTimer.m_NextTimer)
{ {
LogFile.LogF("Timer-NextTimer: %X %X\r\n",m_NextTimer,rSystemTimer.m_NextTimer); LogFile.LogF("Timer-NextTimer: %X %X\r\n", m_NextTimer, rSystemTimer.m_NextTimer);
} }
if (m_Current != rSystemTimer.m_Current) if (m_Current != rSystemTimer.m_Current)
{ {
LogFile.LogF("Timer-Current %X %X\r\n",m_Current,rSystemTimer.m_Current); LogFile.LogF("Timer-Current %X %X\r\n", m_Current, rSystemTimer.m_Current);
} }
if (m_inFixTimer != rSystemTimer.m_inFixTimer) if (m_inFixTimer != rSystemTimer.m_inFixTimer)
{ {
LogFile.LogF("Timer-inFixTimer %X %X\r\n",(int)m_inFixTimer,(int)rSystemTimer.m_inFixTimer); LogFile.LogF("Timer-inFixTimer %X %X\r\n", (int)m_inFixTimer, (int)rSystemTimer.m_inFixTimer);
} }
for (int i = 0; i < MaxTimer; i++) for (int i = 0; i < MaxTimer; i++)
{ {
if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active) if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active)
{ {
LogFile.LogF("Timer-m_TimerDetatils[%d] %X %X\r\n",i,(int)m_TimerDetatils[i].Active,(int)rSystemTimer.m_TimerDetatils[i].Active); LogFile.LogF("Timer-m_TimerDetatils[%d] %X %X\r\n", i, (int)m_TimerDetatils[i].Active, (int)rSystemTimer.m_TimerDetatils[i].Active);
} }
if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer) if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer)
{ {
LogFile.LogF("Timer-m_TimerDetatils[%d] 0x%08X, 0x%08X\r\n",i,(uint32_t)m_TimerDetatils[i].CyclesToTimer,(uint32_t)rSystemTimer.m_TimerDetatils[i].CyclesToTimer ); LogFile.LogF("Timer-m_TimerDetatils[%d] 0x%08X, 0x%08X\r\n", i, (uint32_t)m_TimerDetatils[i].CyclesToTimer, (uint32_t)rSystemTimer.m_TimerDetatils[i].CyclesToTimer);
} }
} }
} }
bool CSystemTimer::operator == (const CSystemTimer& rSystemTimer) const bool CSystemTimer::operator == (const CSystemTimer& rSystemTimer) const
{ {
if (m_LastUpdate != rSystemTimer.m_LastUpdate) if (m_LastUpdate != rSystemTimer.m_LastUpdate)
{ {
return false; return false;
} }
if (m_NextTimer != rSystemTimer.m_NextTimer) if (m_NextTimer != rSystemTimer.m_NextTimer)
{ {
return false; return false;
} }
if (m_Current != rSystemTimer.m_Current) if (m_Current != rSystemTimer.m_Current)
{ {
return false; return false;
} }
if (m_inFixTimer != rSystemTimer.m_inFixTimer) if (m_inFixTimer != rSystemTimer.m_inFixTimer)
{ {
return false; return false;
} }
for (int i = 0; i < MaxTimer; i++) for (int i = 0; i < MaxTimer; i++)
{ {
if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active) if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active)
{ {
return false; return false;
} }
if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer) if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer)
{ {
return false; return false;
} }
} }
return true; return true;
} }
bool CSystemTimer::operator != (const CSystemTimer& rSystemTimer) const bool CSystemTimer::operator != (const CSystemTimer& rSystemTimer) const
{ {
return !(*this == rSystemTimer); return !(*this == rSystemTimer);
} }

View File

@ -16,56 +16,56 @@
class CSystemTimer class CSystemTimer
{ {
public: public:
enum TimerType enum TimerType
{ {
UnknownTimer, UnknownTimer,
CompareTimer, CompareTimer,
SoftResetTimer, SoftResetTimer,
ViTimer, ViTimer,
AiTimerInterrupt, AiTimerInterrupt,
AiTimerBusy, AiTimerBusy,
AiTimerDMA, AiTimerDMA,
SiTimer, SiTimer,
PiTimer, PiTimer,
RspTimer, RspTimer,
RSPTimerDlist, RSPTimerDlist,
MaxTimer MaxTimer
}; };
struct TIMER_DETAILS struct TIMER_DETAILS
{ {
bool Active; bool Active;
__int64 CyclesToTimer; __int64 CyclesToTimer;
}; };
public: public:
CSystemTimer ( int & NextTimer ); CSystemTimer(int & NextTimer);
void SetTimer(TimerType Type, uint32_t Cycles, bool bRelative); void SetTimer(TimerType Type, uint32_t Cycles, bool bRelative);
uint32_t GetTimer(TimerType Type); uint32_t GetTimer(TimerType Type);
void StopTimer ( TimerType Type ); void StopTimer(TimerType Type);
void UpdateTimers (); void UpdateTimers();
void TimerDone (); void TimerDone();
void Reset (); void Reset();
void UpdateCompareTimer (); void UpdateCompareTimer();
bool SaveAllowed (); bool SaveAllowed();
void SaveData ( void * file ) const;
void LoadData ( void * file );
void RecordDifference( CLog &LogFile, const CSystemTimer& rSystemTimer); void SaveData(void * file) const;
void LoadData(void * file);
TimerType CurrentType() const { return m_Current; } void RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer);
bool operator == (const CSystemTimer& rSystemTimer) const; TimerType CurrentType() const { return m_Current; }
bool operator != (const CSystemTimer& rSystemTimer) const;
bool operator == (const CSystemTimer& rSystemTimer) const;
bool operator != (const CSystemTimer& rSystemTimer) const;
private: private:
TIMER_DETAILS m_TimerDetatils[MaxTimer]; TIMER_DETAILS m_TimerDetatils[MaxTimer];
int m_LastUpdate; //Timer at last update int m_LastUpdate; //Timer at last update
int & m_NextTimer; int & m_NextTimer;
TimerType m_Current; TimerType m_Current;
bool m_inFixTimer; bool m_inFixTimer;
void SetCompareTimer(); void SetCompareTimer();
void FixTimers(); void FixTimers();
}; };