2017-02-21 21:28:56 -05:00
|
|
|
#pragma once
|
2015-05-06 00:54:15 -04:00
|
|
|
|
|
|
|
#include "Types.h"
|
|
|
|
#include "INTC.h"
|
|
|
|
#include "zip/ZipArchiveWriter.h"
|
|
|
|
#include "zip/ZipArchiveReader.h"
|
|
|
|
|
|
|
|
class CTimer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
MODE_GATE_ENABLE = 0x004,
|
|
|
|
|
|
|
|
MODE_GATE_SELECT = 0x008,
|
2017-02-23 09:49:56 -05:00
|
|
|
MODE_GATE_SELECT_HBLANK = 0x000,
|
|
|
|
MODE_GATE_SELECT_VBLANK = 0x008,
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
MODE_GATE_MODE = 0x030,
|
2017-02-23 09:49:56 -05:00
|
|
|
MODE_GATE_MODE_COUNTLOW = 0x000,
|
|
|
|
MODE_GATE_MODE_HIGHEDGE = 0x010,
|
2018-04-30 21:01:23 +01:00
|
|
|
MODE_GATE_MODE_LOWEDGE = 0x020,
|
2017-02-23 09:49:56 -05:00
|
|
|
MODE_GATE_MODE_BOTHEDGE = 0x030,
|
2018-04-30 21:01:23 +01:00
|
|
|
|
|
|
|
MODE_ZERO_RETURN = 0x040,
|
|
|
|
MODE_COUNT_ENABLE = 0x080,
|
|
|
|
MODE_EQUAL_FLAG = 0x400,
|
|
|
|
MODE_OVERFLOW_FLAG = 0x800,
|
2015-05-06 00:54:15 -04:00
|
|
|
};
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CTimer(CINTC&);
|
|
|
|
virtual ~CTimer() = default;
|
2015-05-06 00:54:15 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void Reset();
|
2015-05-06 00:54:15 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void Count(unsigned int);
|
2015-05-06 00:54:15 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
uint32 GetRegister(uint32);
|
|
|
|
void SetRegister(uint32, uint32);
|
2015-05-06 00:54:15 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void LoadState(Framework::CZipArchiveReader&);
|
|
|
|
void SaveState(Framework::CZipArchiveWriter&);
|
2015-05-06 00:54:15 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void NotifyVBlankStart();
|
|
|
|
void NotifyVBlankEnd();
|
2017-02-23 09:49:56 -05:00
|
|
|
|
2015-05-06 00:54:15 -04:00
|
|
|
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);
|
2015-05-06 00:54:15 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void ProcessGateEdgeChange(uint32, uint32);
|
2017-02-23 09:49:56 -05:00
|
|
|
|
2015-05-06 00:54:15 -04:00
|
|
|
struct TIMER
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
uint32 nCOUNT;
|
|
|
|
uint32 nMODE;
|
|
|
|
uint32 nCOMP;
|
|
|
|
uint32 nHOLD;
|
2015-05-06 00:54:15 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
uint32 clockRemain;
|
2015-05-06 00:54:15 -04:00
|
|
|
};
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
TIMER m_timer[MAX_TIMER];
|
|
|
|
CINTC& m_intc;
|
2015-05-06 00:54:15 -04:00
|
|
|
};
|