home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SLOWRUNS.ZIP / SLOWSRC.ZIP / MAGIC8.C < prev    next >
C/C++ Source or Header  |  1995-12-20  |  963b  |  43 lines

  1. #include<io.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. #include<dos.h>
  6. #include<bios.h>
  7. #include<fcntl.h>
  8. #include<memory.h>
  9. #include<malloc.h>
  10. #include<math.h>
  11. #include<string.h>
  12.  
  13. #include "magic8.h"
  14.  
  15. long starting_time, // these are used to compute the length of some event
  16.      ending_time;
  17.  
  18. void Timer_Program(int timer, unsigned int rate)
  19. {
  20.     // this function re-programs the internal timer
  21.  
  22.     // first program the timer to mode 2 - binary and data loading sequence of
  23.     // low byte then high byte
  24.  
  25.     _outp(TIMER_CONTROL, TIMER_SET_BITS);
  26.  
  27.     // write the least significant byte of the new rate to the counter register
  28.  
  29.     _outp(timer, LOW_BYTE(rate));
  30.  
  31.     // and now the most significant byte
  32.  
  33.     _outp(timer, HI_BYTE(rate));
  34. } // end Timer_Program
  35.  
  36. long Timer_Query(void)
  37. {
  38.     // this function is used to record the current time
  39.  
  40.     long far *clock = (long far *)0x0000046CL; // address of timer
  41.  
  42.     return(*clock);
  43. }