Measuring time on CPC more precisely
Posted: Sun Nov 19, 2023 1:05 pm
With ugBasic you can measure time with TIMER instruction, that gives the the time spend since your computer boot up. The time unit is 1/50 second which is quite precise, but the Amstrad CPC is able to do better !
Thanks to the following code :
Now you can measure time 6 times more precisely !
Thanks to the following code :
Code: Select all
BITMAP ENABLE(320,200,4)
CLS
DECLARE SYSTEM PROC scnkey AT $BB06 ON CPC
DECLARE SYSTEM PROC myTime AT $BD0D ON CPC
DIM de AS WORD
DIM hl AS WORD
PRINT "Attendez un peu, et appuyez sur une touche "
CALL scnkey
ON CPUZ80 BEGIN ASM
CALL $BD0D
LD (_de),DE
LD (_hl),HL
END ASM
DIM time AS FLOAT
time = (de*256.0 + hl)/300.0
PRINT time ; "secondes"