Date : Mon, 01 Apr 1996 11:52:01 +0100 (BST)
From : James Fidell <james@...>
Subject: Re: More VIA queries
Tom Seddon wrote:
> I've just updated my VIA code so that timer reads return correct(ish)
> values -- although the timers themselves are updated only every 128
> cycles, on each read I add the number of cycles since the last update to
> the value.
>
> But... how many cycles does the 6502 take when executing an instruction
> before actually reading from memory? I suppose that really I should be
> adding this value to the timer as well, in case the timer is incremented
> between the start of the instruction and the time the memory read takes
> place. Is this value constant for all instructions, or does it vary (in
> which case I shan't bother!)? My ultimate aim is to get games which decode
> themselves using the timers working, although I'll settle for greater
> compatibility in general...
The number of clock cycles varies depending on the type of instruction
and the instruction mode. The best discussion I've seen of this is
in the 64doc file which comes with one of the c64 emulators. It's also
in the doc directory in the Xbeeb sources.
Remember that you not only have to handle the variable number of
cycles before the physical read, but also multiple reads due to
carry propagation in address calculations within the 6502 and also
clock-stretching whilst accessing the memory-mapped IO pages.
James.
--
"Yield to temptation -- | Work: james@...
it may not pass your way again" | Play: james@...
| http://www.OiT.co.uk/~james/
- Lazarus Long | James Fidell