AMSTRAD cpc 6128 User Instruction page 403

Integrated computer/disc system
Hide thumbs Also See for cpc 6128:
Table of Contents

Advertisement

The 6128 maintains a real time clock. The AFT E R command allows a
BASIC
program to arrange for sub-routines to be called at some time in the future. Four
delay timers are available, each of which may have a sub-routine associated with it.
When the time specified has passed, the sub-routine is called automatically, just as if
aGO SUB had been issued at the current position in the program. When the
sub-routine finishes, using a normal RE
T
URN command, the main program
continues running where it was interrupted.
The EVE RY command allows a
BASIC
program to arrange for sub-routines to be
repeatedly called at regular intervals. Once again, four delay timers are available,
and each may have a sub-routine associated with it.
The timers have different interrupt priorities. Timer 3 has the highest priority and
timer 0 the lowest (see the chapter entitled 'For your reference .... ').
10 MODE 1:n=14:x=RND*400
20 AFTER x,3:GOSUB 80
30 EVERY 25,2 GOSUB 160
40 EVERY 10,1 GOSUB 170
50 PRINT "test your reflexes"
60 PRINT "press.the space bar.";
70 IF flag=1 THEN END ELSE 70
80 z=REMAIN(2)
90 IF INKEY(47)=-1 THEN 110
100 SOUND 1,900:PRINT "cheat!":GOTO 150
110 SOUND 129,20:PRINT "NOW":t=TIME
120 IF INKEY(47)=-1 THEN 120
130 PRINT "you took";
140 PRINT (TIME-t)/300;"seconds"
150 CLEAR INPUT:flag=1:RETURN
160 SOUND 1,0,50:PRINT ".";:RETURN
170 n=n+1:IF n>26 THEN n=14
180 INK 1,n:RETURN
AFT E Rand EVE R Y commands may be issued at any time, resetting the sub-routine
and time associated with the given delay timer. The delay timers are shared by the
AFT E Rand EVE R Y commands, so an AFT E R overrides any previous EVE R Y for the
given timer, and vice versa.
The D I and E I commands disable and enable timer interrupts whilst the commands
between them are executed. This has the effect of delaying a higher priority interrupt
from ever occurring during the processing of a lower priority interrupt. The REM A I N
function disables; and returns the remaining count for one of the four delay timers.
Chapter 9 Page 30
At your leisure ....

Advertisement

Table of Contents
loading

Table of Contents