Re: [stella] PIA timer questions

Subject: Re: [stella] PIA timer questions
From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney)
Date: Wed, 18 Aug 1999 23:30:03 GMT
>According to the Stella manual, it says that the hex address determines
>how many clock counts it takes for things to count down.  But Bensema's
>playfield document  uses TIM64T and sets it for 44.  If the number
>automatically decrements every machine cycle, why not write 37 to
>address $294 (TIM1T) to count down the number of scanlines?  Or if I'm
>thinking of the wrong cycles it needs to synch up with, write 111
>(37*3) to address $294?  What am I missing?  Or is Bensema not using
>the timer for counting the scanlines?

What you're missing is that the timer decrements every *64* machine
cycles, when you start it by writing to TIM64T.  64 cycles * 44 = 2816
cycles, which is very close to the number of cycles during vertical blank,
76 * 37 = 2812.  You start the timer at the beginning of vertical blank,
then it expires 37 scanlines later, so you know when to start drawing the
screen.

>The timer is read at $284.  How does it know which timer of the four
>addresses to read?

There's only one timer; how fast it counts depends on which register you
write to.

>The way the computer works, wouldn't the numbers in
>all four addresses start cycling down from whatever is in them at that
>random moment when the Atari starts up?

The number is only read at one address, but yeah, it would start cycling
down right at powerup.

>"It holds 0 for one interval, then flips to $FF and decrements once
>each clock cycle...to allow the programmer to determine how long ago
>the timer zeroed out...."  What happens if it hits zero again?  It
>starts at $FF again or it freezes at 0?

It would keep going at $FF again.  It wouldn't have any memory that this
is the second or later time it had hit zero.

--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread