home *** CD-ROM | disk | FTP | other *** search
- \ Attempt to rationally (is that possible?) deal with time intervals
-
- hex
-
- \ This variable counts the number of 5 msec timer ticks
- \ The manual says that this variable is at 4bc but it's really
- \ at 4ba on my system
- : get-ticks ( -- timer-ticks ) 4ba l@ ;
-
- 5 constant ms/tick ( -- n )
- td 1000 ms/tick / constant ticks/second ( -- )
-
- \ This is not done with the existing comparison operators because
- \ we want to allow arbitrary crossings of the positive-to-negative
- \ boundaries of the number circle
- : reached? ( target -- ticks>=target? )
- get-ticks - 0<
- ;
- : ms ( n -- ) \ Delay for at least n milliseconds
- ms/tick / ( #ticks )
- 1+ \ Delay at least 1 tick
- get-ticks + ( target )
- begin pause dup reached? until
- drop
- ;
-