Date : Tue, 20 Jan 1998 11:20:40 +0000
From : drs1@... (David Ralph Stacey)
Subject: Re: BBC Emulator
On Monday, 19th January 1998 18:02:55, Dave (DDevenp666@...) wrote:
> Next release of the emulator delayed slightly. I finally got a copy of Revs
> and have ported it from the beeb to my PC. The emulator is minutely out on
> the timing, so until I fix this problem (which should also remove the
slight
> flickering in Elite), I will hold back on the release
I may be able to help here. A while back I had problems with xbeeb running
Revs - the colour swap was slowly running up the screen. The problem
eventually turned out to be the point at which the latches are reset.
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.
To make things clearer, the xbeeb code looks like this:
SystemViaTimer1 -= val;
if ( SystemViaTimer1 < 0 )
{
if ( SystemViaTimer1Continuous )
{
SystemViaTimer1 += (SystemVia[T1LL] + 2 + 256 * SystemVia[T1LH]);
SystemViaSetInterrupt ( INT_T1 );
}
else ...
...
}
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.
I also have slight flickering in Elite - if you discover anything then
please let me know.
Hope this helps,
Dave.