From 805e2d15c6039c174ad488d8eeaf20e54be6402a Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Fri, 10 Jun 2016 18:20:16 -0400
Subject: [PATCH] Fixed timing when clock is divided.

---
 Machines/Atari2600/Atari2600.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp
index e479780f5..2f85d1f65 100644
--- a/Machines/Atari2600/Atari2600.cpp
+++ b/Machines/Atari2600/Atari2600.cpp
@@ -721,7 +721,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
 					case 0x06:
 					case 0x07:
 						_writtenPiaTimerShift = _piaTimerShift = (decodedAddress - 0x04) * 3 + (decodedAddress / 0x07);	// i.e. 0, 3, 6, 10
-						_piaTimerValue = (unsigned int)(*value) << _piaTimerShift;
+						_piaTimerValue = ((unsigned int)(*value) << _piaTimerShift) | ((1 << _piaTimerShift)-1);
 						_piaTimerStatus &= ~0x40;
 					break;
 				}