project64/Source/Project64-core/N64System/Mips/SystemTiming.h

76 lines
2.5 KiB
C
Raw Normal View History

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 *
* *
****************************************************************************/
#pragma once
2015-12-06 09:59:58 +00:00
#include <Common/LogClass.h>
#include <Project64-core/N64System/N64Types.h>
class CSystemTimer
{
public:
2015-12-13 06:58:08 +00:00
enum TimerType
{
UnknownTimer,
CompareTimer,
SoftResetTimer,
ViTimer,
AiTimerInterrupt,
AiTimerBusy,
AiTimerDMA,
SiTimer,
PiTimer,
RspTimer,
RSPTimerDlist,
MaxTimer
};
2015-12-13 06:58:08 +00:00
struct TIMER_DETAILS
{
bool Active;
int64_t CyclesToTimer;
2015-12-13 06:58:08 +00:00
};
public:
2015-12-13 06:58:08 +00:00
CSystemTimer(int & NextTimer);
2015-12-06 09:59:58 +00:00
void SetTimer(TimerType Type, uint32_t Cycles, bool bRelative);
uint32_t GetTimer(TimerType Type);
2015-12-13 06:58:08 +00:00
void StopTimer(TimerType Type);
void UpdateTimers();
void TimerDone();
void Reset();
void UpdateCompareTimer();
bool SaveAllowed();
2015-12-13 06:58:08 +00:00
void SaveData(void * file) const;
void LoadData(void * file);
2015-12-13 06:58:08 +00:00
void RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer);
2015-12-13 06:58:08 +00:00
TimerType CurrentType() const { return m_Current; }
bool operator == (const CSystemTimer& rSystemTimer) const;
bool operator != (const CSystemTimer& rSystemTimer) const;
private:
CSystemTimer(void); // Disable default constructor
CSystemTimer(const CSystemTimer&); // Disable copy constructor
CSystemTimer& operator=(const CSystemTimer&); // Disable assignment
2015-12-13 06:58:08 +00:00
TIMER_DETAILS m_TimerDetatils[MaxTimer];
int m_LastUpdate; //Timer at last update
int & m_NextTimer;
TimerType m_Current;
bool m_inFixTimer;
2015-12-13 06:58:08 +00:00
void SetCompareTimer();
void FixTimers();
};