Play-/Source/ee/Timer.h

94 lines
1.6 KiB
C
Raw Permalink Normal View History

2017-02-21 21:28:56 -05:00
#pragma once
#include "Types.h"
#include "INTC.h"
#include "zip/ZipArchiveWriter.h"
#include "zip/ZipArchiveReader.h"
class CGSHandler;
class CTimer
{
public:
enum
{
2019-01-02 21:32:11 -05:00
MODE_CLOCK_SELECT = 0x003,
MODE_CLOCK_SELECT_BUSCLOCK = 0x000,
MODE_CLOCK_SELECT_BUSCLOCK16 = 0x001,
MODE_CLOCK_SELECT_BUSCLOCK256 = 0x002,
MODE_CLOCK_SELECT_EXTERNAL = 0x003,
2018-04-30 21:01:23 +01:00
MODE_GATE_ENABLE = 0x004,
MODE_GATE_SELECT = 0x008,
MODE_GATE_SELECT_HBLANK = 0x000,
MODE_GATE_SELECT_VBLANK = 0x008,
2018-04-30 21:01:23 +01:00
MODE_GATE_MODE = 0x030,
MODE_GATE_MODE_COUNTLOW = 0x000,
MODE_GATE_MODE_HIGHEDGE = 0x010,
2018-04-30 21:01:23 +01:00
MODE_GATE_MODE_LOWEDGE = 0x020,
MODE_GATE_MODE_BOTHEDGE = 0x030,
2018-04-30 21:01:23 +01:00
MODE_ZERO_RETURN = 0x040,
MODE_COUNT_ENABLE = 0x080,
MODE_EQUAL_INT_ENABLE = 0x100,
MODE_OVERFLOW_INT_ENABLE = 0x200,
2018-04-30 21:01:23 +01:00
MODE_EQUAL_FLAG = 0x400,
MODE_OVERFLOW_FLAG = 0x800,
};
2019-01-02 21:32:11 -05:00
enum REGISTER
{
T1_COUNT = 0x10000800,
2022-02-10 15:43:34 -05:00
T2_MODE = 0x10001010,
T3_COUNT = 0x10001800,
2019-01-02 21:32:11 -05:00
T3_MODE = 0x10001810,
T3_COMP = 0x10001820,
2019-01-02 21:32:11 -05:00
};
CTimer(CINTC&, CGSHandler*&);
2018-04-30 21:01:23 +01:00
virtual ~CTimer() = default;
2018-04-30 21:01:23 +01:00
void Reset();
2018-04-30 21:01:23 +01:00
void Count(unsigned int);
2018-04-30 21:01:23 +01:00
uint32 GetRegister(uint32);
void SetRegister(uint32, uint32);
2018-04-30 21:01:23 +01:00
void LoadState(Framework::CZipArchiveReader&);
void SaveState(Framework::CZipArchiveWriter&);
2018-04-30 21:01:23 +01:00
void NotifyVBlankStart();
void NotifyVBlankEnd();
private:
2017-02-22 09:26:20 -05:00
enum
{
MAX_TIMER = 4,
};
2018-04-30 21:01:23 +01:00
void DisassembleGet(uint32);
void DisassembleSet(uint32, uint32);
2018-04-30 21:01:23 +01:00
void ProcessGateEdgeChange(uint32, uint32);
struct TIMER
{
2018-04-30 21:01:23 +01:00
uint32 nCOUNT;
uint32 nMODE;
uint32 nCOMP;
uint32 nHOLD;
2018-04-30 21:01:23 +01:00
uint32 clockRemain;
};
2018-04-30 21:01:23 +01:00
TIMER m_timer[MAX_TIMER];
CINTC& m_intc;
CGSHandler*& m_gs;
};