home *** CD-ROM | disk | FTP | other *** search
/ Black Art of 3D Game Programming / Black_Art_of_3D_Game_Programming.iso / source / borland / chap_8 / black8.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-20  |  1.4 KB  |  61 lines

  1.  
  2. // BLACK8.C - Library Module
  3.  
  4. // I N C L U D E S ///////////////////////////////////////////////////////////
  5.  
  6. #include <io.h>
  7. #include <conio.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <dos.h>
  11. #include <bios.h>
  12. #include <fcntl.h>
  13. #include <memory.h>
  14. #include <malloc.h>
  15. #include <math.h>
  16. #include <string.h>
  17.  
  18. #include "black8.h"
  19.  
  20. // G L O B A L S /////////////////////////////////////////////////////////////
  21.  
  22. long starting_time,  // these are used to compute the length of some event
  23.      ending_time;
  24.  
  25. // F U N C T I O N S//////////////////////////////////////////////////////////
  26.  
  27. long Timer_Query(void)
  28. {
  29. // this function is used to record the current time
  30.  
  31. long far *clock = (long far *)0x0000046CL; // address of timer
  32.  
  33. return(*clock);
  34.  
  35. } // end Timer_Query
  36.  
  37. //////////////////////////////////////////////////////////////////////////////
  38.  
  39. void Timer_Program(int timer,unsigned int rate)
  40. {
  41.  
  42. // this function re-programs the internal timer
  43.  
  44. // first program the timer to mode 2 - binary and data loading sequence of
  45. // low byte then high byte
  46.  
  47. outp(TIMER_CONTROL, TIMER_SET_BITS);
  48.  
  49. // write least significant byte of the new rate to the counter register
  50.  
  51. outp(timer,LOW_BYTE(rate));
  52.  
  53. // and now the the most significant byte
  54.  
  55. outp(timer,HI_BYTE(rate));
  56.  
  57. } // end Timer_Program
  58.  
  59. ///////////////////////////////////////////////////////////////////////////////
  60.  
  61.