2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* 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
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
#include "..\\N64 Types.h"
|
|
|
|
|
2012-11-29 11:23:35 +00:00
|
|
|
class CSystemTimer
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2010-05-23 10:05:41 +00:00
|
|
|
public:
|
2015-03-29 17:19:28 +00:00
|
|
|
enum TimerType
|
|
|
|
{
|
2010-05-23 10:05:41 +00:00
|
|
|
UnknownTimer,
|
|
|
|
CompareTimer,
|
|
|
|
SoftResetTimer,
|
|
|
|
ViTimer,
|
2013-01-04 22:48:25 +00:00
|
|
|
AiTimerInterrupt,
|
|
|
|
AiTimerBusy,
|
2010-05-23 10:05:41 +00:00
|
|
|
AiTimerDMA,
|
|
|
|
SiTimer,
|
|
|
|
PiTimer,
|
|
|
|
RspTimer,
|
|
|
|
RSPTimerDlist,
|
|
|
|
MaxTimer
|
|
|
|
};
|
|
|
|
|
2015-05-04 00:08:53 +00:00
|
|
|
struct TIMER_DETAILS
|
2015-03-29 17:19:28 +00:00
|
|
|
{
|
2010-05-23 10:05:41 +00:00
|
|
|
bool Active;
|
|
|
|
__int64 CyclesToTimer;
|
2015-05-04 00:08:53 +00:00
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
public:
|
2010-05-23 10:05:41 +00:00
|
|
|
CSystemTimer ( int & NextTimer );
|
|
|
|
void SetTimer ( TimerType Type, DWORD Cycles, bool bRelative );
|
2010-06-14 21:14:58 +00:00
|
|
|
DWORD GetTimer ( TimerType Type );
|
2010-05-23 10:05:41 +00:00
|
|
|
void StopTimer ( TimerType Type );
|
2015-04-28 22:19:02 +00:00
|
|
|
void UpdateTimers ();
|
|
|
|
void TimerDone ();
|
|
|
|
void Reset ();
|
|
|
|
void UpdateCompareTimer ();
|
|
|
|
bool SaveAllowed ();
|
2010-05-23 10:05:41 +00:00
|
|
|
|
2010-10-23 18:53:01 +00:00
|
|
|
void SaveData ( void * file ) const;
|
|
|
|
void LoadData ( void * file );
|
|
|
|
|
2012-09-23 22:18:44 +00:00
|
|
|
void RecordDifference( CLog &LogFile, const CSystemTimer& rSystemTimer);
|
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
TimerType CurrentType() const { return m_Current; }
|
2010-05-23 10:05:41 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
bool operator == (const CSystemTimer& rSystemTimer) const;
|
|
|
|
bool operator != (const CSystemTimer& rSystemTimer) const;
|
2012-09-23 22:18:44 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
private:
|
2010-05-23 10:05:41 +00:00
|
|
|
TIMER_DETAILS m_TimerDetatils[MaxTimer];
|
2010-07-05 11:29:46 +00:00
|
|
|
int m_LastUpdate; //Timer at last update
|
2015-04-28 22:19:02 +00:00
|
|
|
int & m_NextTimer;
|
2010-05-23 10:05:41 +00:00
|
|
|
TimerType m_Current;
|
2010-07-05 11:29:46 +00:00
|
|
|
bool m_inFixTimer;
|
2010-05-23 10:05:41 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void SetCompareTimer();
|
|
|
|
void FixTimers();
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|