2012-12-19 09:30:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-04-14 05:34:15 +00:00
|
|
|
#include <Common/Log.h>
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/N64System/N64Types.h>
|
2021-04-14 05:34:15 +00:00
|
|
|
#include <Project64-core/N64System/Mips/Register.h>
|
2016-04-21 03:55:37 +00:00
|
|
|
#include <Project64-core/3rdParty/zip.h>
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2022-03-21 00:29:02 +00:00
|
|
|
class AudioInterfaceHandler;
|
|
|
|
|
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-12-13 06:58:08 +00:00
|
|
|
enum TimerType
|
|
|
|
{
|
|
|
|
UnknownTimer,
|
|
|
|
CompareTimer,
|
|
|
|
SoftResetTimer,
|
|
|
|
ViTimer,
|
|
|
|
AiTimerInterrupt,
|
|
|
|
AiTimerBusy,
|
|
|
|
AiTimerDMA,
|
|
|
|
SiTimer,
|
|
|
|
PiTimer,
|
|
|
|
RspTimer,
|
|
|
|
RSPTimerDlist,
|
2016-01-23 21:44:58 +00:00
|
|
|
DDPiTimer,
|
2020-06-05 12:36:49 +00:00
|
|
|
DDSeekTimer,
|
|
|
|
DDMotorTimer,
|
2022-08-22 03:17:44 +00:00
|
|
|
RomWriteDecay,
|
2015-12-13 06:58:08 +00:00
|
|
|
MaxTimer
|
|
|
|
};
|
2010-05-23 10:05:41 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
struct TIMER_DETAILS
|
|
|
|
{
|
2016-05-01 02:47:39 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
int64_t reserved;
|
|
|
|
bool Active;
|
|
|
|
};
|
2015-12-21 21:38:56 +00:00
|
|
|
int64_t CyclesToTimer;
|
2015-12-13 06:58:08 +00:00
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2022-08-22 03:17:44 +00:00
|
|
|
CSystemTimer(CN64System & System);
|
2021-04-14 05:34:15 +00:00
|
|
|
void SetTimer(TimerType Type, uint32_t Cycles, bool bRelative);
|
2015-12-06 09:59:58 +00:00
|
|
|
uint32_t GetTimer(TimerType Type);
|
2021-04-14 05:34:15 +00:00
|
|
|
void StopTimer(TimerType Type);
|
|
|
|
void UpdateTimers();
|
|
|
|
void TimerDone();
|
|
|
|
void Reset();
|
|
|
|
void UpdateCompareTimer();
|
|
|
|
bool SaveAllowed();
|
2010-10-23 18:53:01 +00:00
|
|
|
|
2021-04-14 05:34:15 +00:00
|
|
|
void SaveData(zipFile & file) const;
|
|
|
|
void SaveData(CFile & file) const;
|
|
|
|
void LoadData(zipFile & file);
|
|
|
|
void LoadData(CFile & file);
|
2012-09-23 22:18:44 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
void RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer);
|
2010-05-23 10:05:41 +00:00
|
|
|
|
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;
|
2012-09-23 22:18:44 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
private:
|
2021-04-13 00:07:11 +00:00
|
|
|
CSystemTimer(void);
|
|
|
|
CSystemTimer(const CSystemTimer&);
|
|
|
|
CSystemTimer& operator=(const CSystemTimer&);
|
2010-05-23 10:05:41 +00:00
|
|
|
|
2015-12-13 06:58:08 +00:00
|
|
|
void SetCompareTimer();
|
|
|
|
void FixTimers();
|
2022-08-22 03:17:44 +00:00
|
|
|
|
|
|
|
CN64System & m_System;
|
2021-04-13 00:07:11 +00:00
|
|
|
TIMER_DETAILS m_TimerDetatils[MaxTimer];
|
|
|
|
int32_t m_LastUpdate;
|
|
|
|
int32_t & m_NextTimer;
|
|
|
|
TimerType m_Current;
|
|
|
|
bool m_inFixTimer;
|
|
|
|
CRegisters & m_Reg;
|
2022-08-22 03:17:44 +00:00
|
|
|
RomMemoryHandler & m_RomMemoryHandler;
|
2022-03-21 00:29:02 +00:00
|
|
|
AudioInterfaceHandler & m_AudioInterface;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|