mirror of
https://github.com/libretro/Play-.git
synced 2024-12-13 20:22:25 +00:00
Improved timer emulation : implemented return to zero, reenabled overflow detection and cleaned code a little bit.
git-svn-id: http://svn.purei.org/purei/trunk@794 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
parent
89fb2805e4
commit
7d4327555f
@ -26,7 +26,7 @@ void CTimer::Count(unsigned int ticks)
|
||||
{
|
||||
TIMER* timer = &m_timer[i];
|
||||
|
||||
if(!(timer->nMODE & 0x80)) continue;
|
||||
if(!(timer->nMODE & MODE_COUNT_ENABLE)) continue;
|
||||
|
||||
uint32 previousCount = timer->nCOUNT;
|
||||
uint32 nextCount = timer->nCOUNT;
|
||||
@ -57,20 +57,26 @@ void CTimer::Count(unsigned int ticks)
|
||||
//Check if it hit the reference value
|
||||
if((previousCount < compare) && (nextCount >= compare))
|
||||
{
|
||||
timer->nMODE |= 0x400;
|
||||
timer->nCOUNT = nextCount - compare;
|
||||
timer->nMODE |= MODE_EQUAL_FLAG;
|
||||
if(timer->nMODE & MODE_ZERO_RETURN)
|
||||
{
|
||||
timer->nCOUNT = nextCount - compare;
|
||||
}
|
||||
else
|
||||
{
|
||||
timer->nCOUNT = nextCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timer->nMODE &= ~0x400;
|
||||
timer->nCOUNT = nextCount;
|
||||
}
|
||||
|
||||
// if(pTimer->nCOUNT >= 0xFFFF)
|
||||
// {
|
||||
// pTimer->nMODE |= 0x800;
|
||||
// pTimer->nCOUNT &= 0xFFFF;
|
||||
// }
|
||||
if(timer->nCOUNT >= 0xFFFF)
|
||||
{
|
||||
timer->nMODE |= MODE_OVERFLOW_FLAG;
|
||||
timer->nCOUNT &= 0xFFFF;
|
||||
}
|
||||
|
||||
uint32 nMask = (timer->nMODE & 0x300) << 2;
|
||||
bool interruptPending = (timer->nMODE & nMask) != 0;
|
||||
@ -90,11 +96,9 @@ void CTimer::Count(unsigned int ticks)
|
||||
|
||||
uint32 CTimer::GetRegister(uint32 nAddress)
|
||||
{
|
||||
unsigned int nTimerId;
|
||||
|
||||
DisassembleGet(nAddress);
|
||||
|
||||
nTimerId = (nAddress >> 11) & 0x3;
|
||||
unsigned int nTimerId = (nAddress >> 11) & 0x3;
|
||||
|
||||
switch(nAddress & 0x7FF)
|
||||
{
|
||||
@ -140,11 +144,9 @@ uint32 CTimer::GetRegister(uint32 nAddress)
|
||||
|
||||
void CTimer::SetRegister(uint32 nAddress, uint32 nValue)
|
||||
{
|
||||
unsigned int nTimerId;
|
||||
|
||||
DisassembleSet(nAddress, nValue);
|
||||
|
||||
nTimerId = (nAddress >> 11) & 0x3;
|
||||
unsigned int nTimerId = (nAddress >> 11) & 0x3;
|
||||
|
||||
switch(nAddress & 0x7FF)
|
||||
{
|
||||
@ -190,9 +192,7 @@ void CTimer::SetRegister(uint32 nAddress, uint32 nValue)
|
||||
|
||||
void CTimer::DisassembleGet(uint32 nAddress)
|
||||
{
|
||||
unsigned int nTimerId;
|
||||
|
||||
nTimerId = (nAddress >> 11) & 0x3;
|
||||
unsigned int nTimerId = (nAddress >> 11) & 0x3;
|
||||
|
||||
switch(nAddress & 0x7FF)
|
||||
{
|
||||
@ -216,9 +216,7 @@ void CTimer::DisassembleGet(uint32 nAddress)
|
||||
|
||||
void CTimer::DisassembleSet(uint32 nAddress, uint32 nValue)
|
||||
{
|
||||
unsigned int nTimerId;
|
||||
|
||||
nTimerId = (nAddress >> 11) & 0x3;
|
||||
unsigned int nTimerId = (nAddress >> 11) & 0x3;
|
||||
|
||||
switch(nAddress & 0x7FF)
|
||||
{
|
||||
|
@ -7,13 +7,13 @@
|
||||
class CTimer
|
||||
{
|
||||
public:
|
||||
enum REGISTERS
|
||||
{
|
||||
T0_COUNT = 0x10000000,
|
||||
T0_MODE = 0x10000010,
|
||||
T0_COMP = 0x10000020,
|
||||
T0_HOLD = 0x10000030,
|
||||
};
|
||||
enum
|
||||
{
|
||||
MODE_ZERO_RETURN = 0x040,
|
||||
MODE_COUNT_ENABLE = 0x080,
|
||||
MODE_EQUAL_FLAG = 0x400,
|
||||
MODE_OVERFLOW_FLAG = 0x800,
|
||||
};
|
||||
|
||||
CTimer(CINTC&);
|
||||
virtual ~CTimer();
|
||||
|
Loading…
Reference in New Issue
Block a user