home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-28 | 1.6 KB | 58 lines | [TEXT/YERK] |
- \ interval - interval timer stuff
- \ 12/14/84 cbd Version 1
- \ 10/15/85 cdn Fixed print: method in Timer
- \ 1/31/87 rfl added clear:
- \ 6/13/89 rfl added pause
- \ 12/12/90 rfl modified when: to not depend on events...looks at global 'ticks'
- \ also changed pause and wait to >= compares
- \ 2/02/91 rfl fixed stop:
- \ 1/28/93 rfl added sync:
- Decimal
-
- \ define an interval timer class
- :CLASS Timer <Super Object
-
- Var Ticks \ store system ticks=60ths
- Int On \ true = timing
-
- \ ( -- ticks ) return system ticks
- :M WHEN: global ticks @ ;M
-
- \ start timing an interval
- :M START: when: self put: ticks 1 put: on ;M
-
- \ stop the clock, and replace ticks with the interval
- :M STOP: get: on
- IF when: self get: ticks - put: ticks clear: on THEN ;M
-
- \ ( -- secs*60 ) get the current value of the clock, but keep timing if on
- :M GET: get: on
- IF when: self get: ticks -
- ELSE get: ticks THEN ;M
-
- \ print the current value of the timer, in seconds and hundredths
- :M PRINT: get: self 60 /mod 3 .R $ 2e emit 100 * 60 /
- 2 .R ." Seconds " ;M
-
- :M CLEAR: clear: on clear: ticks ;M
-
- \ sync to vbl tick
- :M SYNC: global ticks @ put: ticks BEGIN global ticks @ get: ticks > UNTIL ;M
-
- ;CLASS
-
- Timer sysTimer \ create an instance of Timer
-
- \ ( -- f OR key t ) listen to event queue, true if key event
- : ?Key next: fEvent ;
-
- \ general purpose pause where time is in 1/60ths of second - process events
- timer pTimer
- : pause { time -- } start: pTimer
- BEGIN next: fevent IF 2drop THEN get: pTimer time >= UNTIL ;
-
- \ same as pause, but don't process events
- : wait { time -- } start: pTimer
- BEGIN get: pTimer time >= UNTIL ;
-
-