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

87 lines
2.0 KiB
C
Raw Normal View History

2012-12-19 09:30:18 +00:00
#pragma once
2021-04-14 05:34:15 +00:00
#include <Common/Log.h>
2016-04-21 03:55:37 +00:00
#include <Project64-core/3rdParty/zip.h>
2022-10-10 00:22:17 +00:00
#include <Project64-core/N64System/Mips/Register.h>
#include <Project64-core/N64System/N64Types.h>
class AudioInterfaceHandler;
2022-10-10 00:22:17 +00:00
class RomMemoryHandler;
class CSystemTimer
{
public:
2015-12-13 06:58:08 +00:00
enum TimerType
{
UnknownTimer,
CompareTimer,
SoftResetTimer,
ViTimer,
AiTimerInterrupt,
AiTimerBusy,
AiTimerDMA,
SiTimer,
PiTimer,
RspTimer,
RSPTimerDlist,
DDPiTimer,
DDSeekTimer,
DDMotorTimer,
RomWriteDecay,
2015-12-13 06:58:08 +00:00
MaxTimer
};
2015-12-13 06:58:08 +00:00
struct TIMER_DETAILS
{
2022-10-10 00:22:17 +00:00
union
{
int64_t reserved;
bool Active;
};
int64_t CyclesToTimer;
2015-12-13 06:58:08 +00:00
};
CSystemTimer(CN64System & System);
2021-04-14 05:34:15 +00:00
void SetTimer(TimerType Type, uint32_t Cycles, bool bRelative);
2022-10-10 00:22:17 +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();
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);
2022-10-10 00:22:17 +00:00
void RecordDifference(CLog & LogFile, const CSystemTimer & rSystemTimer);
2022-10-10 00:22:17 +00:00
TimerType CurrentType() const
{
return m_Current;
}
2015-12-13 06:58:08 +00:00
2022-10-10 00:22:17 +00:00
bool operator==(const CSystemTimer & rSystemTimer) const;
bool operator!=(const CSystemTimer & rSystemTimer) const;
private:
CSystemTimer(void);
2022-10-10 00:22:17 +00:00
CSystemTimer(const CSystemTimer &);
CSystemTimer & operator=(const CSystemTimer &);
2015-12-13 06:58:08 +00:00
void SetCompareTimer();
void FixTimers();
2022-10-10 00:22:17 +00:00
CN64System & m_System;
TIMER_DETAILS m_TimerDetatils[MaxTimer];
int32_t m_LastUpdate;
int32_t & m_NextTimer;
TimerType m_Current;
bool m_inFixTimer;
CRegisters & m_Reg;
RomMemoryHandler & m_RomMemoryHandler;
AudioInterfaceHandler & m_AudioInterface;
};