2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2012-12-19 09:30:18 +00:00
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2010-05-23 10:05:41 +00:00
|
|
|
#include "stdafx.h"
|
2016-01-13 11:15:30 +00:00
|
|
|
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/N64System/SystemGlobals.h>
|
|
|
|
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
2016-01-23 21:44:58 +00:00
|
|
|
#include <Project64-core/N64System/Mips/Disk.h>
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/N64System/N64Class.h>
|
|
|
|
#include <Project64-core/3rdParty/zip.h>
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2017-04-27 22:09:04 +00:00
|
|
|
CSystemTimer::CSystemTimer(CRegisters &Reg, int32_t & NextTimer) :
|
|
|
|
m_LastUpdate(0),
|
|
|
|
m_NextTimer(NextTimer),
|
|
|
|
m_Current(UnknownTimer),
|
|
|
|
m_inFixTimer(false),
|
|
|
|
m_Reg(Reg)
|
2010-05-23 10:05:41 +00:00
|
|
|
{
|
2017-04-27 22:09:04 +00:00
|
|
|
memset(m_TimerDetatils, 0, sizeof(m_TimerDetatils));
|
2010-05-23 10:05:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void CSystemTimer::Reset()
|
2010-05-23 10:05:41 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
//initialise Structure
|
|
|
|
for (int i = 0; i < MaxTimer; i++)
|
|
|
|
{
|
|
|
|
m_TimerDetatils[i].Active = false;
|
|
|
|
m_TimerDetatils[i].CyclesToTimer = 0;
|
|
|
|
}
|
|
|
|
m_Current = UnknownTimer;
|
|
|
|
m_LastUpdate = 0;
|
|
|
|
m_NextTimer = 0;
|
2010-06-12 02:02:06 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
SetTimer(ViTimer, 50000, false);
|
|
|
|
SetCompareTimer();
|
2010-05-23 10:05:41 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
void CSystemTimer::SetTimer(TimerType Type, uint32_t Cycles, bool bRelative)
|
2010-05-23 10:05:41 +00:00
|
|
|
{
|
2017-06-15 11:09:49 +00:00
|
|
|
Cycles *= CGameSettings::OverClockModifier();
|
2015-12-13 06:58:08 +00:00
|
|
|
if (Type >= MaxTimer || Type == UnknownTimer)
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
UpdateTimers();
|
|
|
|
|
|
|
|
m_TimerDetatils[Type].Active = true;
|
|
|
|
if (bRelative)
|
|
|
|
{
|
|
|
|
if (m_TimerDetatils[Type].Active)
|
|
|
|
{
|
|
|
|
m_TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-21 21:38:56 +00:00
|
|
|
m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; //replace the new cycles
|
2015-12-13 06:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-21 21:38:56 +00:00
|
|
|
m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; //replace the new cycles
|
2015-12-13 06:58:08 +00:00
|
|
|
}
|
|
|
|
FixTimers();
|
2010-05-23 10:05:41 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
uint32_t CSystemTimer::GetTimer(TimerType Type)
|
2010-06-14 21:14:58 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
if (Type >= MaxTimer || Type == UnknownTimer)
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!m_TimerDetatils[Type].Active)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-12-21 21:38:56 +00:00
|
|
|
int64_t CyclesToTimer = m_TimerDetatils[Type].CyclesToTimer + m_NextTimer;
|
2015-12-13 06:58:08 +00:00
|
|
|
if (CyclesToTimer < 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (CyclesToTimer > 0x7FFFFFFF)
|
|
|
|
{
|
|
|
|
return 0x7FFFFFFF;
|
|
|
|
}
|
2017-06-15 11:09:49 +00:00
|
|
|
return (uint32_t)(CyclesToTimer / CGameSettings::OverClockModifier());
|
2010-06-14 21:14:58 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
void CSystemTimer::StopTimer(TimerType Type)
|
2010-05-23 10:05:41 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
if (Type >= MaxTimer || Type == UnknownTimer)
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_TimerDetatils[Type].Active = false;
|
|
|
|
FixTimers();
|
2010-05-23 10:05:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void CSystemTimer::FixTimers()
|
2010-05-23 10:05:41 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
if (m_inFixTimer)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_inFixTimer = true;
|
2010-07-05 11:29:46 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
UpdateTimers();
|
|
|
|
if (GetTimer(CompareTimer) > 0x60000000)
|
|
|
|
{
|
|
|
|
SetCompareTimer();
|
|
|
|
}
|
2010-07-05 11:29:46 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
//Update the cycles for the remaining number of cycles to timer
|
|
|
|
int count;
|
|
|
|
for (count = 0; count < MaxTimer; count++)
|
|
|
|
{
|
|
|
|
if (!m_TimerDetatils[count].Active)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
m_TimerDetatils[count].CyclesToTimer += m_NextTimer;
|
|
|
|
}
|
2010-05-23 10:05:41 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
//Set Max timer
|
|
|
|
m_NextTimer = 0x7FFFFFFF;
|
2010-05-23 10:05:41 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
//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
|
|
|
|
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;
|
2010-05-23 10:05:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void CSystemTimer::UpdateTimers()
|
2010-05-23 10:05:41 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
int TimeTaken = m_LastUpdate - m_NextTimer;
|
|
|
|
if (TimeTaken != 0)
|
|
|
|
{
|
2016-02-10 02:20:05 +00:00
|
|
|
int32_t random, wired;
|
2015-12-13 06:58:08 +00:00
|
|
|
m_LastUpdate = m_NextTimer;
|
2017-06-15 11:09:49 +00:00
|
|
|
m_Reg.COUNT_REGISTER += (TimeTaken / CGameSettings::OverClockModifier());
|
2017-04-27 22:09:04 +00:00
|
|
|
random = m_Reg.RANDOM_REGISTER - (TimeTaken / g_System->CountPerOp());
|
|
|
|
wired = m_Reg.WIRED_REGISTER;
|
2016-02-10 02:20:05 +00:00
|
|
|
if (random < wired)
|
2015-12-13 06:58:08 +00:00
|
|
|
{
|
2016-02-06 08:07:15 +00:00
|
|
|
if (wired == 0)
|
|
|
|
{
|
|
|
|
random &= 31;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uint32_t increment = 32 - wired;
|
2016-02-10 02:20:05 +00:00
|
|
|
random += ((wired - random + increment - 1) / increment) * increment;
|
2016-02-06 08:07:15 +00:00
|
|
|
}
|
2015-12-13 06:58:08 +00:00
|
|
|
}
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.RANDOM_REGISTER = random;
|
2015-12-13 06:58:08 +00:00
|
|
|
}
|
2010-05-23 10:05:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void CSystemTimer::TimerDone()
|
2010-05-23 10:05:41 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
UpdateTimers();
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
switch (m_Current)
|
|
|
|
{
|
|
|
|
case CSystemTimer::CompareTimer:
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.FAKE_CAUSE_REGISTER |= CAUSE_IP7;
|
|
|
|
m_Reg.CheckInterrupts();
|
2015-12-13 06:58:08 +00:00
|
|
|
UpdateCompareTimer();
|
|
|
|
break;
|
|
|
|
case CSystemTimer::SoftResetTimer:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::SoftResetTimer);
|
|
|
|
g_System->ExternalEvent(SysEvent_ResetCPU_SoftDone);
|
|
|
|
break;
|
|
|
|
case CSystemTimer::SiTimer:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::SiTimer);
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.MI_INTR_REG |= MI_INTR_SI;
|
|
|
|
m_Reg.SI_STATUS_REG |= SI_STATUS_INTERRUPT;
|
|
|
|
m_Reg.CheckInterrupts();
|
2015-12-13 06:58:08 +00:00
|
|
|
break;
|
|
|
|
case CSystemTimer::PiTimer:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::PiTimer);
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
|
|
|
m_Reg.MI_INTR_REG |= MI_INTR_PI;
|
|
|
|
m_Reg.CheckInterrupts();
|
2015-12-13 06:58:08 +00:00
|
|
|
break;
|
2016-01-23 21:44:58 +00:00
|
|
|
case CSystemTimer::DDPiTimer:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::DDPiTimer);
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
2016-01-23 21:44:58 +00:00
|
|
|
DiskBMUpdate();
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.MI_INTR_REG |= MI_INTR_PI;
|
|
|
|
m_Reg.CheckInterrupts();
|
2016-01-23 21:44:58 +00:00
|
|
|
break;
|
2015-12-13 06:58:08 +00:00
|
|
|
case CSystemTimer::ViTimer:
|
|
|
|
try
|
|
|
|
{
|
|
|
|
g_System->RefreshScreen();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceN64System, TraceError, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__);
|
2015-12-13 06:58:08 +00:00
|
|
|
}
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.MI_INTR_REG |= MI_INTR_VI;
|
|
|
|
m_Reg.CheckInterrupts();
|
2015-12-13 06:58:08 +00:00
|
|
|
break;
|
|
|
|
case CSystemTimer::RspTimer:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::RspTimer);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
g_System->RunRSP();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CSystemTimer::RSPTimerDlist:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::RSPTimerDlist);
|
2017-04-27 22:09:04 +00:00
|
|
|
m_Reg.m_GfxIntrReg |= MI_INTR_DP;
|
|
|
|
m_Reg.CheckInterrupts();
|
2015-12-13 06:58:08 +00:00
|
|
|
break;
|
|
|
|
case CSystemTimer::AiTimerInterrupt:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt);
|
|
|
|
g_Audio->InterruptTimerDone();
|
|
|
|
break;
|
|
|
|
case CSystemTimer::AiTimerBusy:
|
|
|
|
g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy);
|
|
|
|
g_Audio->BusyTimerDone();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
//CheckTimer();
|
|
|
|
/*if (Profiling)
|
|
|
|
{
|
|
|
|
StartTimer(LastTimer);
|
|
|
|
}*/
|
2010-05-23 10:05:41 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void CSystemTimer::SetCompareTimer()
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
uint32_t NextCompare = 0x7FFFFFFF;
|
|
|
|
if (g_Reg)
|
|
|
|
{
|
2017-04-27 22:09:04 +00:00
|
|
|
NextCompare = m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER;
|
2015-12-13 06:58:08 +00:00
|
|
|
if ((NextCompare & 0x80000000) != 0)
|
|
|
|
{
|
|
|
|
NextCompare = 0x7FFFFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetTimer(CompareTimer, NextCompare, false);
|
2010-07-05 11:29:46 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
void CSystemTimer::UpdateCompareTimer(void)
|
2010-07-05 11:29:46 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
SetCompareTimer();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
bool CSystemTimer::SaveAllowed(void)
|
2010-06-14 21:14:58 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
if (GetTimer(CompareTimer) <= 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < MaxTimer; i++)
|
|
|
|
{
|
|
|
|
if (i == CompareTimer)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (i == ViTimer)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (m_TimerDetatils[i].Active)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-10-23 18:53:01 +00:00
|
|
|
|
2016-04-20 09:18:13 +00:00
|
|
|
void CSystemTimer::SaveData(zipFile & file) const
|
2010-10-23 18:53:01 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
uint32_t TimerDetailsSize = sizeof(TIMER_DETAILS);
|
|
|
|
uint32_t Entries = sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]);
|
|
|
|
zipWriteInFileInZip(file, &TimerDetailsSize, sizeof(TimerDetailsSize));
|
|
|
|
zipWriteInFileInZip(file, &Entries, sizeof(Entries));
|
|
|
|
zipWriteInFileInZip(file, (void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
|
|
|
|
zipWriteInFileInZip(file, (void *)&m_LastUpdate, sizeof(m_LastUpdate));
|
|
|
|
zipWriteInFileInZip(file, &m_NextTimer, sizeof(m_NextTimer));
|
|
|
|
zipWriteInFileInZip(file, (void *)&m_Current, sizeof(m_Current));
|
2016-04-20 09:18:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSystemTimer::SaveData(CFile & file) const
|
|
|
|
{
|
|
|
|
uint32_t TimerDetailsSize = sizeof(TIMER_DETAILS);
|
|
|
|
uint32_t Entries = sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]);
|
2016-08-11 07:53:01 +00:00
|
|
|
|
2016-04-20 09:18:13 +00:00
|
|
|
file.Write(&TimerDetailsSize, sizeof(TimerDetailsSize));
|
|
|
|
file.Write(&Entries, sizeof(Entries));
|
|
|
|
file.Write((void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
|
|
|
|
file.Write((void *)&m_LastUpdate, sizeof(m_LastUpdate));
|
|
|
|
file.Write(&m_NextTimer, sizeof(m_NextTimer));
|
|
|
|
file.Write((void *)&m_Current, sizeof(m_Current));
|
2010-10-23 18:53:01 +00:00
|
|
|
}
|
|
|
|
|
2016-04-20 21:21:15 +00:00
|
|
|
void CSystemTimer::LoadData(zipFile & file)
|
2010-10-23 18:53:01 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
uint32_t TimerDetailsSize, Entries;
|
2010-10-23 18:53:01 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
unzReadCurrentFile(file, &TimerDetailsSize, sizeof(TimerDetailsSize));
|
|
|
|
unzReadCurrentFile(file, &Entries, sizeof(Entries));
|
2010-10-23 18:53:01 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
if (TimerDetailsSize != sizeof(TIMER_DETAILS))
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Entries != sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]))
|
|
|
|
{
|
2016-08-11 07:53:01 +00:00
|
|
|
if (Entries < (sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0])))
|
|
|
|
{
|
|
|
|
memset((void *)&m_TimerDetatils, 0, sizeof(m_TimerDetatils));
|
|
|
|
unzReadCurrentFile(file, (void *)&m_TimerDetatils, Entries * sizeof(m_TimerDetatils[0]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unzReadCurrentFile(file, (void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
|
2015-12-13 06:58:08 +00:00
|
|
|
}
|
|
|
|
unzReadCurrentFile(file, (void *)&m_LastUpdate, sizeof(m_LastUpdate));
|
|
|
|
unzReadCurrentFile(file, &m_NextTimer, sizeof(m_NextTimer));
|
|
|
|
unzReadCurrentFile(file, (void *)&m_Current, sizeof(m_Current));
|
2012-09-23 22:18:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-20 21:21:15 +00:00
|
|
|
void CSystemTimer::LoadData(CFile & file)
|
|
|
|
{
|
|
|
|
uint32_t TimerDetailsSize, Entries;
|
|
|
|
|
|
|
|
file.Read(&TimerDetailsSize, sizeof(TimerDetailsSize));
|
|
|
|
file.Read(&Entries, sizeof(Entries));
|
|
|
|
|
|
|
|
if (TimerDetailsSize != sizeof(TIMER_DETAILS))
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Entries != sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]))
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
file.Read((void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
|
|
|
|
file.Read((void *)&m_LastUpdate, sizeof(m_LastUpdate));
|
|
|
|
file.Read(&m_NextTimer, sizeof(m_NextTimer));
|
|
|
|
file.Read((void *)&m_Current, sizeof(m_Current));
|
|
|
|
}
|
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
void CSystemTimer::RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer)
|
2012-09-23 22:18:44 +00:00
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
if (m_LastUpdate != rSystemTimer.m_LastUpdate)
|
|
|
|
{
|
|
|
|
LogFile.LogF("Timer-LastUpdate: %X %X\r\n", m_LastUpdate, rSystemTimer.m_LastUpdate);
|
|
|
|
}
|
|
|
|
if (m_NextTimer != rSystemTimer.m_NextTimer)
|
|
|
|
{
|
|
|
|
LogFile.LogF("Timer-NextTimer: %X %X\r\n", m_NextTimer, rSystemTimer.m_NextTimer);
|
|
|
|
}
|
|
|
|
if (m_Current != rSystemTimer.m_Current)
|
|
|
|
{
|
|
|
|
LogFile.LogF("Timer-Current %X %X\r\n", m_Current, rSystemTimer.m_Current);
|
|
|
|
}
|
|
|
|
if (m_inFixTimer != rSystemTimer.m_inFixTimer)
|
|
|
|
{
|
|
|
|
LogFile.LogF("Timer-inFixTimer %X %X\r\n", (int)m_inFixTimer, (int)rSystemTimer.m_inFixTimer);
|
|
|
|
}
|
2012-09-23 22:18:44 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
for (int i = 0; i < MaxTimer; i++)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2012-09-23 22:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSystemTimer::operator == (const CSystemTimer& rSystemTimer) const
|
|
|
|
{
|
2015-12-13 06:58:08 +00:00
|
|
|
if (m_LastUpdate != rSystemTimer.m_LastUpdate)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_NextTimer != rSystemTimer.m_NextTimer)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_Current != rSystemTimer.m_Current)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_inFixTimer != rSystemTimer.m_inFixTimer)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-09-23 22:18:44 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
for (int i = 0; i < MaxTimer; i++)
|
|
|
|
{
|
|
|
|
if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2012-09-23 22:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSystemTimer::operator != (const CSystemTimer& rSystemTimer) const
|
|
|
|
{
|
|
|
|
return !(*this == rSystemTimer);
|
2015-12-13 06:58:08 +00:00
|
|
|
}
|