mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-27 08:05:41 +00:00
Timers: Add missing event update after resetting count/target
This commit is contained in:
parent
bdf9c91271
commit
34d27bad4a
|
@ -115,11 +115,20 @@ void Timers::AddTicks(u32 timer, TickCount count)
|
||||||
{
|
{
|
||||||
interrupt_request |= cs.mode.irq_at_target;
|
interrupt_request |= cs.mode.irq_at_target;
|
||||||
cs.mode.reached_target = true;
|
cs.mode.reached_target = true;
|
||||||
|
|
||||||
|
if (cs.mode.reset_at_target)
|
||||||
|
{
|
||||||
|
if (cs.target > 0)
|
||||||
|
cs.counter %= cs.target;
|
||||||
|
else
|
||||||
|
cs.counter = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cs.counter >= 0xFFFF)
|
if (cs.counter >= 0xFFFF)
|
||||||
{
|
{
|
||||||
interrupt_request |= cs.mode.irq_on_overflow;
|
interrupt_request |= cs.mode.irq_on_overflow;
|
||||||
cs.mode.reached_overflow = true;
|
cs.mode.reached_overflow = true;
|
||||||
|
cs.counter %= 0xFFFFu;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interrupt_request)
|
if (interrupt_request)
|
||||||
|
@ -137,18 +146,6 @@ void Timers::AddTicks(u32 timer, TickCount count)
|
||||||
UpdateIRQ(timer);
|
UpdateIRQ(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cs.mode.reset_at_target)
|
|
||||||
{
|
|
||||||
if (cs.target > 0)
|
|
||||||
cs.counter %= cs.target;
|
|
||||||
else
|
|
||||||
cs.counter = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cs.counter %= 0xFFFF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timers::AddSysClkTicks(TickCount sysclk_ticks)
|
void Timers::AddSysClkTicks(TickCount sysclk_ticks)
|
||||||
|
@ -242,6 +239,8 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
{
|
{
|
||||||
Log_DebugPrintf("Timer %u write counter %u", timer_index, value);
|
Log_DebugPrintf("Timer %u write counter %u", timer_index, value);
|
||||||
cs.counter = value & u32(0xFFFF);
|
cs.counter = value & u32(0xFFFF);
|
||||||
|
if (timer_index == 2 || !cs.external_counting_enabled)
|
||||||
|
UpdateSysClkEvent();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -265,6 +264,8 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
{
|
{
|
||||||
Log_DebugPrintf("Timer %u write target 0x%04X", timer_index, ZeroExtend32(Truncate16(value)));
|
Log_DebugPrintf("Timer %u write target 0x%04X", timer_index, ZeroExtend32(Truncate16(value)));
|
||||||
cs.target = value & u32(0xFFFF);
|
cs.target = value & u32(0xFFFF);
|
||||||
|
if (timer_index == 2 || !cs.external_counting_enabled)
|
||||||
|
UpdateSysClkEvent();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue