home *** CD-ROM | disk | FTP | other *** search
- { -----------------------------------------------------------------------------
-
- NOTICE:
-
- THESE MATERIALS are UNSUPPORTED by OSS! If you do not understand how to
- use them do not contact OSS for help! We will not teach you how to
- program in Pascal. If you find an error in these materials, feel free
- to SEND US A LETTER explaining the error, and how to fix it.
-
- THE BOTTOM LINE:
-
- Use it, enjoy it, but you are on your own when using these materials!
-
-
- DISCLAIMER:
-
- OSS makes no representations or warranties with respect to the contents
- hereof and specifically disclaim all warranties of merchantability or
- fitness for any particular purpose. This document is subject to change
- without notice.
-
- OSS provides these materials for use with Personal Pascal. Use them in
- any way you wish.
-
- -------------------------------------------------------------------------- }
-
-
- program test_timer;
-
- {
-
- Program to demonstrate method of grabbing the 200hz timer in
- system variables area ($4ba)
-
- Sept. 25, 1986 M Curry
-
- }
-
- VAR
- c : char;
- start, finish : long_integer;
-
- {
-
- Declare bios and gemdos routinese we will need
- See Intro.txt, char.txt, ST Internals
-
- }
-
- Function Super( x: long_integer ) : long_integer;
- Gemdos( $20 );
-
- { ***********************************************************************
-
- Set cursor on (true) or off (false)
-
- *********************************************************************** }
-
- Procedure Cursor( b : boolean );
-
- Begin
- Write( chr( 27 ) );
- IF b THEN Write( 'e' ) ELSE Write( 'f' );
- End;
-
-
- { ************************************************************************
-
- Time Function returns system timer ticks 200/second resolution
-
- ************************************************************************ }
-
- Function Time : Long_integer;
-
- Type
-
- Long_pointer = ^long_integer;
-
- Var
-
- SSP : Long_Integer; { save old supervisor stack pointer }
-
- hz_200 : RECORD
- CASE Boolean OF
- true : ( l: long_integer );
- false : ( p: long_pointer );
- END;
-
- BEGIN
- SSP := Super( 0 ); { save supervisor stack.. enter super mode }
- hz_200.l := $4ba; { point at 200 hertz timer }
- {$p-} { turn pointer checking off }
- Time := hz_200.p^; { get the longword at that location }
- {$p=} { restore old value of pointer checking }
- SSP := Super( SSP ); { restore supervisor stack... enter user mode }
- END;
-
- { **************************************************************************
-
- Now test out the time function...
-
- ************************************************************************** }
-
- begin
- start := time; { get start time }
-
- writeln;
- writeln( '200 hz. system timer - Press any key to exit' );
-
- Cursor( FALSE ); { turn off cursor }
-
- while not Keypress do { main loop - display timer }
- write( (time / 200.0):10:2, chr(13) );
-
- Cursor( TRUE ); { turn on cursor }
- read( c ); { clean up key buffer }
-
- finish := time; { get finish time }
-
- writeln;
- write( 'Program was active for ', ( finish-start ) / 200.00 :10:3 );
- writeln( ' seconds.' );
- writeln;
-
- end.
-
-
-