timer.pas 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. History:
  14. Removed the var for all functions.
  15. 06 Sep 2000.
  16. Added the define use_amiga_smartlink.
  17. 13 Jan 2003.
  18. [email protected]
  19. }
  20. {$PACKRECORDS 2}
  21. {$IFNDEF FPC_DOTTEDUNITS}
  22. unit timer;
  23. {$ENDIF FPC_DOTTEDUNITS}
  24. INTERFACE
  25. {$IFDEF FPC_DOTTEDUNITS}
  26. uses Amiga.Core.Exec;
  27. {$ELSE FPC_DOTTEDUNITS}
  28. uses exec;
  29. {$ENDIF FPC_DOTTEDUNITS}
  30. Const
  31. { unit defintions }
  32. UNIT_MICROHZ = 0;
  33. UNIT_VBLANK = 1;
  34. UNIT_ECLOCK = 2;
  35. UNIT_WAITUNTIL = 3;
  36. UNIT_WAITECLOCK = 4;
  37. TIMERNAME : PAnsiChar = 'timer.device';
  38. Type
  39. ptimeval = ^ttimeval;
  40. ttimeval = record
  41. tv_secs : ULONG;
  42. tv_micro : ULONG;
  43. end;
  44. ptimerequest = ^ttimerequest;
  45. ttimerequest = record
  46. tr_node : tIORequest;
  47. tr_time : ttimeval;
  48. end;
  49. pEClockVal = ^tEClockVal;
  50. tEClockVal = record
  51. ev_hi : ULONG;
  52. ev_lo : ULONG;
  53. end;
  54. Const
  55. { IO_COMMAND to use for adding a timer }
  56. TR_ADDREQUEST = CMD_NONSTD;
  57. TR_GETSYSTIME = CMD_NONSTD + 1;
  58. TR_SETSYSTIME = CMD_NONSTD + 2;
  59. { To use any of the routines below, TimerBase must be set to point
  60. to the timer.device, either by calling CreateTimer or by pulling
  61. the device pointer from a valid TimeRequest, i.e.
  62. TimerBase := TimeRequest.io_Device;
  63. _after_ you have called OpenDevice on the timer.
  64. }
  65. var
  66. TimerBase : Pointer;
  67. Procedure AddTime( Dest : ptimeval location 'a0'; Source : ptimeval location 'a1'); syscall TimerBase 042;
  68. Function CmpTime( Dest : ptimeval location 'a0'; Source : ptimeval location 'a1') : ULONG; syscall TimerBase 054;
  69. Procedure SubTime( Dest : ptimeval location 'a0'; Source : ptimeval location 'a1'); syscall TimerBase 048;
  70. function ReadEClock(Dest : pEClockVal location 'a0'): longint; syscall TimerBase 060;
  71. procedure GetSysTime( Dest : ptimeval location 'a0'); syscall TimerBase 066;
  72. IMPLEMENTATION
  73. end.