10 Interrupt features
Subjects covered in this chapter:
* AFTER
* EVERY
* REMAIN
* The master clock
If you haven’t already noticed, a major innovation in the software of the CPC464 is its unique ability
to handle interrupts from BASIC - which means that AMSTRAD BASIC is capable of performing a
number of simultaneous but separate operations within a program. Such a facility is sometimes
referred to as multitasking, and it is implemented by the application of the new commands AFTER
and EVERY.
This facility is also clearly demonstrated in the way in which sound may be handled through
facilities such as queues and rendezvous.
Every aspect of timing is referred to the master system clock, which is a quartz controlled timing
system within the main computer that looks after the timing and synchronisation of events that
happen in the computer - things like the scanning of the display and clocking the processor. Where a
function in the hardware is related to time, this can be traced back to the quartz master clock.
The software implementation is the AFTER and EVERY command, which in keeping with the
user-friendly approach of AMSTRAD BASIC do precisely what they say: eg. AFTER the time you
have preset in the command line, the program will divert to the designated subroutine and perform
the task defined therein.
10.1 AFTER
The CPC464 maintains a real time clock. The AFTER command allows a BASIC program to arrange
for subroutines to be called at some time in the future. Four delay timers are available, each of which
may have a subroutine associated with it.
AFTER <integer expression>[, integer expression] GOSUB <line number>
The first integer expression specifies how long before the subroutine should be called. This time is
measured in 1/50ths of a second.
The second integer expression specifies which of the four possible delay timers is to be used. The
expression must yield a value in the range 0..3. If the expression is omitted, 0 is assumed.