home *** CD-ROM | disk | FTP | other *** search
- ATARI MACHINE SPECIFIC LIBRARY
-
-
-
- NAME
- Timer
-
- SYNOPSIS
- #include <Timer.h>
-
- unsigned long Hz200()
- void Delay(unsigned long msec)
-
- class TimerSpeed
-
- void HaltTimerA()
- void SetTimerA(void ISR(), TimerSpeed&)
- void SetTimerA(void ISR(), int Hz)
-
- DESCRIPTION
- There are two basic ways in which a real-time application controls
- the speed at which things occurs. One is by clocking to the vertical
- retrace signal (see DoubleBuffer), the other is to use one of the
- system hardware timers.
-
- FUNCTIONS
- unsigned long Hz200()
- Returns the number of 200ths of a seconds since the computer was
- turned on.
-
- void Delay(unsigned long msec)
- Wait for the given number of milliseconds (accurate to 200ths of
- a seconds).
-
- void HaltTimerA()
- Stop Timer A, the only user-free timer.
-
- void SetTimerA(void ISR(), TimerSpeed&);
- Set Timer A to execute the given INTERRUPT Service Routine at
- the speed given. NOTE: A regular C function is NOT sufficient
- to use as an ISR (see USAGE below).
-
- void SetTimerA(void ISR(), int Hz)
- A much slower form of the above.
-
- CLASSES
- class TimerSpeed is used to overcome the way timer speeds are defined.
- While it is possible to have timers run at almost any frequency, the
- value to give to the hardware for these frequencies are in terms that
- are not usually useful. By using the TimerSpeed class, these problems
- can be ignored by the programmer.
-
- CLASS MEMBERS
- TimerSpeed::
- TimerSpeed(int Hz)
- Create a timer speed as close as possible to the requested speed.
- operator int()
- Returns the actualy speed of the timer, in Hz.
-
- USAGE
- When writing an ISR, the programmer is defining a routine that will
- be executed at each pulse of the timer to which it is attached
- (Timer A). The routine will need to be written using assembler and
- should have the following form:
-
- _ISR:
- bclr #5,0xFFFFFA0F | Reset interrupt-pending signal
- moveml ...,sp@- | Save any used registers
- ... | Whatever processing is needed
- moveml sp@+,... | Restore any used registers
- rte | Return from the interrupt
-
- If an interrupt requires to disable itself, use the following in
- the "Whatever processing is needed" code:
-
- bclr #5,0xFFFFFA07 | Disable interrupt on timer A
- bclr #5,0xFFFFFA13 | Clear interrupt mask for timer A
-
- SEE ALSO
- SampledSound (uses Timer A for playing sounds)
-
- BUGS
- The minimal frequency is 82Hz.
- The maximum frequency is limited by the length of the ISR.
-
- AUTHOR
- Warwick Allison, 1992.
- warwick@cs.uq.oz.au
-
- COPYING
- This functionality is part of the Atari Machine Specific Library,
- and is Copyright 1992 by Warwick W. Allison.
-
- The Atari Machine Specific Library is free and protected under the
- GNU Library General Public License.
-
- You are free to copy and modify these sources, provided you acknowledge
- the origin by retaining this notice, and adhere to the conditions
- described in the GNU LGPL.
-