110 PRINT "Testing at
";sp?("50","60"); "Hz
ended
at:";H2;":";M2;":";S2
120 STOP
130 DEFPROC perftest(frames)
140 PAUSE frames
150 ENDPROC
160 DEFPROC GetTime()
170 a$=TIME$
180 h,m,s=VAL(a$ (12 TO 13)),
VAL(a$(15 TO
16)),VAL(a$(18 TO))
190 ENDPROC = h,m,s
Line 10 reads the Next Register bit that holds the vertical frequency to see if it's 50 or 60Hz before asking you how many PAUSE frames you want to test against. The next thing that happens is that procedure GetTime is called which gets the current time in a string formatted as described above in the section devoted to TIME$. By using string slicing and the VAL function we can get the hour, minute and second separately in case we need to manipulate or use them later. Immediately afterwards, the TIME command is initiated which as we mentioned above resets the frame counter. Following that, we call procedure PerfTest which performs a PAUSE for as many frames as we've asked already for and then we inform the user if the requested PAUSE frames and the actual frames as returned by function TIME match. Finally we get once again the current time, store it in variables h2,m2 and s2 and display it. If you run the program for enough frames and you perform some arithmetic using s1, m1, h1 and s2, m2 and h2 you'll easily figure out how much time a frame as requested by PAUSE lasts.
Here is a revised clock program to make use of this:
10 REM First we draw the clock face
20 FOR n=1 TO 12
30 PRINT AT 10-10*COS(n/6*PI),
16+10*SIN(n/6*PI);n
40 NEXT n
50 DEF FN secs()=VAL TIME$(18 TO):
REM Get the number of seconds
100 REM Now we start the clock
110 t1=FN secs()
120 a=t1/30*PI: REM a is the angle of
the second hand in radians
130 sx,sy=72*SIN a,72*COS a
140 PLOT 131,91: DRAW OVER 1;sx,sy:
REM draw hand
200 t=FN secs()
210 IF t<=t1 AND t<>0 THEN GO TO 200:
ELSE IF t=0 and t1 >t then go to
220: else go to 220: REM wait
until time for next hand except
if seconds reset to 0
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.