Date : Sun, 25 Jan 1998 09:08:10 EST
From : DDevenp666@...
Subject: VIA Timer resetting
<< So, assume timer 1 is in continuous mode and is decrementing. The
interrupt
occurs when the timer goes negative, not when it hits zero. At this point
we see if we can generate an interrupt and the timer is reset from the
latches.
It's now that you need to know how the hardware works. When the timer is
reset, the high order latch is transferred, then the low order latch. The
same piece of hardware is used to do both resets (reduces production costs)
but it means that the 6522 needs an extra cycle to perform the reset.
What happens is this: Timer 1 crosses 0. We add the value of the latch.
But because the hardware does this when the timer goes negative (ie
time = -1) we have to add an extra 1. Then because the 6522 takes two
cycles to reset the latches we have to add another 1.
The total amount to be compensated is 2 cycles at 1MHz. If your emulator
decrements counters at 2MHz and then corrects when they are read / written
(like beebem) then you will have to add 4 cycles. >>
This is entirely correct, thanks!
What was wrong with my emulator, was the keyboard (as ever :)) generating
interrupts incorrectly. Also the screen draw code was performing 1024 2Mhz
cycles too many each vertical blank which threw out the whole timing!
Cheers
Dave
PS New release later today/Early Monday, source also.