| |
jonathon Account closed
Registered: May 2007 Posts: 4 |
Using built-in timers
Hi all,
I haven't found much online for using Timer A and B. Any reason why not?
I've been able to get Timer B working counting the number of times Timer A counts down to 0, in both one-shot and continuous mode, and then changing sprite data accordingly. It seems to work just as well as counters in an interrupt or NOPs.
Any reason why Timer A and B are not used very often, from what I have seen? |
|
| |
Radiant
Registered: Sep 2004 Posts: 639 |
Nope, the timers are very practical. Go ahead and (ab)use them! Also, see Vandalism News #43 for a tutorial by Ninja/The Dreams on how to create stable raster interrupts using the timers. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
probably because the timers are straightforward, once you know which bit does what you can use them.
here is a very good reference:
http://unusedino.de/ec64/technical/aay/c64/ciamain.htm
why they arent used? well, probably since there is not much use of them. however though the fastest ways to make stable rasters all use the timers. then they could be used to make line slopes, but nobody tried so far, coz it would be probably too inaccurate. also some stretchers are using the timers. the twister in real, error 23, and the grey stretcher part in royal arte also makes heavy use of them. |
| |
yago
Registered: May 2002 Posts: 333 |
Almost all K2 Demos use timers.
We basically devide our code in 3 pieces:
1) idle loop
2) raster-irq
3) timer-irq
With this technique, we can, for example, load the next part inside the idle-loop, and still run code* inside the timer-irq.
*code which is too long to run inside raster-irq
|
| |
Style
Registered: Jun 2004 Posts: 498 |
I dont think he's talking about NMI interrupts, more the timers themselves.
I only ever use them for raster stabilisation myself. |
| |
Radiant
Registered: Sep 2004 Posts: 639 |
I know for example JackAsser also uses timers extensively, in combination with raster IRQ's, to great effect.
Myself, I've barely looked at them... |
| |
enthusi
Registered: May 2004 Posts: 677 |
They're generally used for tape-loaders!! (!!) |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
@jonathon: I've also observed this behaviour (i.e. the non using timer community) and my personal explanation is that people in general like to code demo stuff and to do that you usually start learning how to setup a raster IRQ, then u're just lazy to do anything else. IMO, both polling and using timers are used WAY too seldom when it really would suit better.
A classic example: U want to do multiplexing or some other raster based effect => then use raster IRQ. But at the same time you wish to remove the upper and lower border. Now do to this simple; use an NMI timer (which has priority over IRQ) to remove the border thus save ALOT of hazzle. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
another useful application is to have raster stuff in nmi with timers (highest priority) plus another timer irq (lower priority) to do whatever else. |
| |
trident
Registered: May 2002 Posts: 91 |
It is also possible to make a nice DYSP by setting a timer for 63 cycles and then do a jmp ($dc04) every raster line. By setting up appropriately timed routines at $3f00, $3e00, $3d00, etc., it is possible to get stable X timing. |
| |
Style
Registered: Jun 2004 Posts: 498 |
thats what I meant :) |