Skip to content

Commit 0752198

Browse files
committed
Randomize timer 0/2 starting phase
1 parent d74f5b8 commit 0752198

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/mikey_inline.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,13 @@ inline void Mikey::WriteTimer(u16 address, u8 value)
502502
if (prescaler_changed || enable_count_rising)
503503
{
504504
if (enable_count_rising)
505-
t->internal_cycles = (t->internal_period_cycles / 2) + 1;
505+
{
506+
if (i == 0 || i == 2)
507+
t->internal_cycles = (t->internal_period_cycles > 0) ? (rand() % t->internal_period_cycles) : 0;
508+
else
509+
t->internal_cycles = (t->internal_period_cycles / 2) + 1;
510+
511+
}
506512
else
507513
t->internal_cycles = 0;
508514

0 commit comments

Comments
 (0)